Skip to content

Commit

Permalink
Merge pull request #252 from armanbilge/feature/source-related-settings
Browse files Browse the repository at this point in the history
Useful source-related settings
  • Loading branch information
armanbilge authored Apr 11, 2022
2 parents c34dda6 + 9adadb6 commit ce5ff67
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions settings/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "1.2.0")
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.typesafe.sbt.GitPlugin
import com.typesafe.sbt.SbtGit.git
import org.typelevel.sbt.kernel.V
import org.typelevel.sbt.kernel.GitHelper
import sbtcrossproject.CrossPlugin.autoImport._
import sbtcrossproject.CrossType

object TypelevelSettingsPlugin extends AutoPlugin {
override def trigger = allRequirements
Expand Down Expand Up @@ -235,6 +237,31 @@ object TypelevelSettingsPlugin extends AutoPlugin {
},
javacOptions ++= {
withJdkRelease(tlJdkRelease.value)(Seq.empty[String])(n => Seq("--release", n.toString))
},
unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
if (crossProjectPlatform.?.value.isDefined)
List(CrossType.Pure, CrossType.Full).flatMap {
_.sharedSrcDir(baseDirectory.value, Defaults.nameForSrc(configuration.value.name))
.toList
.map(f => file(f.getPath + suffix))
}
else
List(
baseDirectory.value / "src" / Defaults.nameForSrc(
configuration.value.name) / s"scala$suffix"
)

CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) if y <= 12 => extraDirs("-2.12-")
case Some((2, y)) if y >= 13 => extraDirs("-2.13+")
case Some((3, _)) => extraDirs("-2.13+")
case _ => Nil
}
},
packageSrc / mappings ++= {
val base = sourceManaged.value
managedSources.value.map(file => file -> file.relativeTo(base).get.getPath)
}
)

Expand Down

0 comments on commit ce5ff67

Please sign in to comment.