Skip to content

Commit 332748a

Browse files
committed
Add a hook to the build to disable doc publishing and genjavadoc
Handy when varying other build parameters, such as `scalaVersion`, results in unavailabilty of genjavadoc or in a Scaladoc bug.
1 parent fd4eb69 commit 332748a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

build.sbt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ initialize := {
6969
sys.error("Java 8 or higher is required for this project.")
7070
}
7171

72+
val disableDocs = sys.props("nodocs") == "true"
73+
74+
publishArtifact in packageDoc := !disableDocs
75+
7276
lazy val JavaDoc = config("genjavadoc") extend Compile
7377

7478
sources in (Compile, doc) := {
7579
val orig = (sources in (Compile, doc)).value
7680
orig.filterNot(_.getName.endsWith(".java")) // raw types not cooked by scaladoc: https://issues.scala-lang.org/browse/SI-8449
7781
}
7882

79-
inConfig(JavaDoc)(Defaults.configSettings) ++ Seq(
83+
inConfig(JavaDoc)(Defaults.configSettings) ++ (if (disableDocs) Nil else Seq(
8084
packageDoc in Compile <<= packageDoc in JavaDoc,
8185
sources in JavaDoc <<= (target, compile in Compile, sources in Compile) map {(t, c, s) =>
8286
val allJavaSources = (t / "java" ** "*.java").get ++ s.filter(_.getName.endsWith(".java"))
@@ -86,7 +90,7 @@ inConfig(JavaDoc)(Defaults.configSettings) ++ Seq(
8690
artifactName in packageDoc in JavaDoc := ((sv, mod, art) => "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar"),
8791
libraryDependencies += compilerPlugin("com.typesafe.genjavadoc" % "genjavadoc-plugin" % "0.8" cross CrossVersion.full),
8892
scalacOptions in Compile <+= target map (t => "-P:genjavadoc:out=" + (t / "java"))
89-
)
93+
))
9094

9195
initialCommands :=
9296
"""|import scala.concurrent._

0 commit comments

Comments
 (0)