Skip to content

Commit

Permalink
Merge pull request #156 from armanbilge/fix/cross-project-base-dir
Browse files Browse the repository at this point in the history
Fix `crossProjectBaseDirectory`
  • Loading branch information
sjrd authored Apr 17, 2023
2 parents a07d717 + 4972b7c commit c030519
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
27 changes: 26 additions & 1 deletion sbt-crossproject-test/src/sbt-test/new-api/detection/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def doCheckType(got: CrossType, expected: CrossType) =
assert(got == expected)

def doCheckBase(got: File, expected: File) =
assert(got == expected)
assert(got == expected.getAbsoluteFile)

lazy val root =
crossProject(JVMPlatform, NativePlatform, JSPlatform)
Expand Down Expand Up @@ -64,3 +64,28 @@ lazy val fullCross =
doCheckBase(crossProjectBaseDirectory.value, file("fullCross"))
}
)

lazy val nonDefaultBase =
crossProject(JVMPlatform, NativePlatform, JSPlatform)
.in(file("non-default-base"))
.jvmSettings(
check := {
doCheckPlatform(crossProjectPlatform.value, "jvm")
doCheckType(crossProjectCrossType.value, CrossType.Full)
doCheckBase(crossProjectBaseDirectory.value, file("non-default-base"))
}
)
.jsSettings(
check := {
doCheckPlatform(crossProjectPlatform.value, "js")
doCheckType(crossProjectCrossType.value, CrossType.Full)
doCheckBase(crossProjectBaseDirectory.value, file("non-default-base"))
}
)
.nativeSettings(
check := {
doCheckPlatform(crossProjectPlatform.value, "native")
doCheckType(crossProjectCrossType.value, CrossType.Full)
doCheckBase(crossProjectBaseDirectory.value, file("non-default-base"))
}
)
3 changes: 3 additions & 0 deletions sbt-crossproject-test/src/sbt-test/new-api/detection/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
> fullCrossJVM/check
> fullCrossJS/check
> fullCrossNative/check
> nonDefaultBaseJVM/check
> nonDefaultBaseJS/check
> nonDefaultBaseNative/check
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ final class CrossProject private[sbtcrossproject] (
configurePlatforms(platforms: _*)(_.enablePlugins(plugins: _*))

def in(dir: File): CrossProject =
mapProjectsByPlatform(
(platform, project) => project.in(crossType.platformDir(dir, platform)))
settings(
CrossPlugin.autoImport.crossProjectBaseDirectory :=
IO.resolve((LocalRootProject / baseDirectory).value, dir)
).mapProjectsByPlatform { (platform, project) =>
project.in(crossType.platformDir(dir, platform))
}

def overrideConfigs(cs: Configuration*): CrossProject =
transform(_.overrideConfigs(cs: _*))
Expand Down Expand Up @@ -205,7 +209,8 @@ object CrossProject {
).settings(
CrossPlugin.autoImport.crossProjectPlatform := platform,
CrossPlugin.autoImport.crossProjectCrossType := crossType,
CrossPlugin.autoImport.crossProjectBaseDirectory := base,
CrossPlugin.autoImport.crossProjectBaseDirectory :=
IO.resolve((LocalRootProject / baseDirectory).value, base),
name := id, // #80
sharedSrc(platform),
sharedResources(platform)
Expand Down

0 comments on commit c030519

Please sign in to comment.