Skip to content

Commit

Permalink
Bloop: Fix classpath of modules with transitive dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tindzk committed Sep 17, 2019
1 parent 02fd155 commit cf7e6aa
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 22 deletions.
32 changes: 13 additions & 19 deletions src/main/scala/seed/config/BuildConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,12 @@ object BuildConfig {
module: Module
): List[Path] =
module.moduleDeps
.filter(name => hasTarget(build, name, Platform.JavaScript))
.flatMap(
name =>
buildPath
.resolve(targetName(build, name, JavaScript)) +: collectJsClassPath(
buildPath,
build,
build(name).module
build(name).module.js.toList.flatMap(
js =>
buildPath.resolve(targetName(build, name, JavaScript)) +:
collectJsClassPath(buildPath, build, js)
)
)
.distinct
Expand All @@ -564,14 +562,12 @@ object BuildConfig {
module: Module
): List[Path] =
module.moduleDeps
.filter(name => hasTarget(build, name, Platform.Native))
.flatMap(
name =>
buildPath
.resolve(targetName(build, name, Native)) +: collectNativeClassPath(
buildPath,
build,
build(name).module
build(name).module.native.toList.flatMap(
native =>
buildPath.resolve(targetName(build, name, Native)) +:
collectNativeClassPath(buildPath, build, native)
)
)
.distinct
Expand All @@ -582,15 +578,13 @@ object BuildConfig {
module: Module
): List[Path] =
module.moduleDeps
.filter(name => hasTarget(build, name, Platform.JVM))
.flatMap(
name =>
buildPath.resolve(targetName(build, name, JVM)) +:
collectJvmClassPath(
buildPath,
build,
build(name).module
)
build(name).module.jvm.toList.flatMap(
jvm =>
buildPath.resolve(targetName(build, name, JVM)) +:
collectJvmClassPath(buildPath, build, jvm)
)
)
.distinct

Expand Down
32 changes: 32 additions & 0 deletions src/test/scala/seed/generation/BloopIntegrationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,36 @@ object BloopIntegrationSpec extends TestSuite[Unit] {
assert(lines.contains("native"))
}
}

test("Inherit classpath of platform-specific base modules") { _ =>
val result = BuildConfig
.load(Paths.get("test").resolve("platform-module-deps"), Log.urgent)
.get
val buildPath = tempPath.resolve("platform-module-deps-bloop")
Files.createDirectory(buildPath)
cli.Generate.ui(
Config(),
result.projectPath,
buildPath,
result.resolvers,
result.build,
Command.Bloop(packageConfig),
Log.urgent
)

val bloopBuildPath = buildPath.resolve("build").resolve("bloop")

val bloopPath = buildPath.resolve(".bloop")

val root = readBloopJson(bloopPath.resolve("example.json"))
val paths = root.project.classpath.filter(_.startsWith(buildPath))

assertEquals(
paths,
List(
bloopBuildPath.resolve("base"),
bloopBuildPath.resolve("core")
)
)
}
}
2 changes: 1 addition & 1 deletion src/test/scala/seed/generation/IdeaSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ object IdeaSpec extends SimpleTestSuite {
.byTagAll["orderEntry"]
.filter(_.attr("type").contains("module"))
.flatMap(_.attr("module-name"))
assertEquals(moduleNames, List("core"))
assertEquals(moduleNames, List("core", "base"))
}

test("Generate non-JVM cross-platform module") {
Expand Down
9 changes: 7 additions & 2 deletions test/platform-module-deps/build.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[project]
scalaVersion = "2.12.8"

[module.base.jvm]
root = "base"
sources = ["base/src/"]

[module.core.jvm]
root = "jvm"
sources = ["jvm/src/"]
moduleDeps = ["base"]
root = "jvm"
sources = ["jvm/src/"]

[module.example.jvm]
moduleDeps = ["core"]
Expand Down

0 comments on commit cf7e6aa

Please sign in to comment.