@@ -88,7 +88,7 @@ lazy val publishSettings : Seq[Setting[_]] = Seq(
8888 val mappings = artifacts.toSeq.map { case (a, f) =>
8989 val typeSuffix = a.`type` match {
9090 case " pom" => " -pom.xml"
91- case " bundle " | " jar" => " .jar"
91+ case " jar" => " .jar"
9292 case " doc" => " -docs.jar"
9393 case tpe => s " - $tpe. ${a.extension}"
9494 }
@@ -103,6 +103,8 @@ lazy val publishSettings : Seq[Setting[_]] = Seq(
103103 if (file.exists) List (Credentials (file))
104104 else Nil
105105 },
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 ),
106108 publishMavenStyle := true
107109)
108110
@@ -240,8 +242,8 @@ def fixPom(extra: (String, scala.xml.Node)*): Setting[_] = {
240242 ) ++ extra) }
241243}
242244
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 (
245247 pomPostProcess := { n =>
246248 val n2 = pomPostProcess.value.apply(n)
247249 import scala .xml ._
@@ -256,14 +258,40 @@ def removePomDependencies(deps: (String, String)*): Setting[_] = {
256258 case n => Seq (n)
257259 }
258260 })).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
259280 }
260- }
281+ )
261282
262283val disableDocs = Seq [Setting [_]](
263284 sources in (Compile , doc) := Seq .empty,
264285 publishArtifact in (Compile , packageDoc) := false
265286)
266287
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+
267295lazy val setJarLocation : Setting [_] =
268296 artifactPath in packageBin in Compile := {
269297 // two lines below are copied over from sbt's sources:
@@ -325,10 +353,10 @@ lazy val library = configureAsSubproject(project)
325353 " /project/name" -> <name >Scala Library </name >,
326354 " /project/description" -> <description >Standard library for the Scala Programming Language </description >,
327355 " /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+ )
331357 )
358+ // Remove the dependency on "forkjoin" from the POM because it is included in the JAR:
359+ .settings(removePomDependencies((" org.scala-lang" , " forkjoin" )): _* )
332360 .settings(filterDocSources(" *.scala" -- (regexFileFilter(" .*/runtime/.*\\ $\\ .scala" ) ||
333361 regexFileFilter(" .*/runtime/ScalaRunTime\\ .scala" ) ||
334362 regexFileFilter(" .*/runtime/StringAdd\\ .scala" ))): _* )
@@ -406,43 +434,44 @@ lazy val compiler = configureAsSubproject(project)
406434 " /project/description" -> <description >Compiler for the Scala Programming Language </description >,
407435 " /project/packaging" -> <packaging >jar</packaging >
408436 ),
409- apiURL := None ,
410- removePomDependencies(
411- (" org.apache.ant" , " ant" ),
412- (" org.scala-lang.modules" , " scala-asm" )
413- )
437+ apiURL := None
414438 )
439+ .settings(removePomDependencies(
440+ (" org.apache.ant" , " ant" ),
441+ (" org.scala-lang.modules" , " scala-asm" )
442+ ): _* )
415443 .dependsOn(library, reflect)
416444
417445lazy val interactive = configureAsSubproject(project)
418446 .settings(disableDocs : _* )
447+ .settings(disablePublishing : _* )
419448 .settings(
420449 name := " scala-compiler-interactive" ,
421- description := " Scala Interactive Compiler" ,
422- publishArtifact := false
450+ description := " Scala Interactive Compiler"
423451 )
424452 .dependsOn(compiler)
425453
426454lazy val repl = configureAsSubproject(project)
427455 .settings(disableDocs : _* )
456+ .settings(disablePublishing : _* )
428457 .settings(
429458 connectInput in run := true ,
430- publishArtifact := false ,
431459 run <<= (run in Compile ).partialInput(" -usejavacp" ) // Automatically add this so that `repl/run` works without additional arguments.
432460 )
433461 .dependsOn(compiler, interactive)
434462
435463lazy val replJline = configureAsSubproject(Project (" repl-jline" , file(" ." ) / " src" / " repl-jline" ))
436464 .settings(disableDocs : _* )
465+ .settings(disablePublishing : _* )
437466 .settings(
438467 libraryDependencies += jlineDep,
439- name := " scala-repl-jline" ,
440- publishArtifact := false
468+ name := " scala-repl-jline"
441469 )
442470 .dependsOn(repl)
443471
444472lazy val replJlineEmbedded = Project (" repl-jline-embedded" , file(" ." ) / " target" / " repl-jline-embedded-src-dummy" )
445473 .settings(scalaSubprojectSettings : _* )
474+ .settings(disablePublishing : _* )
446475 .settings(
447476 name := " scala-repl-jline-embedded" ,
448477 // 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"
473502 val outdir = (classDirectory in Compile ).value
474503 JarJar (inputs, outdir, config)
475504 }),
476- publishArtifact := false ,
477505 connectInput in run := true
478506 )
479507 .dependsOn(replJline)
480508
481509lazy val scaladoc = configureAsSubproject(project)
482510 .settings(disableDocs : _* )
511+ .settings(disablePublishing : _* )
483512 .settings(
484513 name := " scala-compiler-doc" ,
485514 description := " Scala Documentation Generator" ,
486515 libraryDependencies ++= Seq (scalaXmlDep, scalaParserCombinatorsDep, partestDep),
487- publishArtifact := false ,
488516 includeFilter in unmanagedResources in Compile := " *.html" | " *.css" | " *.gif" | " *.png" | " *.js" | " *.txt"
489517 )
490518 .dependsOn(compiler)
@@ -526,10 +554,10 @@ lazy val partestExtras = configureAsSubproject(Project("partest-extras", file(".
526554 .dependsOn(replJlineEmbedded)
527555 .settings(clearSourceAndResourceDirectories : _* )
528556 .settings(disableDocs : _* )
557+ .settings(disablePublishing : _* )
529558 .settings(
530559 name := " scala-partest-extras" ,
531560 description := " Scala Compiler Testing Tool (compiler-specific extras)" ,
532- publishArtifact := false ,
533561 libraryDependencies += partestDep,
534562 unmanagedSourceDirectories in Compile := List (baseDirectory.value)
535563 )
@@ -539,8 +567,8 @@ lazy val junit = project.in(file("test") / "junit")
539567 .settings(clearSourceAndResourceDirectories : _* )
540568 .settings(commonSettings : _* )
541569 .settings(disableDocs : _* )
570+ .settings(disablePublishing : _* )
542571 .settings(
543- publishArtifact := false ,
544572 fork in Test := true ,
545573 libraryDependencies ++= Seq (junitDep, junitIntefaceDep),
546574 testOptions += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" ),
@@ -572,9 +600,9 @@ lazy val test = project
572600 .configs(IntegrationTest )
573601 .settings(commonSettings : _* )
574602 .settings(disableDocs : _* )
603+ .settings(disablePublishing : _* )
575604 .settings(Defaults .itSettings: _* )
576605 .settings(
577- publishArtifact := false ,
578606 libraryDependencies ++= Seq (asmDep, partestDep, scalaXmlDep, scalacheckDep),
579607 unmanagedBase in IntegrationTest := baseDirectory.value / " files" / " lib" ,
580608 unmanagedJars in IntegrationTest <+= (unmanagedBase) (j => Attributed .blank(j)) map(identity),
@@ -601,8 +629,8 @@ lazy val test = project
601629
602630lazy val manual = configureAsSubproject(project)
603631 .settings(disableDocs : _* )
632+ .settings(disablePublishing : _* )
604633 .settings(
605- publishArtifact := false ,
606634 libraryDependencies ++= Seq (scalaXmlDep, antDep),
607635 classDirectory in Compile := (target in Compile ).value / " classes"
608636 )
@@ -672,9 +700,9 @@ lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-di
672700
673701lazy val root = (project in file(" ." ))
674702 .settings(disableDocs : _* )
703+ .settings(disablePublishing : _* )
675704 .settings(generateBuildCharacterFileSettings : _* )
676705 .settings(
677- publishArtifact := false ,
678706 publish := {},
679707 publishLocal := {},
680708 commands ++= ScriptCommands .all
@@ -756,8 +784,8 @@ def configureAsForkOfJavaProject(project: Project): Project = {
756784 (project in base)
757785 .settings(commonSettings : _* )
758786 .settings(disableDocs : _* )
787+ .settings(disablePublishing : _* )
759788 .settings(
760- publishArtifact := false ,
761789 sourceDirectory in Compile := baseDirectory.value,
762790 javaSource in Compile := (sourceDirectory in Compile ).value,
763791 sources in Compile in doc := Seq .empty,
0 commit comments