Cross-built project depending on project with larger set of crossScalaVersions fails to compile
See original GitHub issuesteps
- Create a new project:
mkdir -p test/project
cd test
echo sbt.version=1.0.0 > project/build.properties
cat > build.sbt <<EOF
lazy val top = project
.settings(scalaVersion := "2.12.3", crossScalaVersions := Seq("2.11.11", "2.12.3"))
lazy val bottom = (project dependsOn top)
.settings(scalaVersion := "2.11.11", crossScalaVersions := Seq("2.11.11"))
EOF
- Run
sbt +compile
problem
Compilation fails with:
[error] sbt.librarymanagement.ResolveException: unresolved dependency: top#top_2.11;0.1-SNAPSHOT: not found
expectation
+compile
is successful.
notes
sbt version: 1.0.0
Works with sbt-doge. Change sbt.version=0.13.16
, add addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5")
to project/plugins.sbt
and run sbt 'so compile'
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (10 by maintainers)
Top Results From Across the Web
sbt Reference Manual — Cross-building
This page describes how to use sbt to build and publish your project against multiple ... crossScalaVersions must be set to Nil on...
Read more >Is `scalaBinaryVersion` incompatible with ... - Stack Overflow
I'm changing a project built against 2.11.7 so it cross-builds against 2.10.5 and 2.11.7 . The project currently defines a scalaBinaryVersion := ...
Read more >Intellij sbt project refresh failing for project with cross-builds
When I try refreshing the project in Intellij it fails with: Error while importing sbt project: ;reload; set _root_.org.jetbrains.sbt.
Read more >Hands-on Scala.js - Haoyi's Programming Blog
Hands On is a set of tutorials that walks you through getting started with Scala.js. You'll build a range of small projects, from...
Read more >sbt/sbt - Gitter
when importing the project in intellij the scala module is correctly configured but ... (which is cross-built for 2.13 and 2.12) breaks the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One work around to this would be to set
crossScalaVersions
on the root project to contain a single Scala version that all your aggregated projects have in their cross scala versions. If there is a single common Scala version, this will work. Given the existing bug in sbt-doge where the root project was never actually issued any cross built commands, you should be able to setcrossScalaVersions
to whatever you like on the root project and it won’t have any impact on it.If that doesn’t work, then you may want to consider using sbt-cross. sbt’s built in cross building support is a hack, fullstop, and there are many scenarios where it won’t work, for example, if you have a sub project A that cross builds against 2.11 and 2.12, and a second sub project B that only builds against 2.11 that depends on A, and a third sub project C that only builds against 2.12 and also depends on A, this setup cannot work - you won’t be able to issue a regular compile on it, and you won’t be able to import it into an IDE. If you’re coming across the problem in this issue, then you’re likely very close to also coming across that issue. In contrast, sbt-cross isn’t a hack (or rather is much less hacky), it’s built to work with the sbt scoping system, it doesn’t hack at it like sbt’s built in cross building uses (though I’m not sure how well IDEs go at importing it because it does mean that the same source folders end up being shared by multiple projects).
A variant of James’s workaround, I think is to set the
crossScalaVersions
toList()
. The root project that sbt injects should probably do that by default.For all others who are encountering this issue, the workaround would look like: