Skip to content

Commit 8a41213

Browse files
pvlugterbantonsson
authored andcommitted
Add cross build for sbt 1.0
1 parent c6ff62e commit 8a41213

File tree

34 files changed

+161
-40
lines changed

34 files changed

+161
-40
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
language: scala
2-
3-
scala:
4-
- 2.10.6
2+
jdk: oraclejdk8
3+
script: sbt "^ scripted"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2016 Lightbend Inc. [https://www.lightbend.com]
1+
Copyright 2016-2017 Lightbend Inc. [https://www.lightbend.com]
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

build.sbt

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2016 Lightbend, Inc. <http://www.lightbend.com>
2+
* Copyright © 2016-2017 Lightbend, Inc. <http://www.lightbend.com>
33
*/
44

55
lazy val `sbt-javaagent` = project in file(".")
@@ -9,15 +9,24 @@ sbtPlugin := true
99
name := "sbt-javaagent"
1010
organization := "com.lightbend.sbt"
1111

12+
// sbt cross build
13+
crossSbtVersions := Seq("0.13.16", "1.0.0-RC3")
14+
15+
// fixed in https://github.com/sbt/sbt/pull/3397 (for sbt 0.13.17)
16+
sbtBinaryVersion in update := (sbtBinaryVersion in pluginCrossBuild).value
17+
1218
// dependencies
13-
val packagerVersion = "1.0.6"
14-
val packager11xVersion = "1.1.5"
15-
val packager12xVersion = "1.2.0"
19+
val packagerVersion = "1.2.2-RC2" // with sbt 1.0 cross build
20+
val packager10xVersion = "1.0.6"
21+
val packager11xVersion = "1.1.6"
22+
val packager12xVersion = "1.2.1"
1623
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % packagerVersion % "provided")
1724

1825
// compile settings
19-
scalacOptions ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-unchecked", "-deprecation", "-feature")
20-
javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6")
26+
scalacOptions ++= Seq("-encoding", "UTF-8", "-unchecked", "-deprecation", "-feature") ++
27+
{ if ((sbtBinaryVersion in pluginCrossBuild).value == "0.13") Seq("-target:jvm-1.6") else Seq.empty }
28+
javacOptions ++= Seq("-encoding", "UTF-8") ++
29+
{ if ((sbtBinaryVersion in pluginCrossBuild).value == "0.13") Seq("-source", "1.6", "-target", "1.6") else Seq.empty }
2130

2231
// test agent
2332
lazy val maxwell = project
@@ -36,6 +45,7 @@ scriptedSettings
3645
scriptedLaunchOpts ++= Seq(
3746
"-Dproject.version=" + version.value,
3847
"-Dpackager.version=" + packagerVersion,
48+
"-Dpackager.10x.version=" + packager10xVersion,
3949
"-Dpackager.11x.version=" + packager11xVersion,
4050
"-Dpackager.12x.version=" + packager12xVersion
4151
)
@@ -48,10 +58,50 @@ test in Test := {
4858
ScriptedPlugin.scripted.toTask("").value
4959
}
5060

61+
// cross-sbt scripted tests
62+
resourceDirectory in scriptedTests := sourceDirectory.value / "sbt-test"
63+
resourceDirectories in scriptedTests := Seq((resourceDirectory in scriptedTests).value)
64+
resourceDirectories in scriptedTests += sourceDirectory.value / ("sbt-test-" + (sbtBinaryVersion in pluginCrossBuild).value)
65+
includeFilter in scriptedTests := AllPassFilter
66+
excludeFilter in scriptedTests := HiddenFileFilter
67+
resources in scriptedTests := Defaults.collectFiles(resourceDirectories in scriptedTests, includeFilter in scriptedTests, excludeFilter in scriptedTests).value
68+
target in scriptedTests := crossTarget.value / "sbt-test"
69+
copyResources in scriptedTests := {
70+
val testResources = (resources in scriptedTests).value
71+
val testDirectories = (resourceDirectories in scriptedTests).value
72+
val testTarget = (target in scriptedTests).value
73+
val cacheFile = streams.value.cacheDirectory / "copy-sbt-test"
74+
val mappings = (testResources --- testDirectories) pair (rebase(testDirectories, testTarget) | flat(testTarget))
75+
Sync(cacheFile)(mappings)
76+
mappings
77+
}
78+
sbtTestDirectory := (target in scriptedTests).value
79+
scriptedDependencies := {
80+
scriptedDependencies.value
81+
(copyResources in scriptedTests).value
82+
}
83+
5184
// publish settings
5285
publishMavenStyle := false
5386
bintrayOrganization := Some("sbt")
5487
bintrayRepository := "sbt-plugin-releases"
5588
bintrayPackage := "sbt-javaagent"
5689
bintrayReleaseOnPublish := false
5790
licenses += "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")
91+
92+
// release settings
93+
import ReleaseTransformations._
94+
releaseProcess := Seq[ReleaseStep](
95+
checkSnapshotDependencies,
96+
inquireVersions,
97+
runClean,
98+
releaseStepCommandAndRemaining("^ scripted"),
99+
setReleaseVersion,
100+
commitReleaseVersion,
101+
tagRelease,
102+
releaseStepCommandAndRemaining("^ publish"),
103+
releaseStepTask(bintrayRelease),
104+
setNextVersion,
105+
commitNextVersion,
106+
pushChanges
107+
)

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.11
1+
sbt.version=0.13.16

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright © 2016 Lightbend, Inc. <http://www.lightbend.com>
2+
* Copyright © 2016-2017 Lightbend, Inc. <http://www.lightbend.com>
33
*/
44

5-
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3")
5+
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6")
66
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
77

88
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright © 2016-2017 Lightbend, Inc. <http://www.lightbend.com>
3+
*/
4+
5+
package com.lightbend.sbt.javaagent
6+
7+
import sbt.{ ModuleFilter, ModuleID }
8+
9+
object Modules {
10+
def withConfigurations(module: ModuleID, configurations: Option[String]): ModuleID =
11+
module.copy(configurations = configurations)
12+
13+
def exactFilter(module: ModuleID) = new ModuleFilter {
14+
def apply(m: ModuleID) = {
15+
m.organization == module.organization &&
16+
m.name == module.name &&
17+
m.revision == module.revision
18+
}
19+
}
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright © 2016-2017 Lightbend, Inc. <http://www.lightbend.com>
3+
*/
4+
5+
package com.lightbend.sbt.javaagent
6+
7+
import sbt.ModuleID
8+
import sbt.librarymanagement.ModuleFilter
9+
10+
object Modules {
11+
def withConfigurations(module: ModuleID, configurations: Option[String]): ModuleID =
12+
module.withConfigurations(configurations)
13+
14+
def exactFilter(module: ModuleID) = new ModuleFilter {
15+
def apply(m: ModuleID) = {
16+
m.organization == module.organization &&
17+
m.name == module.name &&
18+
m.revision == module.revision
19+
}
20+
}
21+
}

src/main/scala/com/lightbend/sbt/javaagent/JavaAgent.scala

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2016 Lightbend, Inc. <http://www.lightbend.com>
2+
* Copyright © 2016-2017 Lightbend, Inc. <http://www.lightbend.com>
33
*/
44

55
package com.lightbend.sbt.javaagent
@@ -49,7 +49,7 @@ object JavaAgent extends AutoPlugin {
4949
val inTest = scope.test || confs.contains(Test.name)
5050
val inDist = scope.dist
5151
val configuration = if (inCompile) Provided else AgentConfig
52-
val reconfiguredModule = module.copy(configurations = Some(configuration.name))
52+
val reconfiguredModule = Modules.withConfigurations(module, Some(configuration.name))
5353
val configuredScope = AgentScope(compile = inCompile, test = inTest, run = inRun, dist = inDist)
5454
AgentModule(agentName, reconfiguredModule, configuredScope, agentArguments)
5555
}
@@ -70,20 +70,12 @@ object JavaAgent extends AutoPlugin {
7070

7171
private def resolveAgents = Def.task[Seq[ResolvedAgent]] {
7272
javaAgents.value flatMap { agent =>
73-
update.value.matching(exactModuleFilter(agent.module)).headOption map {
73+
update.value.matching(Modules.exactFilter(agent.module)).headOption map {
7474
jar => ResolvedAgent(agent, jar)
7575
}
7676
}
7777
}
7878

79-
private def exactModuleFilter(module: ModuleID) = new ModuleFilter {
80-
def apply(m: ModuleID) = {
81-
m.organization == module.organization &&
82-
m.name == module.name &&
83-
m.revision == module.revision
84-
}
85-
}
86-
8779
private def enableFork(forkKey: SettingKey[Boolean], enabled: AgentModule => Boolean) = Def.setting[Boolean] {
8880
forkKey.value || javaAgents.value.exists(enabled)
8981
}

src/main/scala/com/lightbend/sbt/javaagent/JavaAgentPackaging.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2016 Lightbend, Inc. <http://www.lightbend.com>
2+
* Copyright © 2016-2017 Lightbend, Inc. <http://www.lightbend.com>
33
*/
44

55
package com.lightbend.sbt.javaagent

0 commit comments

Comments
 (0)