Skip to content

Commit 37585f9

Browse files
committed
Package interactive and scaladoc into compiler jar.
Ant build puts class files for interactive and scaladoc into compiler jar. We mirror that behavior by disabling docs and publishing tasks in interactive and scaladoc subprojects. We include class files generated by those two projects in compiler by merging `mappings` tasks. Mappings is what package tasks uses to determine which class files should end up in a jar file.
1 parent 75ea803 commit 37585f9

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

build.sbt

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ lazy val commonSettings = Seq[Setting[_]](
8484
cleanFiles += (classDirectory in Compile).value
8585
)
8686

87+
// disable various tasks that are not needed for projects that are used
88+
// only for compiling code and not publishing it as a standalone artifact
89+
// we disable those tasks by overriding them and returning bogus files when
90+
// needed. This is a bit sketchy but I haven't found any better way.
91+
val disableDocsAndPublishingTasks = Seq[Setting[_]](
92+
(doc := file("!!! NO DOCS !!!")),
93+
(publishLocal := {}),
94+
(publish := {}),
95+
(packageBin in Compile := file("!!! NO PACKAGING !!!"))
96+
)
97+
8798
lazy val scalaSubprojectSettings = commonSettings ++ Seq[Setting[_]](
8899
artifactPath in packageBin in Compile := {
89100
// two lines below are copied over from sbt's sources:
@@ -121,16 +132,26 @@ lazy val reflect = configureAsSubproject(project).
121132
dependsOn(library)
122133

123134
lazy val compiler = configureAsSubproject(project).
124-
settings(libraryDependencies += "org.apache.ant" % "ant" % "1.9.4").
135+
settings(libraryDependencies += "org.apache.ant" % "ant" % "1.9.4",
136+
// this a way to make sure that classes from interactive and scaladoc projects
137+
// end up in compiler jar (that's what Ant build does)
138+
// we need to use LocalProject references (with strings) to deal with mutual recursion
139+
mappings in Compile in packageBin :=
140+
(mappings in Compile in packageBin).value ++
141+
(mappings in Compile in packageBin in LocalProject("interactive")).value ++
142+
(mappings in Compile in packageBin in LocalProject("scaladoc")).value
143+
).
125144
dependsOn(library, reflect, asm)
126145

127146
lazy val interactive = configureAsSubproject(project).
147+
settings(disableDocsAndPublishingTasks: _*).
128148
dependsOn(compiler)
129149

130150
lazy val repl = configureAsSubproject(project).
131151
// TODO: in Ant build def, this version is defined in versions.properties
132152
// figure out whether we also want to externalize jline's version
133153
settings(libraryDependencies += "jline" % "jline" % "2.12").
154+
settings(disableDocsAndPublishingTasks: _*).
134155
dependsOn(compiler)
135156

136157
lazy val scaladoc = configureAsSubproject(project).
@@ -141,6 +162,7 @@ lazy val scaladoc = configureAsSubproject(project).
141162
"org.scala-lang.modules" %% "scala-partest" % "1.0.5"
142163
)
143164
).
165+
settings(disableDocsAndPublishingTasks: _*).
144166
dependsOn(compiler)
145167

146168
lazy val scalap = configureAsSubproject(project).
@@ -192,18 +214,9 @@ def configureAsSubproject(project: Project): Project = {
192214
*/
193215
def configureAsForkOfJavaProject(project: Project): Project = {
194216
val base = file(".") / "src" / project.id
195-
// disable various tasks that do not make sense for forks of Java projects
196-
// we disable those task by overriding them and returning bogus files when
197-
// needed. This is a bit sketchy but I haven't found any better way.
198-
val disableTasks = Seq[Setting[_]](
199-
(doc := file("!!! NO DOCS !!!")),
200-
(publishLocal := {}),
201-
(publish := {}),
202-
(packageBin in Compile := file("!!! NO PACKAGING !!!"))
203-
)
204217
(project in base).
205218
settings(commonSettings: _*).
206-
settings(disableTasks: _*).
219+
settings(disableDocsAndPublishingTasks: _*).
207220
settings(
208221
sourceDirectory in Compile := baseDirectory.value,
209222
javaSource in Compile := (sourceDirectory in Compile).value,

0 commit comments

Comments
 (0)