sbt/sbt-unidoc

How to publish only the unidoc (aggregating) project

Sciss opened this issue · 4 comments

Sciss commented

For example, my build file

val baseName = "ScalaCollider"
val baseNameL = baseName.toLowerCase

val PROJECT_VERSION           = "1.27.0"
val scalaColliderSwingVersion = "1.39.0"
val ugensVersion              = "1.19.0"
val audioFileVersion          = "1.5.0"
val oscVersion                = "1.1.6"

val lOSC                = RootProject(uri(s"git://github.com/Sciss/ScalaOSC.git#v$oscVersion"))
val lAudioFile          = RootProject(uri(s"git://github.com/Sciss/AudioFile.git#v$audioFileVersion"))
val lUGens              = RootProject(uri(s"git://github.com/Sciss/ScalaColliderUGens.git#v$ugensVersion"))
val lScalaCollider      = RootProject(uri(s"git://github.com/Sciss/$baseName.git#v${PROJECT_VERSION}"))
val lScalaColliderSwing = RootProject(uri(s"git://github.com/Sciss/ScalaColliderSwing.git#v$scalaColliderSwingVersion"))

scalaVersion in ThisBuild := "2.12.8"

val root = project.withId(s"$baseNameL-unidoc").in(file("."))
  .enablePlugins(ScalaUnidocPlugin)
  .settings(
    name                 := s"$baseName-unidoc",
    version              := PROJECT_VERSION,
    organization         := "de.sciss",
    mappings in packageDoc in Compile := (mappings  in (ScalaUnidoc, packageDoc)).value,
    scalacOptions in (Compile, doc) ++= Seq(
      "-skip-packages", Seq(
        "de.sciss.osc.impl", 
        "de.sciss.synth.impl",
        "snippets"
      ).mkString(":"),
      "-doc-title", s"${baseName} ${PROJECT_VERSION} API"
    ),
    publishArtifact in (Compile, packageBin) := false, // there are no binaries
    publishArtifact in (Compile, packageSrc) := false  // there are no sources
  )
  .aggregate(/* lOSC, lAudioFile, */ lUGens, lScalaCollider, lScalaColliderSwing)

What I want to do is publish the javadoc.jar of the unified docs. But if I run sbt scalacollider-unidoc/publishLocal, sbt attempts to also publish all the dependencies, e.g.

[info] Wrote /home/hhrutz/.sbt/1.0/staging/7a469ac4827c285b0be5/scalacolliderugens/spec/target/scalacolliderugens-spec-1.19.0.pom
[info] Wrote /home/hhrutz/.sbt/1.0/staging/7a469ac4827c285b0be5/scalacolliderugens/api/target/scala-2.12/scalacolliderugens-api_2.12-1.19.0.pom
[info] Done updating.
[info] Wrote /home/hhrutz/.sbt/1.0/staging/46c805c0efc1cd242273/scalacolliderswing/core/target/scala-2.12/scalacolliderswing-core_2.12-1.39.0.pom
[info] :: delivering :: de.sciss#scalacolliderugens_2.12;1.19.0 :: 1.19.0 :: release :: Mon Jan 14 01:08:38 CET 2019
[info] 	delivering ivy file to /home/hhrutz/.sbt/1.0/staging/7a469ac4827c285b0be5/scalacolliderugens/target/scala-2.12/ivy-1.19.0.xml
[info] Wrote /data/temp/unidoc-test/target/scala-2.12/scalacollider-unidoc_2.12-1.27.0.pom
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/scalacolliderugens_2.12/1.19.0/ivys/ivy.xml (non-SNAPSHOT)
[warn] 	You need to remove it from the cache manually to take effect.
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/scalacolliderugens_2.12/1.19.0/ivys/ivy.xml.sha1 (non-SNAPSHOT)
[warn] 	You need to remove it from the cache manually to take effect.
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/scalacolliderugens_2.12/1.19.0/ivys/ivy.xml.md5 (non-SNAPSHOT)
[warn] 	You need to remove it from the cache manually to take effect.
...

etc.

Is there a way to only publish the one artifact ~/.ivy2/local/de.sciss/scalacollider-unidoc_2.12/1.27.0/docs/scalacollider-unidoc_2.12-javadoc.jar (eventually publishSigned)?

Sciss commented

I have a solution now, still interested to hear opinions. Feel free to close the issue.

The work around consists of creating a module in addition to the aggregating module, and defining it's publishDocs settings to re-use the publishDocs of the aggregating project. Like

lazy val aggr: Project = project.in(file("aggr"))
  .enablePlugins(ScalaUnidocPlugin)
  .settings(
    mappings in packageDoc in Compile := (mappings in (ScalaUnidoc, packageDoc)).value,
  )
  .aggregate(...)

lazy val pub: Project = project.withId("myproject-unidoc").in(file("pub"))
  .settings(publishSettings)
  .settings(
    name                  := "MyProject-unidoc",
    version               := "0.1.0-SNAPSHOT",
    autoScalaLibrary      := false,
    packageDoc in Compile := (packageDoc in Compile in aggr).value,
    publishArtifact in (Compile, packageBin) := false, // there are no binaries
    publishArtifact in (Compile, packageSrc) := false, // there are no sources
  )

Then I can use sbt myproject-unidoc/publish

2m commented

That seems to be a viable workaround.

Another idea would be to disable api doc publishing on the sub-projects:

lScalaColliderSwing / publish / Doc / skip := true
Sciss commented

oh, good, I didn't know you can add settings to a RootProject like that.

2m commented

I do not think this would work when added to the root project settings. That will have to be added for every sub-project separately.