-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BuildTarget: Expose source paths as environment variable
It is possible for multiple modules to share the same build target, but the executed class/command could not determine which modules referenced it. This limitation is addressed by introducing a new environment variable `MODULE_SOURCE_PATHS` which will contain the source paths of all modules that depend on the build target.
- Loading branch information
Showing
8 changed files
with
131 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ object TestProcessHelper { | |
cwd, | ||
cmd, | ||
None, | ||
List(), | ||
None, | ||
Log.urgent, | ||
out => sb.append(out + "\n") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[project] | ||
scalaVersion = "2.13.0" | ||
|
||
[module.utils.jvm] | ||
sources = ["utils"] | ||
|
||
[module.utils.target.gen-sources] | ||
class = ["utils:jvm", "GenerateSources"] | ||
await = true | ||
|
||
# `template1` and `template2` share the code generator `utils:gen-sources` | ||
[module.template1.jvm] | ||
moduleDeps = ["utils"] | ||
sources = ["template1"] | ||
|
||
[module.template2.jvm] | ||
moduleDeps = ["utils"] | ||
sources = ["template2"] | ||
|
||
[module.demo.jvm] | ||
moduleDeps = ["template1", "template2"] | ||
sources = ["demo"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object Main { | ||
def main(args: Array[String]): Unit = Generated.modulePaths.foreach(println) | ||
} |
16 changes: 16 additions & 0 deletions
16
test/custom-class-target-shared/utils/GenerateSources.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import java.io.File | ||
import java.nio.file.{Files, Paths, StandardOpenOption} | ||
|
||
object GenerateSources { | ||
def main(args: Array[String]): Unit = { | ||
val modulePath = sys.env("MODULE_PATH") | ||
val moduleSourcePaths = | ||
sys.env("MODULE_SOURCE_PATHS").split(File.pathSeparatorChar) | ||
val generatedPath = | ||
Paths.get(modulePath).resolve("demo").resolve("Generated.scala") | ||
val pathsScala = moduleSourcePaths.mkString("\"", "\", \"", "\"") | ||
val output = s"object Generated { val modulePaths = List($pathsScala) }" | ||
|
||
Files.write(generatedPath, output.getBytes) | ||
} | ||
} |