summaryrefslogtreecommitdiff
path: root/build.sbt
diff options
context:
space:
mode:
authorStefan Zeiger <szeiger@novocode.com>2015-11-11 14:55:02 +0100
committerStefan Zeiger <szeiger@novocode.com>2015-11-26 14:24:36 +0100
commit21be6697e61402ca2a80a7e997db68fd126e97d9 (patch)
tree9d77452c27370234b6a5208e159da2f69ad93395 /build.sbt
parent2ef93ad2fe29766fbe09a3e921ad361b25abdeaf (diff)
downloadscala-21be6697e61402ca2a80a7e997db68fd126e97d9.tar.gz
scala-21be6697e61402ca2a80a7e997db68fd126e97d9.tar.bz2
scala-21be6697e61402ca2a80a7e997db68fd126e97d9.zip
Build man pages and scala-dist.jar from sbt
- ManMaker is compiled in a new subproject “manual”. A simple command line runner complements the ant task so that it can be run from sbt. - Another new subproject “scala-dist” is responsible for building the scala-dist.jar artifact. Conflicts: build.sbt
Diffstat (limited to 'build.sbt')
-rw-r--r--build.sbt46
1 files changed, 46 insertions, 0 deletions
diff --git a/build.sbt b/build.sbt
index ef20a68add..4faabc5c6e 100644
--- a/build.sbt
+++ b/build.sbt
@@ -378,6 +378,52 @@ lazy val test = project.
)
)
+lazy val manual = configureAsSubproject(project)
+ .settings(
+ libraryDependencies ++= Seq(scalaXmlDep, antDep),
+ classDirectory in Compile := (target in Compile).value / "classes"
+ )
+ .settings(disableDocsAndPublishingTasks: _*)
+ .dependsOn(library)
+
+lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-dist-src-dummy")
+ .settings(commonSettings: _*)
+ .settings(
+ doc := file("!!! NO DOCS !!!"),
+ mappings in Compile in packageBin ++= {
+ val binBaseDir = buildDirectory.value / "pack"
+ val binMappings = (mkBin in dist).value.pair(relativeTo(binBaseDir), errorIfNone = false)
+ // With the way the resource files are spread out over the project sources we can't just add
+ // an unmanagedResourceDirectory, so we generate the mappings manually:
+ val docBaseDir = (baseDirectory in ThisBuild).value
+ val docMappings = (docBaseDir / "doc").*** pair relativeTo(docBaseDir)
+ val resBaseDir = (baseDirectory in ThisBuild).value / "src/manual/scala/tools/docutil/resources"
+ val resMappings = resBaseDir ** ("*.html" | "*.css" | "*.gif" | "*.png") pair (p => relativeTo(resBaseDir)(p).map("doc/tools/" + _))
+ docMappings ++ resMappings ++ binMappings
+ },
+ resourceGenerators in Compile += Def.task {
+ val command = "fsc, scala, scalac, scaladoc, scalap"
+ val htmlOut = (resourceManaged in Compile).value / "doc/tools"
+ val manOut = (resourceManaged in Compile).value / "genman"
+ val fixedManOut = (resourceManaged in Compile).value / "man"
+ IO.createDirectory(htmlOut)
+ IO.createDirectory(manOut / "man1")
+ toError(runner.value.run("scala.tools.docutil.ManMaker",
+ (fullClasspath in Compile in manual).value.files,
+ Seq(command, htmlOut.getAbsolutePath, manOut.getAbsolutePath),
+ streams.value.log))
+ (manOut ** "*.1" pair rebase(manOut, fixedManOut)).foreach { case (in, out) =>
+ // Generated manpages should always use LF only. There doesn't seem to be a good reason
+ // for generating them with the platform EOL first and then converting them but that's
+ // what the ant build does.
+ IO.write(out, IO.readBytes(in).filterNot(_ == '\r'))
+ }
+ (htmlOut ** "*.html").get ++ (fixedManOut ** "*.1").get
+ }.taskValue,
+ managedResourceDirectories in Compile := Seq((resourceManaged in Compile).value),
+ packageOptions in Compile in packageBin := Seq.empty
+ )
+
lazy val root = (project in file(".")).
aggregate(library, reflect, compiler, interactive, repl, replJline, replJlineEmbedded,
scaladoc, scalap, partestExtras, junit).settings(