-
Notifications
You must be signed in to change notification settings - Fork 65
/
build.sbt
177 lines (171 loc) · 6.68 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import Dependencies._
import ReleaseTransformations._
import scala.sys.process.Process
val updateLaunchconfig = TaskKey[File]("updateLaunchconfig")
def buildInfo(packageName: String, v: String) = Def.settings(
Compile / sourceGenerators += task {
val src = s"""package ${packageName}
|
|private[${packageName}] object ConscriptBuildInfo {
| def sbtLauncherVersion: String = "${v}"
|}
|""".stripMargin
val f = (Compile / sourceManaged).value / "conscript" / "ConscriptBuildInfo.scala"
IO.write(f, src)
Seq(f)
},
)
lazy val commonSettings = Seq(
publishTo := sonatypePublishToBundle.value,
sonatypeProfileName := "org.foundweekends",
crossSbtVersions := Seq("1.2.8")
)
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin, SbtProguard).
settings(
commonSettings,
buildInfo(packageName = "conscript", v = sbtLauncherDeps.revision),
libraryDependencies += sbtLauncherDeps,
pomPostProcess := { node =>
import scala.xml.{NodeSeq, Node}
val rule = new scala.xml.transform.RewriteRule {
override def transform(n: Node) = {
if (List(
n.label == "dependency",
(n \ "groupId").text == sbtLauncherDeps.organization,
(n \ "artifactId").text == sbtLauncherDeps.name,
).forall(identity)) {
NodeSeq.Empty
} else {
n
}
}
}
new scala.xml.transform.RuleTransformer(rule).transform(node)(0)
},
updateLaunchconfig := {
val mainClassName = (Compile / discoveredMainClasses).value match {
case Seq(m) => m
case zeroOrMulti => sys.error(s"could not found main class. $zeroOrMulti")
}
val s = streams.value.log
if(isSnapshot.value) {
s.warn(s"update launchconfig ${version.value}")
}
val launchconfig = s"""[app]
| version: ${version.value}
| org: ${organization.value}
| name: ${normalizedName.value}
| class: ${mainClassName}
|[scala]
| version: ${scalaVersion.value}
|[repositories]
| local
| maven-central
|""".stripMargin
val f = (ThisBuild / baseDirectory).value / "src/main/conscript/cs/launchconfig"
IO.write(f, launchconfig)
Process(Seq("git", "add", f.getAbsolutePath), (LocalRootProject / baseDirectory).value).!
Process(Seq("git", "commit", "-m", "update " + f.getName), (LocalRootProject / baseDirectory).value).!
f
},
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
releaseStepCommandAndRemaining(s"^ plugin/scripted"),
setReleaseVersion,
releaseStepTask(updateLaunchconfig),
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining(s";publishSigned;^ plugin/publishSigned"),
releaseStepCommandAndRemaining("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
),
scalaVersion := "2.11.12",
inThisBuild(List(
organization := "org.foundweekends.conscript",
homepage := Some(url("https://github.com/foundweekends/conscript/")),
licenses := Seq("LGPL-3.0" -> url("https://www.gnu.org/licenses/lgpl.txt")),
scalacOptions ++= Seq("-language:_", "-deprecation", "-Xlint", "-Xfuture"),
developers := List(
Developer("n8han", "Nathan Hamblen", "@n8han", url("https://github.com/n8han")),
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n"))
),
scmInfo := Some(ScmInfo(url("https://github.com/foundweekends/conscript"), "[email protected]:foundweekends/conscript.git"))
)),
name := "conscript",
crossScalaVersions := List("2.11.12"),
libraryDependencies ++= List(launcherInterface, scalaSwing, dispatchCore, scopt, liftJson, slf4jJdk14),
Compile / packageBin / mainClass := Some("conscript.Conscript"),
(Compile / packageBin / mappings) := {
val old = (Compile / packageBin / mappings).value
old filter { case (_, p) => p != "META-INF/MANIFEST.MF" }
},
(Compile / packageSrc / mappings) := {
val old = (Compile / packageSrc / mappings).value
old filter { case (_, p) => p != "META-INF/MANIFEST.MF" }
},
Proguard / proguardVersion := "7.6.1",
Proguard / proguardOptions ++= Seq(
"-keep class conscript.* { *; }",
"-keep class dispatch.* { *; }",
"-keep class com.ning.http.util.** { *; }",
"-keep class com.ning.http.client.providers.netty.** { *; }",
"-keep class org.apache.commons.logging.impl.LogFactoryImpl { *; }",
"-keep class org.apache.commons.logging.impl.Jdk14Logger { *; }",
"-dontnote",
"-dontwarn",
"-dontobfuscate",
"-dontoptimize"
),
(Proguard / proguardInputs) := {
((Compile / fullClasspath).value.files ++ (Runtime / fullClasspath).value.files).distinct.filter { f =>
// This is a dependency of the launcher interface. It may not be the version of scala
// we're using at all, and we don't want it
f.getName != "scala-library.jar"
}
},
Proguard / proguardDefaultInputFilter := None,
Proguard / proguard / javaOptions := Seq("-Xmx2G"),
(Proguard / proguardOutputs) := {
(Proguard / proguardDirectory).value / ("conscript-" + version.value + ".jar") :: Nil
},
(Compile / proguard / artifact) := {
val art = (Compile / proguard / artifact).value
art.withClassifier(Some("proguard"))
},
addArtifact((Compile / proguard / artifact), (Proguard / proguard) map { xs => xs.head }),
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion),
buildInfoPackage := "conscript",
publishMavenStyle := true,
Test / publishArtifact := false,
TaskKey[Unit]("makeSite") := {
val output = target.value / "site"
IO.delete(output)
val src = (LocalRootProject / baseDirectory).value / "docs"
val storage = pamflet.FileStorage(src, Nil)
pamflet.Produce(storage.globalized, output)
IO.delete(output / "offline")
IO.delete(output / "ja" / "offline")
},
)
lazy val javaVmArgs: List[String] = {
import scala.collection.JavaConverters._
java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments.asScala.toList
}
lazy val plugin = (project in file("sbt-conscript")).
enablePlugins(SbtPlugin).
settings(
commonSettings,
buildInfo(packageName = "sbtconscript", v = Dependencies.launcherInterface.revision),
name := "sbt-conscript",
scriptedBufferLog := false,
scriptedLaunchOpts ++= javaVmArgs.filter(
a => Seq("-Xmx", "-Xms", "-XX", "-Dsbt.log.noformat").exists(a.startsWith)
),
scriptedLaunchOpts += ("-Dplugin.version=" + version.value)
)