Skip to content

Commit 288e6e7

Browse files
authored
Merge pull request #5 from scala/2.11.x
2.11.x
2 parents 394b0c5 + 81a67ee commit 288e6e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1925
-444
lines changed

CONTRIBUTING.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In 2014, you -- the Scala community -- matched the core team at EPFL in number o
88

99
We are super happy about this, and are eager to make your experience contributing to Scala productive and satisfying, so that we can keep up this growth. We can't do this alone (nor do we want to)!
1010

11-
This is why we're collecting these notes on how to contribute, and we hope you'll share your experience to improve the process for the next contributor! (Feel free to send a PR for this note, send your thoughts to scala-internals, or tweet about it to @adriaanm.)
11+
This is why we're collecting these notes on how to contribute, and we hope you'll share your experience to improve the process for the next contributor! (Feel free to send a PR for this note, send your thoughts to gitter, scala-internals, or tweet about it to @adriaanm.)
1212

1313
By the way, the team at Lightbend is: @adriaanm, @lrytz, @retronym, @SethTisue, and @szeiger.
1414

@@ -117,14 +117,32 @@ See the [scala-jenkins-infra repo](https://github.com/scala/scala-jenkins-infra)
117117

118118
### Pass code review
119119

120-
Your PR will need to be assigned to one or more reviewers. You can suggest reviewers yourself; if you're not sure, see the list in [README.md](README.md) or ask on scala-internals.
120+
Your PR will need to be assigned to one or more reviewers. You can suggest reviewers
121+
yourself; if you're not sure, see the list in [README.md](README.md) or ask on gitter
122+
or scala-internals.
121123

122-
To assign a reviewer, add a "review by @reviewer" to your PR description.
124+
To assign a reviewer, add a "review by @reviewer" to the PR description or in a
125+
comment on your PR.
123126

124127
NOTE: it's best not to @mention in commit messages, as github pings you every time a commit with your @name on it shuffles through the system (even in other repos, on merges,...).
125128

126129
A reviewer gives the green light by commenting "LGTM" (looks good to me).
127130

128-
A review feedback may be addressed by pushing new commits to the request, if these commits stand on their own.
131+
When including review feedback, we typically amend the changes into the existing commit(s)
132+
and `push -f` to the branch. This is to keep the git history clean. Additional commits
133+
are OK if they stand on their own.
129134

130-
Once all these conditions are met, and we agree with the change (we are available on scala-internals to discuss this beforehand, before you put in the coding work!), we will merge your changes.
135+
Once all these conditions are met, and we agree with the change (we are available on
136+
gitter or scala-internals to discuss this beforehand, before you put in the coding work!),
137+
we will merge your changes.
138+
139+
We use the following labels:
140+
141+
Label | Description
142+
-------------------------|:-----------
143+
`reviewed` | automatically added by scabot when a comment prefixed with LGTM is posted
144+
`welcome` | added by reviewer / queue curator to welcome someone's first PR (for highlighting in the release notes)
145+
`release-notes` | added by reviewer / queue curator to make sure this PR is highlighted in the release notes
146+
`on-hold` | added when this PR should not yet be merged, even though CI is green
147+
`WIP` | added by the author if a PR is submitted for CI testing, needs more work to be complete
148+
`assistance-appreciated` | added by the author if help by the community is appreciated to move a change forward

README.md

Lines changed: 216 additions & 164 deletions
Large diffs are not rendered by default.

build.sbt

Lines changed: 151 additions & 67 deletions
Large diffs are not rendered by default.

build.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ TODO:
279279
<dependency groupId="com.googlecode.jarjar" artifactId="jarjar" version="1.3"/>
280280
</artifact:dependencies>
281281

282+
<artifact:dependencies pathId="jarlister.classpath">
283+
<dependency groupId="com.github.rjolly" artifactId="jarlister_2.11" version="1.0"/>
284+
</artifact:dependencies>
285+
282286
<!-- JUnit -->
283287
<property name="junit.version" value="4.11"/>
284288
<artifact:dependencies pathId="junit.classpath" filesetId="junit.fileset">
@@ -867,6 +871,11 @@ TODO:
867871
<path refid="aux.libs"/>
868872
</path>
869873

874+
<path id="pack.lib.path">
875+
<pathelement location="${library.jar}"/>
876+
<path refid="jarlister.classpath"/>
877+
</path>
878+
870879
<path id="pack.bin.tool.path">
871880
<pathelement location="${library.jar}"/>
872881
<pathelement location="${xml.jar}"/>
@@ -1230,7 +1239,10 @@ TODO:
12301239
<!-- ===========================================================================
12311240
PACKED QUICK BUILD (PACK)
12321241
============================================================================ -->
1233-
<target name="pack.lib" depends="quick.lib, forkjoin.done"> <staged-pack project="library"/></target>
1242+
<target name="pack.lib" depends="quick.lib, forkjoin.done"> <staged-pack project="library"/>
1243+
<taskdef resource="scala/tools/ant/antlib.xml" classpathref="pack.lib.path"/>
1244+
<jarlister file="${library.jar}"/>
1245+
</target>
12341246

12351247
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
12361248

project/BuildSettings.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sbt._
2+
3+
/** This object defines keys that should be visible with an unqualified name in all .sbt files and the command line */
4+
object BuildSettings extends AutoPlugin {
5+
object autoImport {
6+
lazy val antStyle = settingKey[Boolean]("Use ant-style incremental builds instead of name-hashing")
7+
lazy val baseVersion = settingKey[String]("The base version number from which all others are derived")
8+
lazy val baseVersionSuffix = settingKey[String]("Identifies the kind of version to build")
9+
lazy val mimaReferenceVersion = settingKey[Option[String]]("Scala version number to run MiMa against")
10+
}
11+
}

project/MiMa.scala

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// It would be nice to use sbt-mima-plugin here, but the plugin is missing
2+
// at least two features we need:
3+
// * ability to run MiMa twice, swapping `curr` and `prev`, to detect
4+
// both forwards and backwards incompatibilities (possibly fixed as of
5+
// https://github.com/typesafehub/migration-manager/commit/2844ffa48b6d2255aa64bd687703aec21dadd55e)
6+
// * ability to pass a filter file (https://github.com/typesafehub/migration-manager/issues/102)
7+
// So we invoke the MiMa CLI directly; it's also what the Ant build did.
8+
9+
import sbt._
10+
import sbt.Keys._
11+
import BuildSettings.autoImport._
12+
13+
object MiMa {
14+
lazy val mima =
15+
taskKey[Unit]("run Migration Manager to detect binary incompatibilities")
16+
17+
lazy val settings =
18+
Seq(
19+
mima := {
20+
val log = streams.value.log
21+
mimaReferenceVersion.value.fold {
22+
log.info(s"No reference version defined - skipping binary compatibility checks")
23+
} { refVersion =>
24+
def runOnce(prev: java.io.File, curr: java.io.File, isForward: Boolean): Unit = {
25+
val direction = if (isForward) "forward" else "backward"
26+
log.info(s"Checking $direction binary compatibility")
27+
log.debug(s"prev = $prev, curr = $curr")
28+
runMima(
29+
prev = if (isForward) curr else prev,
30+
curr = if (isForward) prev else curr,
31+
// TODO: it would be nicer if each subproject had its own whitelist, but for now
32+
// for compatibility with how Ant did things, there's just one at the root.
33+
// once Ant is gone we'd be free to split it up.
34+
filter = (baseDirectory in ThisBuild).value / s"bincompat-$direction.whitelist.conf",
35+
log)
36+
}
37+
val artifact =
38+
getPreviousArtifact(
39+
"org.scala-lang" % s"${name.value}" % refVersion,
40+
ivySbt.value, streams.value)
41+
for (isForward <- Seq(false, true))
42+
runOnce(artifact, (packageBin in Compile).value, isForward)
43+
}
44+
}
45+
)
46+
47+
def runMima(prev: java.io.File, curr: java.io.File, filter: java.io.File, log: Logger): Unit = {
48+
val args = Array(
49+
"--prev", prev.getAbsolutePath,
50+
"--curr", curr.getAbsolutePath,
51+
"--filters", filter.getAbsolutePath,
52+
"--generate-filters"
53+
)
54+
val exitCode = TrapExit(com.typesafe.tools.mima.cli.Main.main(args), log)
55+
if (exitCode != 0)
56+
throw new RuntimeException(s"MiMa failed with exit code $exitCode")
57+
}
58+
59+
// cribbed from https://github.com/typesafehub/migration-manager/blob/master/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala
60+
def getPreviousArtifact(m: ModuleID, ivy: IvySbt, s: TaskStreams): File = {
61+
val moduleSettings = InlineConfiguration(
62+
"dummy" % "test" % "version",
63+
ModuleInfo("dummy-test-project-for-resolving"),
64+
dependencies = Seq(m))
65+
val module = new ivy.Module(moduleSettings)
66+
val report = Deprecated.Inner.ivyUpdate(ivy)(module, s)
67+
val optFile = (for {
68+
config <- report.configurations
69+
module <- config.modules
70+
(artifact, file) <- module.artifacts
71+
// TODO - Hardcode this?
72+
if artifact.name == m.name
73+
} yield file).headOption
74+
optFile getOrElse sys.error("Could not resolve previous artifact: " + m)
75+
}
76+
77+
}
78+
79+
// use the SI-7934 workaround to silence a deprecation warning on an sbt API
80+
// we have no choice but to call. on the lack of any suitable alternative,
81+
// see https://gitter.im/sbt/sbt-dev?at=5616e2681b0e279854bd74a4 :
82+
// "it's my intention to eventually come up with a public API" says Eugene Y
83+
object Deprecated {
84+
@deprecated("", "") class Inner {
85+
def ivyUpdate(ivy: IvySbt)(module: ivy.Module, s: TaskStreams) =
86+
IvyActions.update(
87+
module,
88+
new UpdateConfiguration(
89+
retrieve = None,
90+
missingOk = false,
91+
logging = UpdateLogging.DownloadOnly),
92+
s.log)
93+
}
94+
object Inner extends Inner
95+
}

project/Osgi.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import aQute.lib.osgi.Builder
22
import aQute.lib.osgi.Constants._
33
import java.util.Properties
4+
import java.util.jar.Attributes
45
import sbt._
56
import sbt.Keys._
67
import scala.collection.JavaConversions._
@@ -16,6 +17,7 @@ object Osgi {
1617
val bundleName = SettingKey[String]("osgiBundleName", "The Bundle-Name for the manifest.")
1718
val bundleSymbolicName = SettingKey[String]("osgiBundleSymbolicName", "The Bundle-SymbolicName for the manifest.")
1819
val headers = SettingKey[Seq[(String, String)]]("osgiHeaders", "Headers and processing instructions for BND.")
20+
val jarlist = SettingKey[Boolean]("osgiJarlist", "List classes in manifest.")
1921

2022
def settings: Seq[Setting[_]] = Seq(
2123
bundleName := description.value,
@@ -26,15 +28,16 @@ object Osgi {
2628
"Bundle-Name" -> bundleName.value,
2729
"Bundle-SymbolicName" -> bundleSymbolicName.value,
2830
"ver" -> v,
29-
"Export-Package" -> ("*;version=${ver}"),
30-
"Import-Package" -> ("scala.*;version=\"${range;[==,=+);${ver}}\",*"),
31+
"Export-Package" -> "*;version=${ver};-split-package:=merge-first",
32+
"Import-Package" -> "scala.*;version=\"${range;[==,=+);${ver}}\",*",
3133
"Bundle-Version" -> v,
3234
"Bundle-RequiredExecutionEnvironment" -> "JavaSE-1.6, JavaSE-1.7",
3335
"-eclipse" -> "false"
3436
)
3537
},
38+
jarlist := false,
3639
bundle <<= Def.task {
37-
bundleTask(headers.value.toMap, (products in Compile in packageBin).value,
40+
bundleTask(headers.value.toMap, jarlist.value, (products in Compile in packageBin).value,
3841
(artifactPath in (Compile, packageBin)).value, Nil, streams.value)
3942
},
4043
packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), bundle).identityMap,
@@ -47,7 +50,7 @@ object Osgi {
4750
)
4851
)
4952

50-
def bundleTask(headers: Map[String, String], fullClasspath: Seq[File], artifactPath: File,
53+
def bundleTask(headers: Map[String, String], jarlist: Boolean, fullClasspath: Seq[File], artifactPath: File,
5154
resourceDirectories: Seq[File], streams: TaskStreams): File = {
5255
val log = streams.log
5356
val builder = new Builder
@@ -62,6 +65,12 @@ object Osgi {
6265
builder.getWarnings.foreach(s => log.warn(s"bnd: $s"))
6366
builder.getErrors.foreach(s => log.error(s"bnd: $s"))
6467
IO.createDirectory(artifactPath.getParentFile)
68+
if (jarlist) {
69+
val entries = jar.getManifest.getEntries
70+
for ((name, resource) <- jar.getResources if name.endsWith(".class")) {
71+
entries.put(name, new Attributes)
72+
}
73+
}
6574
jar.write(artifactPath)
6675
artifactPath
6776
}

project/Quiet.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ object Quiet {
2828
case x => x
2929
}
3030
}
31-
32-
def silenceIvyUpdateInfoLogging = logLevel in update := Level.Warn
3331
}

project/ScalaTool.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ case class ScalaTool(mainClass: String,
2727
} else classpath.mkString(":").replace('\\', '/').replaceAll(varRegex, """\${$1}""")
2828

2929
val variables = Map(
30-
("@@" -> "@"), // for backwards compatibility
31-
("@class@" -> mainClass),
32-
("@properties@" -> (properties map { case (k, v) => s"""-D$k="$v""""} mkString " ")),
33-
("@javaflags@" -> javaOpts),
34-
("@toolflags@" -> toolFlags),
35-
("@classpath@" -> platformClasspath)
30+
"@@" -> "@", // for backwards compatibility
31+
"@class@" -> mainClass,
32+
"@properties@" -> (properties map { case (k, v) => s"""-D$k="$v""""} mkString " "),
33+
"@javaflags@" -> javaOpts,
34+
"@toolflags@" -> toolFlags,
35+
"@classpath@" -> platformClasspath
3636
)
3737

3838
val (from, to) = variables.unzip

project/ScriptCommands.scala

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
import sbt._
22
import Keys._
3-
import complete.DefaultParsers._
3+
import BuildSettings.autoImport._
44

55
/** Custom commands for use by the Jenkins scripts. This keeps the surface area and call syntax small. */
66
object ScriptCommands {
7-
def all = Seq(setupPublishCore)
7+
def all = Seq(setupPublishCore, setupValidateTest)
88

99
/** Set up the environment for `validate/publish-core`. The argument is the Artifactory snapshot repository URL. */
1010
def setupPublishCore = Command.single("setupPublishCore") { case (state, url) =>
1111
Project.extract(state).append(Seq(
12-
VersionUtil.baseVersionSuffix in Global := "SHA-SNAPSHOT",
12+
baseVersionSuffix in Global := "SHA-SNAPSHOT",
1313
// Append build.timestamp to Artifactory URL to get consistent build numbers (see https://github.com/sbt/sbt/issues/2088):
1414
publishTo in Global := Some("scala-pr" at url.replaceAll("/$", "") + ";build.timestamp=" + System.currentTimeMillis),
1515
publishArtifact in (Compile, packageDoc) in ThisBuild := false,
16-
scalacOptions in Compile in ThisBuild += "-optimise"
16+
scalacOptions in Compile in ThisBuild += "-optimise",
17+
logLevel in ThisBuild := Level.Info,
18+
logLevel in update in ThisBuild := Level.Warn
1719
), state)
1820
}
21+
22+
/** Set up the environment for `validate/test`. The argument is the Artifactory snapshot repository URL. */
23+
def setupValidateTest = Command.single("setupValidateTest") { case (state, url) =>
24+
//TODO When ant is gone, pass starr version as an argument to this command instead of using version.properties
25+
Project.extract(state).append(Seq(
26+
resolvers in Global += "scala-pr" at url,
27+
scalacOptions in Compile in ThisBuild += "-optimise",
28+
logLevel in ThisBuild := Level.Info,
29+
logLevel in update in ThisBuild := Level.Warn
30+
), state)
31+
}
1932
}

0 commit comments

Comments
 (0)