Skip to content

Commit a436e90

Browse files
committed
Merge pull request scala#4500 from lrytz/merge-2.11-may-12
Merge 2.11.x into 2.12.x [ci: last-only]
2 parents 0bcd0a4 + d253702 commit a436e90

File tree

170 files changed

+7550
-33038
lines changed

Some content is hidden

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

170 files changed

+7550
-33038
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ scala/
5151
+---/reflect Scala Reflection.
5252
+---/compiler Scala Compiler.
5353
+---/eclipse Eclipse project files.
54-
+---/intellij-14 IntelliJ project templates.
54+
+---/intellij IntelliJ project templates.
5555
+--scripts/ Scripts for the CI jobs (including building releases)
5656
+--test/ The Scala test suite.
5757
+--build/ [Generated] Build products output directory for ant.
@@ -118,8 +118,8 @@ Use the latest IntelliJ IDEA release and install the Scala plugin from within th
118118

119119
The following steps are required to use IntelliJ IDEA on Scala trunk
120120
- Run `ant init`. This will download some JARs to `./build/deps`, which are included in IntelliJ's classpath.
121-
- Run src/intellij-14/setup.sh
122-
- Open ./src/intellij-14/scala.ipr in IntelliJ
121+
- Run src/intellij/setup.sh
122+
- Open ./src/intellij/scala.ipr in IntelliJ
123123
- File, Project Settings, Project, SDK. Create an SDK entry named "1.6" containing the Java 1.6 SDK.
124124
(You may use a later SDK for local development, but the CI will verify against Java 6.)
125125

build-ant-macros.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
<macrodef name="simple-javac">
9393
<attribute name="project"/>
94-
<!-- project: asm/forkjoin -->
94+
<!-- project: forkjoin -->
9595
<attribute name="args" default=""/>
9696
<attribute name="jar" default="yes"/>
9797
<sequential>
@@ -371,6 +371,10 @@
371371
<then>
372372
<mkdir dir="${build-pack.dir}/${@{project}.targetdir}"/>
373373
<pre/>
374+
<!-- can't check if a fileset is defined, so we have an additional property -->
375+
<if><not><isset property="pack.@{project}.include-jars.defined"/></not><then>
376+
<fileset id="pack.@{project}.include-jars" dir="." excludes="**" />
377+
</then></if>
374378
<if>
375379
<not>
376380
<equals arg1="@{manifest}" arg2=""/>
@@ -380,6 +384,7 @@
380384
<!-- update="true" makes no difference on my machine, so starting from scratch-->
381385
<jar-opts/>
382386
<path refid="pack.@{project}.files"/>
387+
<zipgroupfileset refid="pack.@{project}.include-jars"/>
383388
</jar>
384389
</then>
385390
<else>

build.sbt

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ val partestDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest" %
6161
val partestInterfaceDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest-interface" % "0.5.0")
6262
val junitDep = "junit" % "junit" % "4.11"
6363
val junitIntefaceDep = "com.novocode" % "junit-interface" % "0.11" % "test"
64+
val asmDep = "org.scala-lang.modules" % "scala-asm" % versionProps("scala-asm.version")
6465
val jlineDep = "jline" % "jline" % versionProps("jline.version")
6566
val antDep = "org.apache.ant" % "ant" % "1.9.4"
6667
val scalacheckDep = withoutScalaLang("org.scalacheck" %% "scalacheck" % "1.11.4")
@@ -169,17 +170,22 @@ lazy val compiler = configureAsSubproject(project)
169170
.settings(generatePropertiesFileSettings: _*)
170171
.settings(
171172
name := "scala-compiler",
172-
libraryDependencies += antDep,
173+
libraryDependencies ++= Seq(antDep, asmDep),
173174
// this a way to make sure that classes from interactive and scaladoc projects
174175
// end up in compiler jar (that's what Ant build does)
175176
// we need to use LocalProject references (with strings) to deal with mutual recursion
176177
mappings in Compile in packageBin :=
177178
(mappings in Compile in packageBin).value ++
179+
dependencyClasses(
180+
(externalDependencyClasspath in Compile).value,
181+
modules = Set(asmDep),
182+
keep = "*.class" || "scala-asm.properties",
183+
streams.value.cacheDirectory) ++
178184
(mappings in Compile in packageBin in LocalProject("interactive")).value ++
179185
(mappings in Compile in packageBin in LocalProject("scaladoc")).value ++
180186
(mappings in Compile in packageBin in LocalProject("repl")).value,
181187
includeFilter in unmanagedResources in Compile := compilerIncludes)
182-
.dependsOn(library, reflect, asm)
188+
.dependsOn(library, reflect)
183189

184190
lazy val interactive = configureAsSubproject(project)
185191
.settings(disableDocsAndPublishingTasks: _*)
@@ -209,8 +215,6 @@ lazy val actors = configureAsSubproject(project)
209215

210216
lazy val forkjoin = configureAsForkOfJavaProject(project)
211217

212-
lazy val asm = configureAsForkOfJavaProject(project)
213-
214218
lazy val partestExtras = configureAsSubproject(Project("partest-extras", file(".") / "src" / "partest-extras"))
215219
.dependsOn(repl)
216220
.settings(clearSourceAndResourceDirectories: _*)
@@ -231,9 +235,9 @@ lazy val junit = project.in(file("test") / "junit")
231235
)
232236

233237
lazy val partestJavaAgent = (project in file(".") / "src" / "partest-javaagent").
234-
dependsOn(asm).
235238
settings(commonSettings: _*).
236239
settings(
240+
libraryDependencies += asmDep,
237241
doc := file("!!! NO DOCS !!!"),
238242
publishLocal := {},
239243
publish := {},
@@ -249,13 +253,13 @@ lazy val partestJavaAgent = (project in file(".") / "src" / "partest-javaagent")
249253
)
250254

251255
lazy val test = project.
252-
dependsOn(compiler, interactive, actors, repl, scalap, partestExtras, partestJavaAgent, asm, scaladoc).
256+
dependsOn(compiler, interactive, actors, repl, scalap, partestExtras, partestJavaAgent, scaladoc).
253257
configs(IntegrationTest).
254258
settings(disableDocsAndPublishingTasks: _*).
255259
settings(commonSettings: _*).
256260
settings(Defaults.itSettings: _*).
257261
settings(
258-
libraryDependencies ++= Seq(partestDep, scalaXmlDep, partestInterfaceDep, scalacheckDep),
262+
libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep, partestInterfaceDep, scalacheckDep),
259263
unmanagedBase in Test := baseDirectory.value / "files" / "lib",
260264
unmanagedJars in Test <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity),
261265
// no main sources
@@ -279,7 +283,7 @@ lazy val test = project.
279283
)
280284

281285
lazy val root = (project in file(".")).
282-
aggregate(library, forkjoin, reflect, compiler, asm, interactive, repl,
286+
aggregate(library, forkjoin, reflect, compiler, interactive, repl,
283287
scaladoc, scalap, actors, partestExtras, junit).settings(
284288
sources in Compile := Seq.empty,
285289
onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
@@ -310,7 +314,7 @@ def configureAsSubproject(project: Project): Project = {
310314

311315
/**
312316
* Configuration for subprojects that are forks of some Java projects
313-
* we depend on. At the moment there are just two: asm and forkjoin.
317+
* we depend on. At the moment there's just forkjoin.
314318
*
315319
* We do not publish artifacts for those projects but we package their
316320
* binaries in a jar of other project (compiler or library).
@@ -382,6 +386,50 @@ lazy val generateVersionPropertiesFileImpl: Def.Initialize[Task[File]] = Def.tas
382386
propFile
383387
}
384388

389+
/**
390+
* Extract selected dependencies to the `cacheDirectory` and return a mapping for the content.
391+
* Heavily inspired by sbt-assembly (https://github.com/sbt/sbt-assembly/blob/0.13.0/src/main/scala/sbtassembly/Assembly.scala#L157)
392+
*/
393+
def dependencyClasses(dependencies: Classpath, modules: Set[ModuleID], keep: FileFilter, cacheDirectory: File): Seq[(File, String)] = {
394+
val dependencyFiles: Seq[File] = dependencies.map(_.data).toSeq
395+
val toInclude = dependencyFiles.filter(f => {
396+
val p = f.getCanonicalPath
397+
modules.exists(m => {
398+
// works for both .m2 (org/scala-lang/modules/scala-asm/5.0.3-scala-3/scala-asm-5.0.3-scala-3.jar)
399+
// and .ivy2 (org.scala-lang.modules/scala-asm/5.0.3-scala-3/bundles/scala-asm.jar)
400+
val nameParts = m.organization.split('.').toSet + m.name + m.revision
401+
nameParts.forall(p.contains)
402+
})
403+
})
404+
assert(toInclude.forall(sbt.classpath.ClasspathUtilities.isArchive), s"Expected JAR files as dependencies: $toInclude")
405+
406+
val tempDir = cacheDirectory / "unpackedDependencies"
407+
408+
def sha1name(f: File): String = bytesToSha1String(f.getCanonicalPath.getBytes("UTF-8"))
409+
def sha1content(f: File): String = bytesToSha1String(IO.readBytes(f))
410+
def bytesToSha1String(bytes: Array[Byte]): String = {
411+
val sha1 = java.security.MessageDigest.getInstance("SHA-1")
412+
val hash = sha1.digest(bytes)
413+
hash map {"%02x".format(_)} mkString
414+
}
415+
416+
val jarDirs: Seq[File] = for (jar <- toInclude) yield {
417+
val jarName = jar.getName
418+
val hash = sha1name(jar) + "_" + sha1content(jar)
419+
val jarNamePath = tempDir / (hash + ".jarName")
420+
val dest = tempDir / hash
421+
if (!jarNamePath.exists || IO.read(jarNamePath) != jar.getCanonicalPath) {
422+
IO.delete(dest)
423+
dest.mkdir()
424+
IO.unzip(jar, dest)
425+
IO.write(jarNamePath, jar.getCanonicalPath, IO.utf8, append = false)
426+
}
427+
dest
428+
}
429+
430+
jarDirs.flatMap(dir => dir ** keep --- dir pair relativeTo(dir))
431+
}
432+
385433
// Defining these settings is somewhat redundant as we also redefine settings that depend on them.
386434
// However, IntelliJ's project import works better when these are set correctly.
387435
def clearSourceAndResourceDirectories = Seq(Compile, Test).flatMap(config => inConfig(config)(Seq(

build.xml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ TODO:
165165
<property name="build.dir" value="${basedir}/build"/>
166166
<property name="build-deps.dir" value="${build.dir}/deps"/>
167167
<property name="build-libs.dir" value="${build.dir}/libs"/>
168-
<property name="build-asm.dir" value="${build-libs.dir}"/>
169168
<property name="build-forkjoin.dir" value="${build-libs.dir}"/>
170169
<property name="build-locker.dir" value="${build.dir}/locker"/>
171170
<property name="build-quick.dir" value="${build.dir}/quick"/>
@@ -266,6 +265,11 @@ TODO:
266265
-->
267266
<if><not><isset property="maven-deps-done"></isset></not><then>
268267
<mkdir dir="${user.home}/.m2/repository"/>
268+
269+
<artifact:remoteRepository id="sonatype-release" url="https://oss.sonatype.org/content/repositories/releases"/>
270+
<artifact:remoteRepository id="sonatype-snapshots" url="https://oss.sonatype.org/content/repositories/snapshots"/>
271+
<artifact:remoteRepository id="extra-repo" url="${extra.repo.url}"/>
272+
269273
<!-- This task has an issue where if the user directory does not exist, so we create it above. UGH. -->
270274
<artifact:dependencies pathId="extra.tasks.classpath" filesetId="extra.tasks.fileset">
271275
<dependency groupId="biz.aQute" artifactId="bnd" version="1.50.0"/>
@@ -307,6 +311,36 @@ TODO:
307311
<artifact:remoteRepository id="sonatype-release" url="https://oss.sonatype.org/content/repositories/releases"/>
308312
<artifact:remoteRepository id="extra-repo" url="${extra.repo.url}"/>
309313

314+
<!-- scala-java8-compat, used by the experimental -target jvm-1.8 support. -->
315+
<if><isset property="scala-java8-compat.package"/><then>
316+
<property name="scala-java8-compat.version" value="0.2.0"/>
317+
<property name="scala-java8-compat.binary.version" value="2.11"/>
318+
<artifact:dependencies pathId="scala-java8-compat.classpath" filesetId="scala-java8-compat.fileset">
319+
<dependency groupId="org.scala-lang.modules" artifactId="scala-java8-compat_${scala-java8-compat.binary.version}" version="${scala-java8-compat.version}">
320+
<exclusion groupId="org.scala-lang" artifactId="scala-library"/>
321+
</dependency>
322+
</artifact:dependencies>
323+
<property name="scala-java8-compat-classes" value="${build-quick.dir}/scala-java8-compat"/>
324+
<delete dir="${scala-java8-compat-classes}"/>
325+
<unzip dest="${scala-java8-compat-classes}">
326+
<fileset refid="scala-java8-compat.fileset"/>
327+
<patternset>
328+
<include name="**/*.class"/>
329+
</patternset>
330+
</unzip>
331+
<path id="scala-java8-compat.libs">
332+
<pathelement location="${scala-java8-compat-classes}"/>
333+
</path>
334+
<fileset id="scala-java8-compat.fileset" dir="${scala-java8-compat-classes}">
335+
<include name="**/*"/>
336+
</fileset>
337+
</then>
338+
<else>
339+
<path id="scala-java8-compat.libs"/>
340+
<fileset id="scala-java8-compat.fileset" dir="." excludes="**"/>
341+
</else>
342+
</if>
343+
310344
<!-- prepare, for each of the names below, the property "@{name}.cross", set to the
311345
necessary cross suffix (usually something like "_2.11.0-M6". -->
312346
<prepareCross name="scala-xml" />
@@ -315,6 +349,11 @@ TODO:
315349
<prepareCross name="partest"/>
316350
<prepareCross name="scalacheck"/>
317351

352+
<artifact:dependencies pathId="asm.classpath" filesetId="asm.fileset">
353+
<dependency groupId="org.scala-lang.modules" artifactId="scala-asm" version="${scala-asm.version}"/>
354+
</artifact:dependencies>
355+
<copy-deps project="asm"/>
356+
318357
<!-- TODO: delay until absolutely necessary to allow minimal build, also move out partest dependency from scaladoc -->
319358
<artifact:dependencies pathId="partest.classpath" filesetId="partest.fileset" versionsId="partest.versions">
320359
<!-- uncomment the following if you're deploying your own partest locally -->
@@ -572,9 +611,7 @@ TODO:
572611
</then></if>
573612

574613
<path id="forkjoin.classpath" path="${build-forkjoin.dir}/classes/forkjoin"/>
575-
<path id="asm.classpath" path="${build-asm.dir}/classes/asm"/>
576614
<property name="forkjoin-classes" refid="forkjoin.classpath"/>
577-
<property name="asm-classes" refid="asm.classpath"/>
578615

579616
<!-- the following properties fully define staged-docs, staged-pack, make-bundle, copy-bundle and mvn-package for each of the projects -->
580617
<property name="library.description" value="Scala Standard Library"/>
@@ -627,7 +664,7 @@ TODO:
627664
<property name="partest-extras.description" value="Scala Compiler Testing Tool (compiler-specific extras)"/>
628665
<property name="partest-javaagent.description" value="Scala Compiler Testing Tool (compiler-specific java agent)"/>
629666

630-
<!-- projects without project-specific options: asm, forkjoin, manual, bin, repl -->
667+
<!-- projects without project-specific options: forkjoin, manual, bin, repl -->
631668
<for list="compiler,interactive,scaladoc,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml" param="project">
632669
<sequential>
633670
<!-- description is mandatory -->
@@ -687,6 +724,7 @@ TODO:
687724
<pathelement location="${build-locker.dir}/classes/library"/>
688725
<path refid="forkjoin.classpath"/>
689726
<path refid="aux.libs"/>
727+
<path refid="scala-java8-compat.libs"/>
690728
</path>
691729

692730
<path id="locker.reflect.build.path">
@@ -708,6 +746,7 @@ TODO:
708746
<pathelement location="${build-quick.dir}/classes/library"/>
709747
<path refid="forkjoin.classpath"/>
710748
<path refid="aux.libs"/>
749+
<path refid="scala-java8-compat.libs"/>
711750
</path>
712751

713752
<path id="quick.reflect.build.path">
@@ -789,6 +828,7 @@ TODO:
789828
<path id="pack.library.files">
790829
<fileset dir="${build-quick.dir}/classes/library"/>
791830
<fileset dir="${forkjoin-classes}"/>
831+
<fileset refid="scala-java8-compat.fileset"/>
792832
</path>
793833

794834
<path id="pack.compiler.files">
@@ -798,8 +838,9 @@ TODO:
798838
<fileset dir="${build-quick.dir}/classes/scaladoc"/>
799839
<fileset dir="${build-quick.dir}/classes/interactive"/>
800840
<fileset dir="${build-quick.dir}/classes/repl"/>
801-
<fileset dir="${asm-classes}"/>
802841
</path>
842+
<fileset id="pack.compiler.include-jars" refid="asm.fileset"/>
843+
<property name="pack.compiler.include-jars.defined" value="yeah"/>
803844

804845
<!-- TODO modularize compiler.
805846
<path id="pack.scaladoc.files"> <fileset dir="${build-quick.dir}/classes/scaladoc"/> </path>
@@ -994,9 +1035,9 @@ TODO:
9941035
<!-- ===========================================================================
9951036
CLEANLINESS
9961037
=============================================================================-->
997-
<target name="libs.clean"> <clean build="libs"/> <clean build="asm"/> </target>
998-
<target name="quick.clean" depends="libs.clean"> <clean build="quick"/> <clean build="pack"/> <clean build="strap"/> </target>
999-
<target name="locker.clean" depends="quick.clean"> <clean build="locker"/> </target>
1038+
<target name="libs.clean"> <clean build="libs"/> </target>
1039+
<target name="quick.clean" depends="libs.clean"> <clean build="quick"/> <clean build="pack"/> <clean build="strap"/> </target>
1040+
<target name="locker.clean" depends="quick.clean"> <clean build="locker"/> </target>
10001041

10011042
<target name="docs.clean"> <clean build="docs"/> <delete dir="${build.dir}/manmaker" includeemptydirs="yes" quiet="yes" failonerror="no"/> </target>
10021043
<target name="dist.clean"> <delete dir="${dists.dir}" includeemptydirs="yes" quiet="yes" failonerror="no"/> </target>
@@ -1014,7 +1055,6 @@ TODO:
10141055
LOCAL DEPENDENCIES
10151056
============================================================================ -->
10161057

1017-
<target name="asm.done" depends="init"> <simple-javac project="asm" jar="no"/> </target>
10181058
<target name="forkjoin.done" depends="init"> <simple-javac project="forkjoin" args="-XDignore.symbol.file" jar="no"/></target>
10191059

10201060
<!-- For local development only. We only allow released versions of Scala for STARR.
@@ -1037,7 +1077,7 @@ TODO:
10371077
<!-- ===========================================================================
10381078
LOCAL REFERENCE BUILD (LOCKER)
10391079
============================================================================ -->
1040-
<target name="locker.start" depends="asm.done, forkjoin.done">
1080+
<target name="locker.start" depends="forkjoin.done">
10411081
<condition property="locker.locked"><available file="${build-locker.dir}/locker.locked"/></condition></target>
10421082

10431083
<target name="locker.lib" depends="locker.start" unless="locker.locked">
@@ -1102,7 +1142,7 @@ TODO:
11021142
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
11031143

11041144
<!-- TODO modularize compiler. Remove other quick targets when they become modules. -->
1105-
<target name="pack.comp" depends="quick.comp, quick.scaladoc, quick.interactive, quick.repl, asm.done">
1145+
<target name="pack.comp" depends="quick.comp, quick.scaladoc, quick.interactive, quick.repl">
11061146
<staged-pack project="compiler" manifest="${build-pack.dir}/META-INF/MANIFEST.MF">
11071147
<pre> <!-- TODO the files copied here do not influence actuality of this target (nor does the manifest) -->
11081148
<copy todir="${build-pack.dir}/lib">

scripts/jobs/integrate/bootstrap

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,18 @@ mkdir -p $baseDir/resolutionScratch_
114114
# repo used to publish "locker" scala to (to start the bootstrap)
115115
releaseTempRepoCred="private-repo"
116116
releaseTempRepoUrl=${releaseTempRepoUrl-"https://scala-ci.typesafe.com/artifactory/scala-release-temp/"}
117+
jcenterCacheUrl=${jcenterCacheUrl-"https://scala-ci.typesafe.com/artifactory/jcenter/"}
117118

118119
# Used below in sbtArgs since we use a dedicated repository to share artifcacts between jobs,
119120
# so we need to configure SBT to use these rather than its default, Maven Central.
120121
# See http://www.scala-sbt.org/0.13/docs/Proxy-Repositories.html
121122
sbtRepositoryConfig="$scriptsDir/repositories-scala-release"
122123
cat > "$sbtRepositoryConfig" << EOF
123124
[repositories]
124-
plugins: http://dl.bintray.com/sbt/sbt-plugin-releases/, [organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
125125
private-repo: $releaseTempRepoUrl
126-
typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
127-
sbt-plugin-releases: http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
126+
jcenter-cache: $jcenterCacheUrl
127+
typesafe-ivy-releases: https://dl.bintray.com/typesafe/ivy-releases/, [organisation]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
128+
sbt-plugin-releases: https://dl.bintray.com/sbt/sbt-plugin-releases/, [organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
128129
maven-central
129130
local
130131
EOF

0 commit comments

Comments
 (0)