Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8984379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:05:31+00:00 2026-06-15T21:05:31+00:00

I have a fairly normal Scala project currently being built using Maven. I would

  • 0

I have a fairly normal Scala project currently being built using Maven. I would like to support both Scala 2.9.x and the forthcoming 2.10, which is not binary or source compatible. I am willing to entertain converting to SBT if necessary, but I have run into some challenges.

My requirements for this project are:

  • Single source tree (no branching). I believe that trying to support multiple concurrent “master” branches for each Scala version will be the quickest way to miss bugfixes between the branches.

  • Version specific source directories. Since the Scala versions are not source compatibile, I need to be able to specify an auxiliary source directory for version specific sources.

  • Version specific source jars. End users should be able to download the correct source jar, with the correct version specific sources, for their version of Scala for IDE integration.

  • Integrated deployment. I currently use the Maven release plugin to deploy new versions to the Sonatype OSS repository, and would like to have a similarly simple workflow for releases.

  • End-user Maven support. My end users are often Maven users, and so a functional POM that accurately reflects dependencies is critical.

  • Shaded jar support. I need to be able to produce a JAR that includes a subset of my dependenices and removes the shaded dependencies from the published POM.

Things I have tried:

  • Maven profiles. I created a set of Maven profiles to control what version of Scala is used to build, using the Maven build-helper plugin to select the version specific source tree. This was working well until it came time to publish;

    • Using classifiers to qualify versions doesn’t work well, because the source jars would also need custom classifiers (‘source-2.9.2’, etc.), and most IDE tools wouldn’t know how to locate them.

    • I tried using a Maven property to add the SBT-style _${scala.version} suffix to the artifact name, but Maven does not like properties in the artifact name.

  • SBT. This works well once you can grok it (no small task despite extensive documentation). The downside is that there does not seem to be an equivalent to the Maven shade plugin. I’ve looked at:

    • Proguard. The plugin is not updated for SBT 0.12.x, and won’t build from source because it depends on another SBT plugin that has changed groupIds, and doesn’t have a 0.12.x version under the old name. I have not yet been able to work out how to instruct SBT to ignore/replace the plugin dependency.

    • OneJar. This uses custom class loading to run Main classes out of embedded jars, which is not the desired result; I want the class files of my project to be in the jar along with (possibly renamed) class files from my shaded dependencies.

    • SBT Assembly plugin. This can work to a degree, but the POM file appears to include the dependencies that I’m trying to shade, which doesn’t help my end users.

I accept that there may not be a solution that does what I want for Scala, and/or I may need to write my own Maven or Scala plugins to accomplish the goal. But if I can I’d like to find an existing solution.

Update

I am close to accepting @Jon-Ander’s excellent answer, but there is still one outstanding piece for me, which is a unified release process. The current state of my build.sbt is on GitHub. (I’ll reproduce it here in an answer later for posterity).

The sbt-release plugin does not support multi-version builds (i.e., + release does not behave as one might like), which makes a sort of sense as the process of release tagging doesn’t really need to happen across versions. But I would like two parts of the process to be multi-version: testing and publishing.

What I’d like to have happen is something akin to two-stage maven-release-plugin process. The first stage would do the administrative work of updating Git and running the tests, which in this case would mean running + test so that all versions are tested, tagging, updating to snapshot, and then pushing the result to upstream.

The second stage would checkout the tagged version and + publish, which will rerun the tests and push the tagged versions up to the Sonatype repository.

I suspect that I could write releaseProcess values that do each of these, but I’m not sure if I can support multiple releaseProcess values in my build.sbt. It probably can work with some additional scopes, but that part of SBT is still strange majick to me.

What I currently have done is changed the releaseProcess to not publish. I then have to checkout the tagged version by hand and run + publish after the fact, which is close to what I want but does compromise, especially since the tests are only run on the current scala version in the release process. I could live with a process that isn’t two-stage like the maven plugin, but does implement multi-version test and publish.

Any additional feedback that can get me across the last mile would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:05:32+00:00Added an answer on June 15, 2026 at 9:05 pm

    Most of this is well supported in sbt within a single source tree

    Version specific source directories are usually not need. Scala programs tends to be source compatible – so often in fact that
    crossbuilding (http://www.scala-sbt.org/release/docs/Detailed-Topics/Cross-Build) has first class support in sbt.

    If you really need version specific code, you can add extra source folders.
    Putting this in your build.sbt file will add “src/main/scala-[scalaVersion]” as a source directory for each version as you crossbuild in addition to the regular “src/main/scala”.
    (there is also a plugin available for generating shims between version, but I haven’t tried it – https://github.com/sbt/sbt-scalashim)

    unmanagedSourceDirectories in Compile <+= (sourceDirectory in Compile, scalaVersion){ (s,v) => s / ("scala-"+v) }
    

    version specific source jars – see crossbuilding, works out of the box

    integrated deployment – https://github.com/sbt/sbt-release (has awesome git integration too)

    Maven end-users – http://www.scala-sbt.org/release/docs/Detailed-Topics/Publishing.html

    Shaded – I have used this one https://github.com/sbt/sbt-assembly which have worked fine for my needs.
    Your problem with the assembly plugin can be solved by rewriting the generated pom.
    Here is an example ripping out joda-time.

    pomPostProcess := {
        import xml.transform._
        new RuleTransformer(new RewriteRule{
            override def transform(node:xml.Node) = {
                if((node \ "groupId").text == "joda-time") xml.NodeSeq.Empty else node
            }
        })
    }
    

    Complete build.sbt for for reference

    scalaVersion := "2.9.2"
    
    crossScalaVersions := Seq("2.9.2", "2.10.0-RC5")
    
    unmanagedSourceDirectories in Compile <+= (sourceDirectory in Compile, scalaVersion){ (s,v) => s / ("scala-"+v) }
    
    libraryDependencies += "joda-time" % "joda-time" % "1.6.2"
    
    libraryDependencies += "org.mindrot" % "jbcrypt" % "0.3m"
    
    pomPostProcess := {
        import xml.transform._
        new RuleTransformer(new RewriteRule{
            override def transform(node:xml.Node) = {
                if((node \ "groupId").text == "joda-time") xml.NodeSeq.Empty else node
            }
        })
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a working application but I would like some advice because I
I have a fairly simple web2py form with a few validators like, IS_FLOAT_IN_RANGE(...) on
This seems like a fairly simple problem to me but I have been having
I have a fairly odd set of circumstances. I'm using Spring 3.0.6 with a
I have a simple mfc project built on a CDialog. I also have a
I have created a fairly simple Activity in Mono for Android project: [Activity(Label =
I have a fairly simple project with only two XIBs, 5 custom classes and
I have a fairly complex Xcode project and I want to add Qt to
I have a service that uses a fairly expensive object to create. I would
I have a list of 'request' objects, each of which has fairly normal activerecord

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.