sbt-crossproject
sbt-crossproject copied to clipboard
+publish(Signed) fails with "Repository for publishing is not specified." when crossScalaVersions are not identical
e.g. only publishing against Scala 2.13 for Scala.js:
lazy val root = crossProject(JVMPlatform, JSPlatform).in(file("."))
.settings(publishSettings)
.settings(
scalaVersion := "2.13.3"
)
.jvmSettings(
crossScalaVersions := Seq("2.13.3", "2.12.12"),
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
publishTo := {
Some(if (isSnapshot.value)
"Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
else
"Sonatype Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
)
},
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
)
Here, sbt +publishSigned uploads the JVM artefact for Scala 2.12, and the JS artefact for Scala 2.13, but fails to upload the JVM artefact for Scala 2.13, instead failing with
[error] java.lang.RuntimeException: Repository for publishing is not specified.
[error] at scala.sys.package$.error(package.scala:30)
[error] at sbt.Classpaths$.$anonfun$getPublishTo$1(Defaults.scala:3033)
[error] at scala.Option.getOrElse(Option.scala:189)
[error] at sbt.Classpaths$.getPublishTo(Defaults.scala:3033)
[error] at sbt.Classpaths$.$anonfun$ivyBaseSettings$53(Defaults.scala:2427)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
...
This happens because it's trying to publish the implicitly created root project. You need to disable publishing of the root project altogether with something like
publish / skip := true
publishSigned / skip := true
at the top level of your build.sbt file.
Hmm, that just gives
/home/hhrutz/Documents/devel/AudioFile/build.sbt:25: error: not found: value publishSigned
publishSigned / skip := false
^
[error] Type error in expression
also - should it be skip := true?
Here is the whole picture for +publishLocal, after adding publish / skip := true to global:
[info] welcome to sbt 1.4.2 (Debian Java 11.0.9)
[info] loading settings for project global-plugins from build.sbt,idea.sbt ...
[info] loading global plugins from /home/hhrutz/.sbt/1.0/plugins
[info] loading settings for project audiofile-build from plugins.sbt ...
[info] loading project definition from /home/hhrutz/Documents/devel/AudioFile/project
[info] loading settings for project audiofile from build.sbt ...
[info] set current project to audiofile (in build file:/home/hhrutz/Documents/devel/AudioFile/)
[info] Setting Scala version to 2.12.12 on 2 projects.
[info] Excluded 1 projects, run ++ 2.12.12 -v for more details.
[info] Reapplying settings...
[info] set current project to audiofile (in build file:/home/hhrutz/Documents/devel/AudioFile/)
[info] Wrote /home/hhrutz/Documents/devel/AudioFile/target/scala-2.12/audiofile_2.12-0.1.0-SNAPSHOT.pom
[info] Wrote /home/hhrutz/Documents/devel/AudioFile/jvm/target/scala-2.12/audiofile_2.12-2.3.2.pom
[info] Wrote /home/hhrutz/Documents/devel/AudioFile/js/target/scala-2.13/audiofile_sjs1_2.13-2.3.2.pom
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] :: delivering :: default#audiofile_2.12;0.1.0-SNAPSHOT :: 0.1.0-SNAPSHOT :: integration :: Fri Dec 04 12:20:30 CET 2020
[info] delivering ivy file to /home/hhrutz/Documents/devel/AudioFile/target/scala-2.12/ivy-0.1.0-SNAPSHOT.xml
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/default/audiofile_2.12/0.1.0-SNAPSHOT/poms/audiofile_2.12.pom
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/default/audiofile_2.12/0.1.0-SNAPSHOT/jars/audiofile_2.12.jar
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/default/audiofile_2.12/0.1.0-SNAPSHOT/srcs/audiofile_2.12-sources.jar
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/default/audiofile_2.12/0.1.0-SNAPSHOT/docs/audiofile_2.12-javadoc.jar
[info] published ivy to /home/hhrutz/.ivy2/local/default/audiofile_2.12/0.1.0-SNAPSHOT/ivys/ivy.xml
...
[info] :: delivering :: de.sciss#audiofile_2.12;2.3.2 :: 2.3.2 :: release :: Fri Dec 04 12:20:45 CET 2020
[info] delivering ivy file to /home/hhrutz/Documents/devel/AudioFile/jvm/target/scala-2.12/ivy-2.3.2.xml
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.12/2.3.2/poms/audiofile_2.12.pom
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.12/2.3.2/jars/audiofile_2.12.jar
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.12/2.3.2/srcs/audiofile_2.12-sources.jar
[info] published audiofile_2.12 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.12/2.3.2/docs/audiofile_2.12-javadoc.jar
[info] published ivy to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.12/2.3.2/ivys/ivy.xml
[info] :: delivering :: de.sciss#audiofile_sjs1_2.13;2.3.2 :: 2.3.2 :: release :: Fri Dec 04 12:20:45 CET 2020
[info] delivering ivy file to /home/hhrutz/Documents/devel/AudioFile/js/target/scala-2.13/ivy-2.3.2.xml
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/poms/audiofile_sjs1_2.13.pom
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/jars/audiofile_sjs1_2.13.jar
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/srcs/audiofile_sjs1_2.13-sources.jar
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/docs/audiofile_sjs1_2.13-javadoc.jar
[info] published ivy to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/ivys/ivy.xml
[success] Total time: 16 s, completed 4 Dec 2020, 12.20.45
[info] Setting Scala version to 2.13.4 on 2 projects.
[info] Excluded 1 projects, run ++ 2.13.4 -v for more details.
[info] Reapplying settings...
[info] set current project to audiofile (in build file:/home/hhrutz/Documents/devel/AudioFile/)
[info] Wrote /home/hhrutz/Documents/devel/AudioFile/js/target/scala-2.13/audiofile_sjs1_2.13-2.3.2.pom
[info] Wrote /home/hhrutz/Documents/devel/AudioFile/jvm/target/scala-2.13/audiofile_2.13-2.3.2.pom
[info] :: delivering :: de.sciss#audiofile_sjs1_2.13;2.3.2 :: 2.3.2 :: release :: Fri Dec 04 12:20:45 CET 2020
[info] delivering ivy file to /home/hhrutz/Documents/devel/AudioFile/js/target/scala-2.13/ivy-2.3.2.xml
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/poms/audiofile_sjs1_2.13.pom (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/audiofile_sjs1_2.13/2.3.2/poms/audiofile_sjs1_2.13.pom.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/audiofile_sjs1_2.13/2.3.2/poms/audiofile_sjs1_2.13.pom.md5 (non-SNAPSHOT)
[warn] You need to remove it from the cache manually to take effect.
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/poms/audiofile_sjs1_2.13.pom
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/jars/audiofile_sjs1_2.13.jar (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/audiofile_sjs1_2.13/2.3.2/jars/audiofile_sjs1_2.13.jar.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/audiofile_sjs1_2.13/2.3.2/jars/audiofile_sjs1_2.13.jar.md5 (non-SNAPSHOT)
[warn] You need to remove it from the cache manually to take effect.
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/jars/audiofile_sjs1_2.13.jar
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/srcs/audiofile_sjs1_2.13-sources.jar (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/audiofile_sjs1_2.13/2.3.2/srcs/audiofile_sjs1_2.13-sources.jar.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/audiofile_sjs1_2.13/2.3.2/srcs/audiofile_sjs1_2.13-sources.jar.md5 (non-SNAPSHOT)
[warn] You need to remove it from the cache manually to take effect.
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/srcs/audiofile_sjs1_2.13-sources.jar
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/docs/audiofile_sjs1_2.13-javadoc.jar (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/audiofile_sjs1_2.13/2.3.2/docs/audiofile_sjs1_2.13-javadoc.jar.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/audiofile_sjs1_2.13/2.3.2/docs/audiofile_sjs1_2.13-javadoc.jar.md5 (non-SNAPSHOT)
[warn] You need to remove it from the cache manually to take effect.
[info] published audiofile_sjs1_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/docs/audiofile_sjs1_2.13-javadoc.jar
[warn] Attempting to overwrite /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/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/audiofile_sjs1_2.13/2.3.2/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/audiofile_sjs1_2.13/2.3.2/ivys/ivy.xml.md5 (non-SNAPSHOT)
[warn] You need to remove it from the cache manually to take effect.
[info] published ivy to /home/hhrutz/.ivy2/local/de.sciss/audiofile_sjs1_2.13/2.3.2/ivys/ivy.xml
...
[info] :: delivering :: de.sciss#audiofile_2.13;2.3.2 :: 2.3.2 :: release :: Fri Dec 04 12:20:51 CET 2020
[info] delivering ivy file to /home/hhrutz/Documents/devel/AudioFile/jvm/target/scala-2.13/ivy-2.3.2.xml
[info] published audiofile_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.13/2.3.2/poms/audiofile_2.13.pom
[info] published audiofile_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.13/2.3.2/jars/audiofile_2.13.jar
[info] published audiofile_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.13/2.3.2/srcs/audiofile_2.13-sources.jar
[info] published audiofile_2.13 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.13/2.3.2/docs/audiofile_2.13-javadoc.jar
[info] published ivy to /home/hhrutz/.ivy2/local/de.sciss/audiofile_2.13/2.3.2/ivys/ivy.xml
[success] Total time: 6 s, completed 4 Dec 2020, 12.20.51
[info] Setting Scala version to 3.0.0-M2 on 1 projects.
[info] Excluded 2 projects, run ++ 3.0.0-M2 -v for more details.
[info] Reapplying settings...
[info] set current project to audiofile (in build file:/home/hhrutz/Documents/devel/AudioFile/)
[info] Wrote /home/hhrutz/Documents/devel/AudioFile/jvm/target/scala-3.0.0-M2/audiofile_3.0.0-M2-2.3.2.pom
...
[info] :: delivering :: de.sciss#audiofile_3.0.0-M2;2.3.2 :: 2.3.2 :: release :: Fri Dec 04 12:21:00 CET 2020
[info] delivering ivy file to /home/hhrutz/Documents/devel/AudioFile/jvm/target/scala-3.0.0-M2/ivy-2.3.2.xml
[info] published audiofile_3.0.0-M2 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_3.0.0-M2/2.3.2/poms/audiofile_3.0.0-M2.pom
[info] published audiofile_3.0.0-M2 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_3.0.0-M2/2.3.2/jars/audiofile_3.0.0-M2.jar
[info] published audiofile_3.0.0-M2 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_3.0.0-M2/2.3.2/srcs/audiofile_3.0.0-M2-sources.jar
[info] published audiofile_3.0.0-M2 to /home/hhrutz/.ivy2/local/de.sciss/audiofile_3.0.0-M2/2.3.2/docs/audiofile_3.0.0-M2-javadoc.jar
[info] published ivy to /home/hhrutz/.ivy2/local/de.sciss/audiofile_3.0.0-M2/2.3.2/ivys/ivy.xml
[success] Total time: 8 s, completed 4 Dec 2020, 12.21.00
As you can see, scala.js is accidentally published multiple times, although it should not appear in the 2.12 cycle.
also - should it be
skip := true?
Yes, it should. Sorry. I updated my message.
I have no idea how +aggregateTask is supposed to behave when not all the projects it applies to have the same crossScalaVersions. I don't know if this is specified. I wouldn't recommend trying that. Instead, consider doing separately
> +rootJVM/publishLocal
> +rootJS/publishLocal
yes, I'm doing that now (two separate publishes); still, I guess it's a bug somewhere
I think one of the problems is that changing from project to crossProject "drops" keys in the root project. For example, using .settings(version := foo, organization := bar) etc., these settings are lost now. If I run, for example, sbt sonatypeBundleRelease, it says version is 0.1.0-SNAPSHOT (sbt default) and organization is empty. So I think the crossProject needs to populate the root project for anything in settings (as opposed to .jvmSettings, .jsSettings).
This really has nothing to do with crossProject. crossProject is a stupid builder for 2 (or more) projects. You could rewrite your build not to use crossProject, but instead declare 2 projects, and everything would behave the same:
lazy val rootJVM = project.in(file("jvm"))
.settings(publishSettings)
.settings(sharedSourceSettings)
.settings(
scalaVersion := "2.13.3"
)
.settings(
crossScalaVersions := Seq("2.13.3", "2.12.12"),
)
lazy val rootJS = project.in(file("js"))
.enablePlugins(ScalaJSPlugin)
.settings(publishSettings)
.settings(sharedSourceSettings)
.settings(
scalaVersion := "2.13.3"
)
lazy val sharedSourceSettings = Def.settings(
Compile / unmanagedSourceDirectories += baseDirectory.value.getParentFile / "shared/src/main/scala",
Test / unmanagedSourceDirectories += baseDirectory.value.getParentFile / "shared/src/test/scala",
)
If you manage to make it work with two separate projects that are manually configured, and it still doesn't work with the equivalent configuration using crossProject, then we can see what's the difference and possibly introduce a change in sbt-crossproject.
Until then, my assessment is that it has nothing to do with sbt-crossproject, and everything to do with sbt's broken aggregation mechanism combined with the not-so-broken-anymore + behavior.
Currently bumping into the same issue but will follow the development on https://github.com/sbt/sbt/issues/6193.
For me it works if I set crossScalaVersions := Nil in my root project.
Note: I follow the recommended layout of having a root project which aggregates the cross project(s).