How do you remove the _<scala-version> postfix from artifacts built+published with simple-build-tool?

ScalaSbt

Scala Problem Overview


I'm building a few Java-only projects using simple-build-tool. When I publish the artifacts from the projects using, say, sbt publish-local then the resulting artifacts have the Scala version appended to their name. With a Scala project this would make sense, but since these are Java only projects it doesn't. How would I disable this postfixing of the Scala version? Or can I?

For reference I'm using sbt 0.11.1, Scala 2.9.1 and a .sbt file for build configuration (though moving to a full project config would be no problem).

Scala Solutions


Solution 1 - Scala

After looking around how Artifact.artifactName is implemented and ultimately used it seems that the way to turn this off is to specify false for the crossPath setting. This is documented in one of the quick configuration examples on the xsbt wiki.

http://www.scala-sbt.org/release/docs/Examples/Quick-Configuration-Examples

// disable using the Scala version in output paths and artifacts
crossPaths := false

Solution 2 - Scala

I know this question is old, but I've been asking myself the same question, and there's actually a very simple way to do this now. All you have to do is to declare the dependency using % instead of %%:

> %: A method used to construct an Ivy Module ID from the strings you > supply. > > %%: When used after the groupID, it automatically adds your > project’s Scala version (such as _2.10) to the end of the artifact > name.

http://alvinalexander.com/scala/sbt-how-to-manage-project-dependencies-in-scala

Solution 3 - Scala

This is documented on the xsbt wiki under Modifying default artifacts. From that page:

> For example, to produce a minimal name without a classifier or cross path: > > artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) => > artifact.name + "-" + module.revision + "." + artifact.extension > }

Solution 4 - Scala

While the accepted answer is strictly correct, you should never set crossVersions to false on publicly published Scala artifacts. The embedded scala version is an important compatibility feature, since different versions of the Scala libraries may not be binary compatible.

Only set crossVersions to false for projects, like those in the question, that are strictly Java only.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJamesView Question on Stackoverflow
Solution 1 - ScalaJamesView Answer on Stackoverflow
Solution 2 - ScalaFrancis TothView Answer on Stackoverflow
Solution 3 - ScalaPaul ButcherView Answer on Stackoverflow
Solution 4 - ScalagregsymonsView Answer on Stackoverflow