Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 247
0__ Avatar asked Feb 10 '13 22:02

0__


People also ask

Which Scala version does sbt use?

sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs. This version of Scala is fixed for a specific sbt release and cannot be changed. For sbt 1.7. 1, this version is Scala 2.12.

What are library dependencies in sbt?

Library dependencies can be added in two ways: unmanaged dependencies are jars dropped into the lib directory. managed dependencies are configured in the build definition and downloaded automatically from repositories.

Where are sbt jars?

All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.

Does sbt use ivy?

By default, sbt uses the standard Ivy home directory location ${user.


1 Answers

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.

like image 178
earldouglas Avatar answered Nov 04 '22 05:11

earldouglas