Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt: cross-publish from build.sbt

Tags:

scala

sbt

Currently, I'm using SBT scripted plugin for testing. To publish a plugin into the local repository, following code snippet in build.sbt is used:

crossScalaVersions := Seq(scalaVersion.value,"2.11.7")

scriptedDependencies := {
      val local = publishLocal.value
}

This way the artefact gets published into the local repository, but only for the version scalaVersion.value. I would like to have it cross-published for both scala versions. How can I do that?

like image 696
Slava Schmidt Avatar asked Feb 08 '16 13:02

Slava Schmidt


People also ask

How do I publish to local sbt?

To use publishing, you need to specify the repository to publish to and the credentials to use. Once these are set up, you can run publish . The publishLocal action is used to publish your project to your Ivy local file repository, which is usually located at $HOME/. ivy2/local/ .

What are resolvers in sbt?

sbt resolver is the configuration for repository that contains jars and their dependencies. for example the below is a resolver definition for a repository called Sonatype and it points at snapshot releases (dev versions) resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

What does sbt build do?

sbt is a popular tool for compiling, running, and testing Scala projects of any size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies or more than one code file.


1 Answers

As mentioned in the comments by @srjd you can use the + prefix.

As mentioned in this section of the docs

To build against all versions listed in crossScalaVersions, prefix the action to run with +. For example:

> + test

A typical way to use this feature is to do development on a single Scala version (no + prefix) and then cross-build (using +) occasionally and when releasing.

This works for any action, including publisLocal.

> + publishLocal
like image 84
Nader Ghanbari Avatar answered Oct 09 '22 15:10

Nader Ghanbari