0__
0__

Reputation: 67280

scala-library.jar version in sbt published artifacts

As Scala 2.10.1 is coming out soon, I believe, I want to make sure that artifacts I publish now will automatically work with a scala-library.jar of that version. I use sbt 0.12.2 to publish, and with a setting of

scalaVersion := "2.10.0"

I get correctly attached the binary compatible version to my artifact, e.g.

<artifactId>mylibrary_2.10</artifactId>

...but the scala library dependency still says 2.10.0:

     <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.10.0</version> <!-- !!! -->
    </dependency>

I suppose that is not correct, and it should use 2.10 or 2.10.+ here?


I also tried to add scalaBinaryVersion := "2.10" but that doesn't seem to change anything.

Another idea I had was to use scalaVersion := "2.10.+". Sbt takes forever with Getting Scala 2.10.+ ..., but it finally goes on fine and the pom has this version now for scala-library.jar. So maybe this is the correct way?

Upvotes: 11

Views: 990

Answers (2)

earldouglas
earldouglas

Reputation: 13473

You should be good to go for 2.10.x, since it is meant to be binary compatible between minor versions (as documented in the release notes).

In general, you can generate artifacts for arbitrary versions of Scala using the crossScalaVersions setting in sbt.

build.sbt

name := "so-14803362"

scalaVersion := "2.10.0"

crossScalaVersions := Seq("2.10.0", "2.10.1", "2.10.2")

With the above configuration, you can prepend a + to sbt commands to run them for each Scala version:

> + publish

This will build and publish your project's artifacts with each Scala version listed in crossScalaVersions.

See the sbt docs for more info.

Upvotes: 1

Roman Nikitchenko
Roman Nikitchenko

Reputation: 13046

I think if you are generating 'fat JAR' everything is determined by the versions of direct dependencies (correct me if I'm wrong) because their direct dependencies are specified too and so forth. Of course this does not guarantee you from some components that depend on Scala library version other than you'd like, you are not guaranteed from components that depends on different versions of some lib and of course Scala is in active development phase but if you stick with some Scala library version and tested well, until this changes you are OK.

But you cannot guarantee everything will be good on next Scala library because you also have other components that probably are not synchronized the same day, right? And, yes, version of Scala library should match version of Scala compiler used.

Upvotes: 0

Related Questions