-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathbuild.sbt
More file actions
192 lines (186 loc) · 7.01 KB
/
build.sbt
File metadata and controls
192 lines (186 loc) · 7.01 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
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 := (if (isSnapshot.value) None else localStaging.value),
scalacOptions ++= Seq("-deprecation"),
scalacOptions ++= {
scalaBinaryVersion.value match {
case "3" =>
Nil
case _ =>
Seq("-language:_", "-Xlint", "-Xfuture")
}
},
)
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"plugin2_12/scripted ; plugin3/scripted "),
setReleaseVersion,
releaseStepTask(updateLaunchconfig),
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining(s";publishSigned; plugin2_12/publishSigned; plugin3/publishSigned"),
releaseStepCommandAndRemaining("sonaRelease"),
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")),
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"), "git@github.com: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.8.2",
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 = (projectMatrix in file("sbt-conscript"))
.jvmPlatform(scalaVersions = Seq("3.7.2", "2.12.21"))
.enablePlugins(SbtPlugin)
.settings(
commonSettings,
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
case "2.12" =>
"1.2.8"
case _ =>
"2.0.0-RC8"
}
},
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)
)