I have the following sbt file
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
sbtPlugin := true,
organization := "com.foo",
crossScalaVersions := Seq("2.11.2", "2.12.0"),
version := "1.0.0"
)),
name := "myplugin",
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % "1.0.6",
"com.typesafe" % "config" % "1.3.3"
)
)
Now I can easily do sbt publishLocal
and I see that it generates a jar file in the .ivy2/local/com.foo/myplugin/scala_2.12/sbt_1.0/1.0.0/jars/
but if I do a
sbt +publishLocal
I get an error
[error] Modules were resolved with conflicting cross-version suffixes in ProjectRef(uri("file:/Users/user/myplugin/"), "root"):
[error] org.scala-lang.modules:scala-xml _2.11, _2.12
[error] org.scala-lang.modules:scala-parser-combinators _2.11, _2.12
[error] java.lang.RuntimeException: Conflicting cross-version suffixes in: org.scala-lang.modules:scala-xml, org.scala-lang.modules:scala-parser-combinators
[error] at scala.sys.package$.error(package.scala:27)
[error] at sbt.librarymanagement.ConflictWarning$.processCrossVersioned(ConflictWarning.scala:39)
[error] at sbt.librarymanagement.ConflictWarning$.apply(ConflictWarning.scala:19)
[error] at sbt.Classpaths$.$anonfun$ivyBaseSettings$64(Defaults.scala:1995)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:39)
[error] at sbt.std.Transform$$anon$4.work(System.scala:66)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:262)
My expectation was that SBT will do the compilation and publishing twice and each time it will pick the right jars for the right Scala version. Why does it say that there is a conflict?
My end goal is to make SBT publish multiple jar files one for each scala version in my crossScalaVersions
list.
sbt uses a fixed version of Scala: sbt 0.13 uses Scala 2.10, sbt 1.x uses Scala 2.12. So
There is documentation about Cross building plugins, but I'm not sure it is up to date, so it's better to see some examples in existing plugins. I think it should be enough to have this setup for your plugin project:
in project/build.properties
:
sbt.version=0.13.17
in build.sbt
settings:
sbtPlugin := true,
crossSbtVersions := Seq("0.13.17", "1.0.0"),
See sbt-boilerplate for an example.