@@ -88,7 +88,7 @@ lazy val publishSettings : Seq[Setting[_]] = Seq(
88
88
val mappings = artifacts.toSeq.map { case (a, f) =>
89
89
val typeSuffix = a.`type` match {
90
90
case " pom" => " -pom.xml"
91
- case " bundle " | " jar" => " .jar"
91
+ case " jar" => " .jar"
92
92
case " doc" => " -docs.jar"
93
93
case tpe => s " - $tpe. ${a.extension}"
94
94
}
@@ -103,6 +103,8 @@ lazy val publishSettings : Seq[Setting[_]] = Seq(
103
103
if (file.exists) List (Credentials (file))
104
104
else Nil
105
105
},
106
+ // Add a "default" Ivy configuration because sbt expects the Scala distribution to have one:
107
+ ivyConfigurations += Configuration (" default" , " Default" , true , List (Configurations .Runtime ), true ),
106
108
publishMavenStyle := true
107
109
)
108
110
@@ -240,8 +242,8 @@ def fixPom(extra: (String, scala.xml.Node)*): Setting[_] = {
240
242
) ++ extra) }
241
243
}
242
244
243
- /** Remove unwanted dependencies from the POM. */
244
- def removePomDependencies (deps : (String , String )* ): Setting [_] = {
245
+ /** Remove unwanted dependencies from the POM and ivy.xml . */
246
+ def removePomDependencies (deps : (String , String )* ): Seq [ Setting [_]] = Seq (
245
247
pomPostProcess := { n =>
246
248
val n2 = pomPostProcess.value.apply(n)
247
249
import scala .xml ._
@@ -256,14 +258,40 @@ def removePomDependencies(deps: (String, String)*): Setting[_] = {
256
258
case n => Seq (n)
257
259
}
258
260
})).transform(Seq (n2)).head
261
+ },
262
+ deliverLocal := {
263
+ import scala .xml ._
264
+ import scala .xml .transform ._
265
+ val f = deliverLocal.value
266
+ val e = (new RuleTransformer (new RewriteRule {
267
+ override def transform (node : Node ) = node match {
268
+ case e : Elem if e.label == " dependency" && {
269
+ val org = e.attribute(" org" ).getOrElse(" " ).toString
270
+ val name = e.attribute(" name" ).getOrElse(" " ).toString
271
+ deps.exists { case (g, a) =>
272
+ org == g && (name == a || name == (a + " _" + scalaBinaryVersion.value))
273
+ }
274
+ } => Seq .empty
275
+ case n => Seq (n)
276
+ }
277
+ })).transform(Seq (XML .loadFile(f))).head
278
+ XML .save(f.getAbsolutePath, e, xmlDecl = true )
279
+ f
259
280
}
260
- }
281
+ )
261
282
262
283
val disableDocs = Seq [Setting [_]](
263
284
sources in (Compile , doc) := Seq .empty,
264
285
publishArtifact in (Compile , packageDoc) := false
265
286
)
266
287
288
+ val disablePublishing = Seq [Setting [_]](
289
+ publishArtifact := false ,
290
+ // The above is enough for Maven repos but it doesn't prevent publishing of ivy.xml files
291
+ publish := {},
292
+ publishLocal := {}
293
+ )
294
+
267
295
lazy val setJarLocation : Setting [_] =
268
296
artifactPath in packageBin in Compile := {
269
297
// two lines below are copied over from sbt's sources:
@@ -325,10 +353,10 @@ lazy val library = configureAsSubproject(project)
325
353
" /project/name" -> <name >Scala Library </name >,
326
354
" /project/description" -> <description >Standard library for the Scala Programming Language </description >,
327
355
" /project/packaging" -> <packaging >jar</packaging >
328
- ),
329
- // Remove the dependency on "forkjoin" from the POM because it is included in the JAR:
330
- removePomDependencies((" org.scala-lang" , " forkjoin" ))
356
+ )
331
357
)
358
+ // Remove the dependency on "forkjoin" from the POM because it is included in the JAR:
359
+ .settings(removePomDependencies((" org.scala-lang" , " forkjoin" )): _* )
332
360
.settings(filterDocSources(" *.scala" -- (regexFileFilter(" .*/runtime/.*\\ $\\ .scala" ) ||
333
361
regexFileFilter(" .*/runtime/ScalaRunTime\\ .scala" ) ||
334
362
regexFileFilter(" .*/runtime/StringAdd\\ .scala" ))): _* )
@@ -406,43 +434,44 @@ lazy val compiler = configureAsSubproject(project)
406
434
" /project/description" -> <description >Compiler for the Scala Programming Language </description >,
407
435
" /project/packaging" -> <packaging >jar</packaging >
408
436
),
409
- apiURL := None ,
410
- removePomDependencies(
411
- (" org.apache.ant" , " ant" ),
412
- (" org.scala-lang.modules" , " scala-asm" )
413
- )
437
+ apiURL := None
414
438
)
439
+ .settings(removePomDependencies(
440
+ (" org.apache.ant" , " ant" ),
441
+ (" org.scala-lang.modules" , " scala-asm" )
442
+ ): _* )
415
443
.dependsOn(library, reflect)
416
444
417
445
lazy val interactive = configureAsSubproject(project)
418
446
.settings(disableDocs : _* )
447
+ .settings(disablePublishing : _* )
419
448
.settings(
420
449
name := " scala-compiler-interactive" ,
421
- description := " Scala Interactive Compiler" ,
422
- publishArtifact := false
450
+ description := " Scala Interactive Compiler"
423
451
)
424
452
.dependsOn(compiler)
425
453
426
454
lazy val repl = configureAsSubproject(project)
427
455
.settings(disableDocs : _* )
456
+ .settings(disablePublishing : _* )
428
457
.settings(
429
458
connectInput in run := true ,
430
- publishArtifact := false ,
431
459
run <<= (run in Compile ).partialInput(" -usejavacp" ) // Automatically add this so that `repl/run` works without additional arguments.
432
460
)
433
461
.dependsOn(compiler, interactive)
434
462
435
463
lazy val replJline = configureAsSubproject(Project (" repl-jline" , file(" ." ) / " src" / " repl-jline" ))
436
464
.settings(disableDocs : _* )
465
+ .settings(disablePublishing : _* )
437
466
.settings(
438
467
libraryDependencies += jlineDep,
439
- name := " scala-repl-jline" ,
440
- publishArtifact := false
468
+ name := " scala-repl-jline"
441
469
)
442
470
.dependsOn(repl)
443
471
444
472
lazy val replJlineEmbedded = Project (" repl-jline-embedded" , file(" ." ) / " target" / " repl-jline-embedded-src-dummy" )
445
473
.settings(scalaSubprojectSettings : _* )
474
+ .settings(disablePublishing : _* )
446
475
.settings(
447
476
name := " scala-repl-jline-embedded" ,
448
477
// There is nothing to compile for this project. Instead we use the compile task to create
@@ -473,18 +502,17 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target"
473
502
val outdir = (classDirectory in Compile ).value
474
503
JarJar (inputs, outdir, config)
475
504
}),
476
- publishArtifact := false ,
477
505
connectInput in run := true
478
506
)
479
507
.dependsOn(replJline)
480
508
481
509
lazy val scaladoc = configureAsSubproject(project)
482
510
.settings(disableDocs : _* )
511
+ .settings(disablePublishing : _* )
483
512
.settings(
484
513
name := " scala-compiler-doc" ,
485
514
description := " Scala Documentation Generator" ,
486
515
libraryDependencies ++= Seq (scalaXmlDep, scalaParserCombinatorsDep, partestDep),
487
- publishArtifact := false ,
488
516
includeFilter in unmanagedResources in Compile := " *.html" | " *.css" | " *.gif" | " *.png" | " *.js" | " *.txt"
489
517
)
490
518
.dependsOn(compiler)
@@ -526,10 +554,10 @@ lazy val partestExtras = configureAsSubproject(Project("partest-extras", file(".
526
554
.dependsOn(replJlineEmbedded)
527
555
.settings(clearSourceAndResourceDirectories : _* )
528
556
.settings(disableDocs : _* )
557
+ .settings(disablePublishing : _* )
529
558
.settings(
530
559
name := " scala-partest-extras" ,
531
560
description := " Scala Compiler Testing Tool (compiler-specific extras)" ,
532
- publishArtifact := false ,
533
561
libraryDependencies += partestDep,
534
562
unmanagedSourceDirectories in Compile := List (baseDirectory.value)
535
563
)
@@ -539,8 +567,8 @@ lazy val junit = project.in(file("test") / "junit")
539
567
.settings(clearSourceAndResourceDirectories : _* )
540
568
.settings(commonSettings : _* )
541
569
.settings(disableDocs : _* )
570
+ .settings(disablePublishing : _* )
542
571
.settings(
543
- publishArtifact := false ,
544
572
fork in Test := true ,
545
573
libraryDependencies ++= Seq (junitDep, junitIntefaceDep),
546
574
testOptions += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" ),
@@ -572,9 +600,9 @@ lazy val test = project
572
600
.configs(IntegrationTest )
573
601
.settings(commonSettings : _* )
574
602
.settings(disableDocs : _* )
603
+ .settings(disablePublishing : _* )
575
604
.settings(Defaults .itSettings: _* )
576
605
.settings(
577
- publishArtifact := false ,
578
606
libraryDependencies ++= Seq (asmDep, partestDep, scalaXmlDep, scalacheckDep),
579
607
unmanagedBase in IntegrationTest := baseDirectory.value / " files" / " lib" ,
580
608
unmanagedJars in IntegrationTest <+= (unmanagedBase) (j => Attributed .blank(j)) map(identity),
@@ -601,8 +629,8 @@ lazy val test = project
601
629
602
630
lazy val manual = configureAsSubproject(project)
603
631
.settings(disableDocs : _* )
632
+ .settings(disablePublishing : _* )
604
633
.settings(
605
- publishArtifact := false ,
606
634
libraryDependencies ++= Seq (scalaXmlDep, antDep),
607
635
classDirectory in Compile := (target in Compile ).value / " classes"
608
636
)
@@ -672,9 +700,9 @@ lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-di
672
700
673
701
lazy val root = (project in file(" ." ))
674
702
.settings(disableDocs : _* )
703
+ .settings(disablePublishing : _* )
675
704
.settings(generateBuildCharacterFileSettings : _* )
676
705
.settings(
677
- publishArtifact := false ,
678
706
publish := {},
679
707
publishLocal := {},
680
708
commands ++= ScriptCommands .all
@@ -756,8 +784,8 @@ def configureAsForkOfJavaProject(project: Project): Project = {
756
784
(project in base)
757
785
.settings(commonSettings : _* )
758
786
.settings(disableDocs : _* )
787
+ .settings(disablePublishing : _* )
759
788
.settings(
760
- publishArtifact := false ,
761
789
sourceDirectory in Compile := baseDirectory.value,
762
790
javaSource in Compile := (sourceDirectory in Compile ).value,
763
791
sources in Compile in doc := Seq .empty,
0 commit comments