diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2015-11-11 14:55:02 +0100 |
---|---|---|
committer | Stefan Zeiger <szeiger@novocode.com> | 2015-11-26 14:24:36 +0100 |
commit | 21be6697e61402ca2a80a7e997db68fd126e97d9 (patch) | |
tree | 9d77452c27370234b6a5208e159da2f69ad93395 | |
parent | 2ef93ad2fe29766fbe09a3e921ad361b25abdeaf (diff) | |
download | scala-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
-rw-r--r-- | build.sbt | 46 | ||||
-rw-r--r-- | src/manual/scala/tools/docutil/ManMaker.scala | 10 |
2 files changed, 56 insertions, 0 deletions
@@ -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( diff --git a/src/manual/scala/tools/docutil/ManMaker.scala b/src/manual/scala/tools/docutil/ManMaker.scala index 802b357f5f..4b8bfc6606 100644 --- a/src/manual/scala/tools/docutil/ManMaker.scala +++ b/src/manual/scala/tools/docutil/ManMaker.scala @@ -57,3 +57,13 @@ class ManMaker extends Task { }) } } + +/** Command line runner for ManMaker which is called from the sbt build. */ +object ManMaker extends App { + val Array(commands, htmlout, manout) = args + val mm = new ManMaker + mm.setCommand(commands) + mm.setHtmlout(new File(htmlout)) + mm.setManout(new File(manout)) + mm.execute() +} |