52
52
* https://groups.google.com/d/topic/scala-internals/gp5JsM1E0Fo/discussion
53
53
*/
54
54
55
+ import VersionUtil .{versionProps , versionNumber , generatePropertiesFileSettings , versionProperties , versionPropertiesSettings }
56
+
55
57
val bootstrapScalaVersion = versionProps(" starr.version" )
56
58
57
59
def withoutScalaLang (moduleId : ModuleID ): ModuleID = moduleId exclude(" org.scala-lang" , " *" )
@@ -71,8 +73,9 @@ val jlineDep = "jline" % "jline" % versionProps("jline.version")
71
73
val antDep = " org.apache.ant" % " ant" % " 1.9.4"
72
74
val scalacheckDep = withoutScalaLang(" org.scalacheck" %% " scalacheck" % versionNumber(" scalacheck" ) % " it" )
73
75
74
- lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq [Setting [_]](
76
+ lazy val commonSettings = clearSourceAndResourceDirectories ++ versionPropertiesSettings ++ Seq [Setting [_]](
75
77
organization := " org.scala-lang" ,
78
+ // The ANT build uses the file "build.number" and the property "build.release" to compute the version
76
79
version := " 2.11.8-SNAPSHOT" ,
77
80
scalaVersion := bootstrapScalaVersion,
78
81
// we don't cross build Scala itself
@@ -95,6 +98,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
95
98
unmanagedJars in Compile := Seq .empty,
96
99
sourceDirectory in Compile := baseDirectory.value,
97
100
unmanagedSourceDirectories in Compile := List (baseDirectory.value),
101
+ unmanagedResourceDirectories in Compile += (baseDirectory in ThisBuild ).value / " src" / thisProject.value.id,
98
102
scalaSource in Compile := (sourceDirectory in Compile ).value,
99
103
javaSource in Compile := (sourceDirectory in Compile ).value,
100
104
// resources are stored along source files in our current layout
@@ -108,7 +112,17 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
108
112
// to make sure they are being cleaned properly
109
113
cleanFiles += (classDirectory in Compile ).value,
110
114
cleanFiles += (target in Compile in doc).value,
111
- fork in run := true
115
+ fork in run := true ,
116
+ scalacOptions in Compile in doc ++= Seq (
117
+ " -doc-footer" , " epfl" ,
118
+ " -diagrams" ,
119
+ " -implicits" ,
120
+ " -groups" ,
121
+ " -doc-version" , versionProperties.value.canonicalVersion,
122
+ " -doc-title" , description.value,
123
+ " -sourcepath" , (baseDirectory in ThisBuild ).value.toString,
124
+ " -doc-source-url" , s " https://github.com/scala/scala/tree/ ${versionProperties.value.githubTree}€{FILE_PATH}.scala#L1 "
125
+ )
112
126
)
113
127
114
128
// disable various tasks that are not needed for projects that are used
@@ -134,13 +148,7 @@ lazy val setJarLocation: Setting[_] =
134
148
val resolvedArtifactName = s " ${resolvedArtifact.name}. ${resolvedArtifact.extension}"
135
149
buildDirectory.value / " pack/lib" / resolvedArtifactName
136
150
}
137
- lazy val scalaSubprojectSettings : Seq [Setting [_]] = commonSettings :+ setJarLocation
138
-
139
- lazy val generatePropertiesFileSettings = Seq [Setting [_]](
140
- copyrightString := " Copyright 2002-2015, LAMP/EPFL" ,
141
- resourceGenerators in Compile += generateVersionPropertiesFile.map(file => Seq (file)).taskValue,
142
- generateVersionPropertiesFile := generateVersionPropertiesFileImpl.value
143
- )
151
+ lazy val scalaSubprojectSettings : Seq [Setting [_]] = commonSettings ++ generatePropertiesFileSettings :+ setJarLocation
144
152
145
153
def filterDocSources (ff : FileFilter ): Seq [Setting [_]] = Seq (
146
154
sources in (Compile , doc) ~= (_.filter(ff.accept _)),
@@ -160,19 +168,21 @@ def regexFileFilter(s: String): FileFilter = new FileFilter {
160
168
def accept (f : File ) = pat.matcher(f.getAbsolutePath.replace('\\ ' , '/' )).matches()
161
169
}
162
170
163
- val libIncludes : FileFilter = " *.tmpl" | " *.xml" | " *.js" | " *.css" | " rootdoc.txt"
164
-
165
171
lazy val library = configureAsSubproject(project)
166
172
.settings(generatePropertiesFileSettings : _* )
167
173
.settings(
168
174
name := " scala-library" ,
175
+ description := " Scala Standard Library" ,
169
176
scalacOptions in Compile ++= Seq [String ](" -sourcepath" , (scalaSource in Compile ).value.toString),
170
177
scalacOptions in Compile in doc ++= {
171
178
val libraryAuxDir = (baseDirectory in ThisBuild ).value / " src/library-aux"
172
- Seq (" -doc-no-compile" , libraryAuxDir.toString)
179
+ Seq (
180
+ " -doc-no-compile" , libraryAuxDir.toString,
181
+ " -skip-packages" , " scala.concurrent.impl" ,
182
+ " -doc-root-content" , (sourceDirectory in Compile ).value + " /rootdoc.txt"
183
+ )
173
184
},
174
- unmanagedResourceDirectories in Compile += (baseDirectory in ThisBuild ).value / " src" / project.id,
175
- includeFilter in unmanagedResources in Compile := libIncludes,
185
+ includeFilter in unmanagedResources in Compile := " *.tmpl" | " *.xml" | " *.js" | " *.css" | " rootdoc.txt" ,
176
186
// Include forkjoin classes in scala-library.jar
177
187
mappings in Compile in packageBin ++=
178
188
(mappings in Compile in packageBin in LocalProject (" forkjoin" )).value
@@ -184,17 +194,20 @@ lazy val library = configureAsSubproject(project)
184
194
185
195
lazy val reflect = configureAsSubproject(project)
186
196
.settings(generatePropertiesFileSettings : _* )
187
- .settings(name := " scala-reflect" )
197
+ .settings(
198
+ name := " scala-reflect" ,
199
+ description := " Scala Reflection Library" ,
200
+ scalacOptions in Compile in doc ++= Seq (
201
+ " -skip-packages" , " scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"
202
+ )
203
+ )
188
204
.dependsOn(library)
189
205
190
- val compilerIncludes : FileFilter =
191
- " *.tmpl" | " *.xml" | " *.js" | " *.css" | " *.html" | " *.properties" | " *.swf" |
192
- " *.png" | " *.gif" | " *.gif" | " *.txt"
193
-
194
206
lazy val compiler = configureAsSubproject(project)
195
207
.settings(generatePropertiesFileSettings : _* )
196
208
.settings(
197
209
name := " scala-compiler" ,
210
+ description := " Scala Compiler" ,
198
211
libraryDependencies ++= Seq (antDep, asmDep),
199
212
// this a way to make sure that classes from interactive and scaladoc projects
200
213
// end up in compiler jar (that's what Ant build does)
@@ -209,12 +222,21 @@ lazy val compiler = configureAsSubproject(project)
209
222
(mappings in Compile in packageBin in LocalProject (" interactive" )).value ++
210
223
(mappings in Compile in packageBin in LocalProject (" scaladoc" )).value ++
211
224
(mappings in Compile in packageBin in LocalProject (" repl" )).value,
212
- unmanagedResourceDirectories in Compile += (baseDirectory in ThisBuild ).value / " src" / project.id,
213
- includeFilter in unmanagedResources in Compile := compilerIncludes)
225
+ includeFilter in unmanagedResources in Compile :=
226
+ " *.tmpl" | " *.xml" | " *.js" | " *.css" | " *.html" | " *.properties" | " *.swf" |
227
+ " *.png" | " *.gif" | " *.gif" | " *.txt" ,
228
+ scalacOptions in Compile in doc ++= Seq (
229
+ " -doc-root-content" , (sourceDirectory in Compile ).value + " /rootdoc.txt"
230
+ )
231
+ )
214
232
.dependsOn(library, reflect)
215
233
216
234
lazy val interactive = configureAsSubproject(project)
217
235
.settings(disableDocsAndPublishingTasks : _* )
236
+ .settings(
237
+ name := " scala-compiler-interactive" ,
238
+ description := " Scala Interactive Compiler"
239
+ )
218
240
.dependsOn(compiler)
219
241
220
242
lazy val repl = configureAsSubproject(project)
@@ -272,18 +294,29 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target"
272
294
273
295
lazy val scaladoc = configureAsSubproject(project)
274
296
.settings(
275
- libraryDependencies ++= Seq (scalaXmlDep, scalaParserCombinatorsDep, partestDep)
297
+ name := " scala-compiler-doc" ,
298
+ description := " Scala Documentation Generator" ,
299
+ libraryDependencies ++= Seq (scalaXmlDep, scalaParserCombinatorsDep, partestDep),
300
+ includeFilter in unmanagedResources in Compile := " *.html" | " *.css" | " *.gif" | " *.png" | " *.js" | " *.txt"
276
301
)
277
302
.settings(disableDocsAndPublishingTasks : _* )
278
303
.dependsOn(compiler)
279
304
280
305
lazy val scalap = configureAsSubproject(project).
281
- dependsOn(compiler)
306
+ settings(
307
+ description := " Scala Bytecode Parser" ,
308
+ // Include decoder.properties
309
+ includeFilter in unmanagedResources in Compile := " *.properties"
310
+ )
311
+ .dependsOn(compiler)
282
312
283
313
// deprecated Scala Actors project
284
314
lazy val actors = configureAsSubproject(project)
285
315
.settings(generatePropertiesFileSettings : _* )
286
- .settings(name := " scala-actors" )
316
+ .settings(
317
+ name := " scala-actors" ,
318
+ description := " Scala Actors Library"
319
+ )
287
320
.settings(filterDocSources(" *.scala" ): _* )
288
321
.dependsOn(library)
289
322
@@ -294,6 +327,7 @@ lazy val partestExtras = configureAsSubproject(Project("partest-extras", file(".
294
327
.settings(clearSourceAndResourceDirectories : _* )
295
328
.settings(
296
329
name := " scala-partest-extras" ,
330
+ description := " Scala Compiler Testing Tool (compiler-specific extras)" ,
297
331
libraryDependencies += partestDep,
298
332
unmanagedSourceDirectories in Compile := List (baseDirectory.value),
299
333
doc := file(" !!! NO DOCS !!!" )
@@ -311,15 +345,17 @@ lazy val junit = project.in(file("test") / "junit")
311
345
doc := file(" !!! NO DOCS !!!" )
312
346
)
313
347
314
- lazy val partestJavaAgent = (project in file(" ." ) / " src" / " partest-javaagent" ).
315
- settings(commonSettings : _* ).
316
- settings(
348
+ lazy val partestJavaAgent = Project (" partest-javaagent" , file(" ." ) / " src" / " partest-javaagent" )
349
+ .settings(commonSettings : _* )
350
+ .settings(generatePropertiesFileSettings : _* )
351
+ .settings(
317
352
libraryDependencies += asmDep,
318
353
doc := file(" !!! NO DOCS !!!" ),
319
354
publishLocal := {},
320
355
publish := {},
321
356
// Setting name to "scala-partest-javaagent" so that the jar file gets that name, which the Runner relies on
322
357
name := " scala-partest-javaagent" ,
358
+ description := " Scala Compiler Testing Tool (compiler-specific java agent)" ,
323
359
// writing jar file to $buildDirectory/pack/lib because that's where it's expected to be found
324
360
setJarLocation,
325
361
// add required manifest entry - previously included from file
@@ -377,7 +413,7 @@ lazy val dist = (project in file("dist"))
377
413
.settings(
378
414
libraryDependencies ++= Seq (scalaContinuationsLibraryDep, scalaContinuationsPluginDep, scalaSwingDep, jlineDep),
379
415
mkBin := mkBinImpl.value,
380
- mkQuick <<= Def .task {} dependsOn ((distDependencies.map(compile in Compile in _) :+ mkBin): _* ),
416
+ mkQuick <<= Def .task {} dependsOn ((distDependencies.map(products in Runtime in _) :+ mkBin): _* ),
381
417
mkPack <<= Def .task {} dependsOn (packageBin in Compile , mkBin),
382
418
target := (baseDirectory in ThisBuild ).value / " target" / thisProject.value.id,
383
419
packageBin in Compile := {
@@ -438,59 +474,10 @@ def configureAsForkOfJavaProject(project: Project): Project = {
438
474
}
439
475
440
476
lazy val buildDirectory = settingKey[File ](" The directory where all build products go. By default ./build" )
441
- lazy val copyrightString = settingKey[String ](" Copyright string." )
442
- lazy val generateVersionPropertiesFile = taskKey[File ](" Generating version properties file." )
443
477
lazy val mkBin = taskKey[Seq [File ]](" Generate shell script (bash or Windows batch)." )
444
478
lazy val mkQuick = taskKey[Unit ](" Generate a full build, including scripts, in build-sbt/quick" )
445
479
lazy val mkPack = taskKey[Unit ](" Generate a full build, including scripts, in build-sbt/pack" )
446
480
447
- lazy val generateVersionPropertiesFileImpl : Def .Initialize [Task [File ]] = Def .task {
448
- val propFile = (resourceManaged in Compile ).value / s " ${thisProject.value.id}.properties "
449
- val props = new java.util.Properties
450
-
451
- /**
452
- * Regexp that splits version number split into two parts: version and suffix.
453
- * Examples of how the split is performed:
454
- *
455
- * "2.11.5": ("2.11.5", null)
456
- * "2.11.5-acda7a": ("2.11.5", "-acda7a")
457
- * "2.11.5-SNAPSHOT": ("2.11.5", "-SNAPSHOT")
458
- *
459
- */
460
- val versionSplitted = """ ([\w+\.]+)(-[\w+\.]+)??""" .r
461
-
462
- val versionSplitted(ver, suffixOrNull) = version.value
463
- val osgiSuffix = suffixOrNull match {
464
- case null => " -VFINAL"
465
- case " -SNAPSHOT" => " "
466
- case suffixStr => suffixStr
467
- }
468
-
469
- def executeTool (tool : String ) = {
470
- val cmd =
471
- if (System .getProperty(" os.name" ).toLowerCase.contains(" windows" ))
472
- s " cmd.exe /c tools \\ $tool.bat -p "
473
- else s " tools/ $tool"
474
- Process (cmd).lines.head
475
- }
476
-
477
- val commitDate = executeTool(" get-scala-commit-date" )
478
- val commitSha = executeTool(" get-scala-commit-sha" )
479
-
480
- props.put(" version.number" , s " ${version.value}- $commitDate- $commitSha" )
481
- props.put(" maven.version.number" , s " ${version.value}" )
482
- props.put(" osgi.version.number" , s " $ver.v $commitDate$osgiSuffix- $commitSha" )
483
- props.put(" copyright.string" , copyrightString.value)
484
-
485
- // unfortunately, this will write properties in arbitrary order
486
- // this makes it harder to test for stability of generated artifacts
487
- // consider using https://github.com/etiennestuder/java-ordered-properties
488
- // instead of java.util.Properties
489
- IO .write(props, null , propFile)
490
-
491
- propFile
492
- }
493
-
494
481
/**
495
482
* Extract selected dependencies to the `cacheDirectory` and return a mapping for the content.
496
483
* Heavily inspired by sbt-assembly (https://github.com/sbt/sbt-assembly/blob/0.13.0/src/main/scala/sbtassembly/Assembly.scala#L157)
@@ -582,17 +569,3 @@ lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
582
569
}
583
570
584
571
buildDirectory in ThisBuild := (baseDirectory in ThisBuild ).value / " build-sbt"
585
-
586
- lazy val versionProps : Map [String , String ] = {
587
- import java .io .FileInputStream
588
- import java .util .Properties
589
- val props = new Properties ()
590
- val in = new FileInputStream (file(" versions.properties" ))
591
- try props.load(in)
592
- finally in.close()
593
- import scala .collection .JavaConverters ._
594
- props.asScala.toMap
595
- }
596
-
597
- def versionNumber (name : String ): String =
598
- versionProps(s " $name.version.number " )
0 commit comments