-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sbt._ | ||
import sbt.Keys._ | ||
import sbtcrossproject.{CrossPlugin, CrossProject} | ||
import scala.language.implicitConversions | ||
import ProjectKeys.projectName | ||
|
||
object Implicits { | ||
implicit class CrossProjectOps(private val p: CrossProject) extends AnyVal { | ||
def asModuleWithoutSuffix: CrossProject = asModule(true) | ||
|
||
def asModule: CrossProject = asModule(false) | ||
|
||
private def asModule(noSuffix: Boolean): CrossProject = { | ||
val project = p.componentProjects(0) | ||
val s = project.settings(0) | ||
p | ||
.settings( | ||
moduleName := { | ||
if (noSuffix) | ||
(ThisBuild / projectName).value | ||
else | ||
s"${(ThisBuild / projectName).value}-${(project / name).value}" | ||
}, | ||
CrossPlugin.autoImport.crossProjectBaseDirectory := { | ||
val dir = file(s"modules/${(project / name).value}") | ||
IO.resolve((LocalRootProject / baseDirectory).value, dir) | ||
}, | ||
) | ||
.configure(project => | ||
project.in(file("modules") / project.base.getPath), | ||
) | ||
} | ||
} | ||
|
||
implicit def builderOps(b: CrossProject.Builder): CrossProjectOps = | ||
new CrossProjectOps(b.build()) | ||
} |
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,7 @@ | ||
import sbt.settingKey | ||
|
||
object ProjectKeys { | ||
lazy val projectName = settingKey[String]("project name") | ||
lazy val groupId = settingKey[String]("artifact group ID") | ||
lazy val rootPkg = settingKey[String]("root package") | ||
} |