forked from sbt/sbt-assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
55 lines (51 loc) · 2.2 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
lazy val commonSettings: Seq[Setting[_]] = Seq(
version in ThisBuild := "0.14.7-SNAPSHOT",
organization in ThisBuild := "com.eed3si9n"
)
lazy val root = (project in file(".")).
// enablePlugins(GitVersioning).
settings(commonSettings: _*).
settings(
sbtPlugin := true,
name := "sbt-assembly",
description := "sbt plugin to create a single fat jar",
licenses := Seq("MIT License" -> url("https://github.com/sbt/sbt-assembly/blob/master/LICENSE")),
scalacOptions := Seq("-deprecation", "-unchecked", "-Dscalac.patmat.analysisBudget=1024"),
libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.0.1",
"org.pantsbuild" % "jarjar" % "1.6.5"
),
TaskKey[Unit]("runScriptedTest") := Def.taskDyn {
val sbtBinVersion = (sbtBinaryVersion in pluginCrossBuild).value
val base = sbtTestDirectory.value
def isCompatible(directory: File): Boolean = {
val buildProps = new java.util.Properties()
IO.load(buildProps, directory / "project" / "build.properties")
Option(buildProps.getProperty("sbt.version"))
.map { version =>
val requiredBinVersion = CrossVersion.binarySbtVersion(version)
val compatible = requiredBinVersion == sbtBinVersion
if (!compatible) {
val testName = directory.relativeTo(base).getOrElse(directory)
streams.value.log.warn(s"Skipping $testName since it requires sbt $requiredBinVersion")
}
compatible
}
.getOrElse(true)
}
val testDirectoryFinder = base * AllPassFilter * AllPassFilter filter { _.isDirectory }
val tests = for {
test <- testDirectoryFinder.get
if isCompatible(test)
path <- Path.relativeTo(base)(test)
} yield path.replace('\\', '/')
if (tests.nonEmpty)
Def.task(scripted.toTask(tests.mkString(" ", " ", "")).value)
else
Def.task(streams.value.log.warn("No tests can be run for this sbt version"))
}.value,
publishArtifact in (Compile, packageBin) := true,
publishArtifact in (Test, packageBin) := false,
publishArtifact in (Compile, packageDoc) := false,
publishArtifact in (Compile, packageSrc) := true
)