Skip to content

Instantly share code, notes, and snippets.

@cdegroot
Last active November 2, 2015 10:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdegroot/5864f4b4a4d759f42158 to your computer and use it in GitHub Desktop.
Save cdegroot/5864f4b4a4d759f42158 to your computer and use it in GitHub Desktop.
How-to JitPack with sbt cross compilation

Introduction

JitPack just added support for multiple Scala versions. This quick how-to describes the changes I made to one of my little projects to make everything work.

SBT changes

If you want to release for multiple Scala versions, you need to test it. Therefore, you need to add the versions you want to test against in project/Build.scala, adding:

...
crossScalaVersions := Seq("2.10.6", "2.11.7"),
...

to your Build object. When this is done,

sbt "+ test"

will build and test against both 2.10 and 2.11. So far so good for local development.

== Travis changes

You also want to double check (and you will forget the "+ test" invocation before pushing to Github) in Travis that both versions work. Your .travis.yml should look like:

language: scala
scala:
    - 2.10.6
    - 2.11.7

and Travis will do its magic.

Releasing

When Travis is green and you want to release, just do a github release with a regular version number (so no more adding "_2.10" or something like that). Your users can use the regular way of referencing sbt-built dependencies:

...
"com.github.cdegroot" %% "hardcoded" % "1.1.1",
...

and JitPack will automagically provide them with a version-specific artifact.

@FRosner
Copy link

FRosner commented Oct 7, 2015

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment