From 03607b219aa854c3d36ae572d2ac6fca8a1bd29e Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 11 Nov 2015 14:55:02 +0100 Subject: [nomerge] Build man pages and scala-dist.jar from sbt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- build.sbt | 48 ++++++++++++++++++++++++++- src/manual/scala/tools/docutil/ManMaker.scala | 10 ++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6540d0b9c0..aaf79888d8 100644 --- a/build.sbt +++ b/build.sbt @@ -185,7 +185,7 @@ lazy val library = configureAsSubproject(project) includeFilter in unmanagedResources in Compile := "*.tmpl" | "*.xml" | "*.js" | "*.css" | "rootdoc.txt", // Include forkjoin classes in scala-library.jar mappings in Compile in packageBin ++= - (mappings in Compile in packageBin in LocalProject("forkjoin")).value + (mappings in Compile in packageBin in forkjoin).value ) .settings(filterDocSources("*.scala" -- (regexFileFilter(".*/runtime/.*\\$\\.scala") || regexFileFilter(".*/runtime/ScalaRunTime\\.scala") || @@ -395,6 +395,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, forkjoin, reflect, compiler, interactive, repl, replJline, replJlineEmbedded, scaladoc, scalap, actors, 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() +} -- cgit v1.2.3