^compile does not resolve correct version of sbt plugin dependency (using addSbtPlugin)
See original GitHub issuesteps
Given a build.sbt for an sbt plugin that needs to include another sbt plugin as a library dependency (e.g. we are creating an AutoPlugin which requires this other sbt plugin):
sbtPlugin := true
crossSbtVersions := Seq("0.13.16", "1.0.0-RC3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
problem
When attempting to cross-build (^compile
) this plugin for the given versions of sbt, the resolution for the plugin used as a dependency fails:
> ^compile
[info] Setting `sbtVersion in pluginCrossBuild` to 0.13.16
[info] Set current project to sbt-issue (in build file:/Users/jeffo/Projects/jvm/sbt-issue/)
[success] Total time: 2 s, completed Jul 31, 2017 10:09:42 AM
[info] Setting `sbtVersion in pluginCrossBuild` to 1.0.0-RC3
[info] Set current project to sbt-issue (in build file:/Users/jeffo/Projects/jvm/sbt-issue/)
[info] Resolving com.eed3si9n#sbt-buildinfo;0.7.0 ...
[warn] module not found: com.eed3si9n#sbt-buildinfo;0.7.0
[logging elided] ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.eed3si9n#sbt-buildinfo;0.7.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.eed3si9n:sbt-buildinfo:0.7.0 (scalaVersion=2.12, sbtVersion=0.13)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.eed3si9n:sbt-buildinfo:0.7.0 (scalaVersion=2.12, sbtVersion=0.13) (/Users/jeffo/Projects/jvm/sbt-issue-1/build.sbt#L5-6)
[warn] +- default:sbt-issue-1:0.1-SNAPSHOT (scalaVersion=2.12, sbtVersion=1.0)
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-buildinfo;0.7.0: not found
expectation
I would expect addSbtPlugin
to use the correct version of Scala, conditionally, for each version of sbt that it is attempting to compile against.
notes
This can be worked around by replacing addSbtPlugin
with the following:
libraryDependencies += {
val currentSbtVersion = (sbtBinaryVersion in pluginCrossBuild).value
Defaults.sbtPluginExtra("com.eed3si9n" % "sbt-buildinfo" % "0.7.0", currentSbtVersion, scalaBinaryVersion.value)
}
sbt version: 0.13.16, cross building for 0.13.16 and 1.0.0-RC3
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
sbt - when specify the scalaVersion and sbtVersion to resolve ...
Trying to use an artifact build with Scala 2.10, ie. for SBT 0.13.x, will break. Share.
Read more >sbt Reference Manual — Plugins
You can create project/plugins.sbt with all of the desired sbt plugins, any general dependencies, and any necessary repositories: addSbtPlugin("org.example" ...
Read more >problems with adding dependencies to play plugins.sbt file
I am using version of play: 2.4.4 and scala version: 2.11.5. This is what i added to plugins.sbt which did not work. addSbtPlugin("net.databinder.dispatch" ......
Read more >sbt/sbt - Gitter
Hi everyone, I'm trying to create a fat-jar with sedona libraries for my spark application. for that I add dependencies into my build.sbt:...
Read more >sbt-assembly - Scaladex
Using Published Plugin. sbt-assembly Scala version support. Add sbt-assembly as a dependency in project/plugins.sbt : addSbtPlugin("com.eed3si9n" ...
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
For those too impatient to wait for a new release:
https://github.com/sbt/sbt-web-build-base/blob/9503fa2cb8cea57cdd859e140941514766a9aebd/src/main/scala/SbtWebBuildBase.scala#L16-L25
Fix was merged to 0.13 branch - https://github.com/sbt/sbt/pull/3397 Still needs forward porting to 1.x branch