Skip to content

Commit 1e416e6

Browse files
authored
allow to disable codegen (#219)
Useful e.g. if users want to modify the generated files and ensure their changes are not being overridden by the codegen.
1 parent 4f9df48 commit 1e416e6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[![Build Status](https://github.com/ShiftleftSecurity/overflowdb-codegen/workflows/release/badge.svg)](https://github.com/ShiftleftSecurity/overflowdb-codegen/actions?query=workflow%3Arelease)
22

33
# overflowdb-codegen
4+
5+
## Configuration overview: TODO
6+
7+
## Disable temporarily
8+
You can temporarily disable the codegen in your build by setting the environment variable `ODB_CODEGEN_DISABLE=true`. That's useful e.g. if you made some manual changes to the generated files that would otherwise be overridden by the codegen.

sbt-overflowdb/src/main/scala/overflowdb/codegen/sbt/OdbCodegenSbtPlugin.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ object OdbCodegenSbtPlugin extends AutoPlugin {
5656
lazy val lastSchemaAndDependenciesHash: Option[String] =
5757
Try(IO.read(schemaAndDependenciesHashFile)).toOption
5858

59-
if (outputDirValue.exists && lastSchemaAndDependenciesHash == Some(currentSchemaAndDependenciesHash)) {
60-
// inputs did not change, don't regenerate
59+
val disabled = sys.env.getOrElse("ODB_CODEGEN_DISABLE", default = "false").toLowerCase == "true"
60+
if (disabled) {
6161
Def.task {
62+
streams.value.log.info("overflowdb codegen is disabled")
6263
outputDirValue
6364
}
65+
} else if (outputDirValue.exists && lastSchemaAndDependenciesHash == Some(currentSchemaAndDependenciesHash)) {
66+
// inputs did not change, don't regenerate
67+
Def.task { outputDirValue }
6468
} else {
6569
Def.task {
6670
FileUtils.deleteRecursively(outputDirValue)

0 commit comments

Comments
 (0)