mirror of https://github.com/sbt/sbt.git
Clean-up build
This commit is contained in:
parent
3b81a4ad5e
commit
a3abe32525
25
build.sbt
25
build.sbt
|
|
@ -29,7 +29,7 @@ lazy val `sbt-shared` = project
|
|||
// because we don't publish for 2.11 the following declaration
|
||||
// is more wordy than usual
|
||||
// once support for sbt 0.13 is removed, this dependency can go away
|
||||
libs ++= {
|
||||
libraryDependencies ++= {
|
||||
val dependency = "com.dwijnand" % "sbt-compat" % "1.2.6"
|
||||
val sbtV = (sbtBinaryVersion in pluginCrossBuild).value
|
||||
val scalaV = (scalaBinaryVersion in update).value
|
||||
|
|
@ -43,10 +43,12 @@ lazy val `sbt-shared` = project
|
|||
|
||||
lazy val `sbt-coursier` = project
|
||||
.in(file("modules/sbt-coursier"))
|
||||
.enablePlugins(ScriptedPlugin)
|
||||
.dependsOn(`sbt-shared`)
|
||||
.settings(
|
||||
plugin,
|
||||
utest,
|
||||
libraryDependencies += "com.lihaoyi" %% "utest" % "0.6.4" % Test,
|
||||
testFrameworks += new TestFramework("utest.runner.Framework"),
|
||||
libraryDependencies ++= Seq(
|
||||
"io.get-coursier" %% "coursier" % coursierVersion,
|
||||
"io.get-coursier" %% "coursier-cache" % coursierVersion,
|
||||
|
|
@ -64,10 +66,16 @@ lazy val `sbt-coursier` = project
|
|||
|
||||
lazy val `sbt-pgp-coursier` = project
|
||||
.in(file("modules/sbt-pgp-coursier"))
|
||||
.enablePlugins(ScriptedPlugin)
|
||||
.dependsOn(`sbt-coursier`)
|
||||
.settings(
|
||||
plugin,
|
||||
libs += Deps.sbtPgp.value,
|
||||
libraryDependencies += {
|
||||
val sbtv = CrossVersion.binarySbtVersion(sbtVersion.in(pluginCrossBuild).value)
|
||||
val sv = scalaBinaryVersion.value
|
||||
val ver = "1.1.1"
|
||||
Defaults.sbtPluginExtra("com.jsuereth" % "sbt-pgp" % ver, sbtv, sv)
|
||||
},
|
||||
scriptedDependencies := {
|
||||
scriptedDependencies.value
|
||||
// TODO Get dependency projects automatically
|
||||
|
|
@ -77,14 +85,19 @@ lazy val `sbt-pgp-coursier` = project
|
|||
|
||||
lazy val `sbt-shading` = project
|
||||
.in(file("modules/sbt-shading"))
|
||||
.enablePlugins(ShadingPlugin)
|
||||
.enablePlugins(ScriptedPlugin, ShadingPlugin)
|
||||
.dependsOn(`sbt-coursier`)
|
||||
.settings(
|
||||
plugin,
|
||||
shading,
|
||||
libs += Deps.jarjar % "shaded",
|
||||
libraryDependencies += "io.get-coursier.jarjar" % "jarjar-core" % "1.0.1-coursier-1" % "shaded",
|
||||
// dependencies of jarjar-core - directly depending on these so that they don't get shaded
|
||||
libs ++= Deps.jarjarTransitiveDeps,
|
||||
libraryDependencies ++= Seq(
|
||||
"com.google.code.findbugs" % "jsr305" % "2.0.2",
|
||||
"org.ow2.asm" % "asm-commons" % "5.2",
|
||||
"org.ow2.asm" % "asm-util" % "5.2",
|
||||
"org.slf4j" % "slf4j-api" % "1.7.25"
|
||||
),
|
||||
scriptedDependencies := {
|
||||
scriptedDependencies.value
|
||||
// TODO Get dependency projects automatically
|
||||
|
|
|
|||
|
|
@ -7,36 +7,12 @@ import sbt.librarymanagement.CrossVersion.partialVersion
|
|||
|
||||
object Aliases {
|
||||
|
||||
def libs = libraryDependencies
|
||||
|
||||
def withScriptedTests: Seq[Def.Setting[_]] =
|
||||
ScriptedPlugin.globalSettings ++ ScriptedPlugin.projectSettings.filterNot(_.key.key.label == libraryDependencies.key.label) ++ Seq(
|
||||
libraryDependencies ++= {
|
||||
scalaBinaryVersion.value match {
|
||||
case "2.12" =>
|
||||
partialVersion(scriptedSbt.value) match {
|
||||
case Some((1, _)) =>
|
||||
Seq(
|
||||
"org.scala-sbt" %% "scripted-sbt" % scriptedSbt.value % ScriptedConf,
|
||||
"org.scala-sbt" % "sbt-launch" % scriptedSbt.value % ScriptedLaunchConf
|
||||
)
|
||||
case other =>
|
||||
sys.error(s"Unrecognized sbt partial version: $other")
|
||||
}
|
||||
case _ =>
|
||||
Seq()
|
||||
}
|
||||
}
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scala-sbt" %% "scripted-sbt" % scriptedSbt.value % ScriptedConf,
|
||||
"org.scala-sbt" % "sbt-launch" % scriptedSbt.value % ScriptedLaunchConf
|
||||
)
|
||||
)
|
||||
|
||||
def hasITs = itSettings
|
||||
|
||||
def ShadingPlugin = coursier.ShadingPlugin
|
||||
|
||||
|
||||
implicit class ProjectOps(val proj: Project) extends AnyVal {
|
||||
def dummy: Project =
|
||||
proj.in(file(s"target/${proj.id}"))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
import sbt._
|
||||
import sbt.Defaults.sbtPluginExtra
|
||||
import sbt.Keys._
|
||||
|
||||
object Deps {
|
||||
|
||||
def sbtPgp = Def.setting {
|
||||
val sbtv = CrossVersion.binarySbtVersion(sbtVersion.in(pluginCrossBuild).value)
|
||||
val sv = scalaBinaryVersion.value
|
||||
val ver = "1.1.1"
|
||||
sbtPluginExtra("com.jsuereth" % "sbt-pgp" % ver, sbtv, sv)
|
||||
}
|
||||
|
||||
def jarjar = "io.get-coursier.jarjar" % "jarjar-core" % "1.0.1-coursier-1"
|
||||
|
||||
def jarjarTransitiveDeps = Seq(
|
||||
"com.google.code.findbugs" % "jsr305" % "2.0.2",
|
||||
"org.ow2.asm" % "asm-commons" % "5.2",
|
||||
"org.ow2.asm" % "asm-util" % "5.2",
|
||||
"org.slf4j" % "slf4j-api" % "1.7.25"
|
||||
)
|
||||
|
||||
def utest = "com.lihaoyi" %% "utest" % "0.6.4"
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
import java.io.{ByteArrayOutputStream, InputStream}
|
||||
import java.net.{HttpURLConnection, URL, URLConnection}
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
import sbt.Logger
|
||||
|
||||
object HttpUtil {
|
||||
|
||||
private def readFully(is: InputStream): Array[Byte] = {
|
||||
val buffer = new ByteArrayOutputStream
|
||||
val data = Array.ofDim[Byte](16384)
|
||||
|
||||
var nRead = 0
|
||||
while ({
|
||||
nRead = is.read(data, 0, data.length)
|
||||
nRead != -1
|
||||
})
|
||||
buffer.write(data, 0, nRead)
|
||||
|
||||
buffer.flush()
|
||||
buffer.toByteArray
|
||||
}
|
||||
|
||||
def fetch(url: String, log: Logger, extraHeaders: Seq[(String, String)] = Nil): String = {
|
||||
|
||||
val url0 = new URL(url)
|
||||
|
||||
log.info(s"Fetching $url")
|
||||
|
||||
val (rawResp, code) = {
|
||||
|
||||
var conn: URLConnection = null
|
||||
var httpConn: HttpURLConnection = null
|
||||
var is: InputStream = null
|
||||
|
||||
try {
|
||||
conn = url0.openConnection()
|
||||
httpConn = conn.asInstanceOf[HttpURLConnection]
|
||||
for ((k, v) <- extraHeaders)
|
||||
httpConn.setRequestProperty(k, v)
|
||||
is = conn.getInputStream
|
||||
|
||||
(readFully(is), httpConn.getResponseCode)
|
||||
} finally {
|
||||
if (is != null)
|
||||
is.close()
|
||||
if (httpConn != null) {
|
||||
scala.util.Try(httpConn.getInputStream).filter(_ != null).foreach(_.close())
|
||||
scala.util.Try(httpConn.getErrorStream).filter(_ != null).foreach(_.close())
|
||||
httpConn.disconnect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (code / 100 != 2)
|
||||
sys.error(s"Unexpected response code when getting $url: $code")
|
||||
|
||||
new String(rawResp, StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
|
||||
import com.typesafe.tools.mima.plugin.MimaKeys._
|
||||
|
||||
object Mima {
|
||||
|
||||
// Important: the line with the "binary compatibility versions" comment below is matched during releases
|
||||
def binaryCompatibilityVersions = Set(
|
||||
"" // binary compatibility versions
|
||||
)
|
||||
|
||||
|
||||
lazy val previousArtifacts = Seq(
|
||||
mimaPreviousArtifacts := {
|
||||
binaryCompatibilityVersions.collect {
|
||||
case ver if ver.nonEmpty =>
|
||||
organization.value %% moduleName.value % ver
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
import java.nio.file.Files
|
||||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import sbt.ScriptedPlugin.autoImport.{sbtLauncher, scriptedBufferLog, ScriptedLaunchConf, scriptedLaunchOpts}
|
||||
import sbt.ScriptedPlugin.autoImport.{scriptedBufferLog, scriptedLaunchOpts}
|
||||
|
||||
import com.typesafe.sbt.pgp._
|
||||
import coursier.ShadingPlugin.autoImport._
|
||||
import coursier.ShadingPlugin.autoImport.{Shading, shadingNamespace}
|
||||
|
||||
import Aliases._
|
||||
|
||||
|
|
@ -14,38 +12,22 @@ object Settings {
|
|||
|
||||
def scala212 = "2.12.7"
|
||||
|
||||
def sonatypeRepository(name: String) = {
|
||||
resolvers += Resolver.sonatypeRepo(name)
|
||||
}
|
||||
def sbt10Version = "1.0.2"
|
||||
|
||||
lazy val shared = Seq(
|
||||
sonatypeRepository("releases"),
|
||||
resolvers += Resolver.sonatypeRepo("releases"),
|
||||
crossScalaVersions := Seq(scala212),
|
||||
scalaVersion := scala212,
|
||||
scalacOptions ++= Seq(
|
||||
"-target:jvm-1.8",
|
||||
"-feature",
|
||||
"-deprecation",
|
||||
"-language:higherKinds",
|
||||
"-language:implicitConversions"
|
||||
),
|
||||
javacOptions ++= Seq(
|
||||
"-source", "1.8",
|
||||
"-target", "1.8"
|
||||
),
|
||||
javacOptions.in(Keys.doc) := Seq()
|
||||
)
|
||||
)
|
||||
|
||||
lazy val utest = Seq(
|
||||
libs += Deps.utest % Test,
|
||||
testFrameworks += new TestFramework("utest.runner.Framework")
|
||||
)
|
||||
|
||||
def sbt10Version = "1.0.2"
|
||||
|
||||
lazy val plugin =
|
||||
shared ++
|
||||
withScriptedTests ++
|
||||
Seq(
|
||||
scriptedLaunchOpts ++= Seq(
|
||||
"-Xmx1024M",
|
||||
|
|
@ -58,10 +40,10 @@ object Settings {
|
|||
)
|
||||
|
||||
lazy val shading =
|
||||
inConfig(_root_.coursier.ShadingPlugin.Shading)(PgpSettings.projectSettings) ++
|
||||
inConfig(Shading)(PgpSettings.projectSettings) ++
|
||||
// Why does this have to be repeated here?
|
||||
// Can't figure out why configuration gets lost without this in particular...
|
||||
_root_.coursier.ShadingPlugin.projectSettings ++
|
||||
coursier.ShadingPlugin.projectSettings ++
|
||||
Seq(
|
||||
shadingNamespace := "coursier.shaded",
|
||||
publish := publish.in(Shading).value,
|
||||
|
|
|
|||
Loading…
Reference in New Issue