Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

^compile does not resolve correct version of sbt plugin dependency (using addSbtPlugin) #3393

Closed
jeffreyolchovy opened this issue Jul 31, 2017 · 5 comments
Milestone

Comments

@jeffreyolchovy
Copy link

steps

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

@jeffreyolchovy jeffreyolchovy changed the title ^compile does not resolve correct version of sbt plugin dependency ^compile does not resolve correct version of sbt plugin dependency (using addSbtPlugin) Jul 31, 2017
@dwijnand
Copy link
Member

Yeah. addSbtPlugin should be redefined to use in pluginCrossBuild.

Good issues, @jeffreyolchovy, thank you.

@alonsodomin
Copy link

this exact same problem can be observed in the recently released SBT 1.0.0, preventing cross compiling plugins that depend on other plugins (the exact same workaround suggested here fixes the error).

Could be this ported to SBT 1.0.1?

@joan38
Copy link

joan38 commented Aug 13, 2017

Is there a PR for this or a commit?
Which version are we targeting?

@eed3si9n
Copy link
Member

Fix was merged to 0.13 branch - #3397
Still needs forward porting to 1.x branch

dwijnand added a commit to dwijnand/sbt that referenced this issue Aug 14, 2017
dwijnand added a commit to dwijnand/sbt that referenced this issue Aug 15, 2017
sjrd added a commit to sjrd/sbt-crossproject that referenced this issue Aug 18, 2017
Due to sbt/sbt#3393, we cannot use
`addSbtPlugin` because it is broken in 0.13.16 for cross-building
scenarios. Instead, we inline the fixed definition that will be
released in 0.13.17.
sjrd added a commit to sjrd/sbt-crossproject that referenced this issue Aug 18, 2017
Due to sbt/sbt#3393, we cannot use
`addSbtPlugin` because it is broken in 0.13.16 for cross-building
scenarios. Instead, we inline the fixed definition that will be
released in 0.13.17.
densh pushed a commit to portable-scala/sbt-crossproject that referenced this issue Aug 18, 2017
Due to sbt/sbt#3393, we cannot use
`addSbtPlugin` because it is broken in 0.13.16 for cross-building
scenarios. Instead, we inline the fixed definition that will be
released in 0.13.17.
@jroper
Copy link
Member

jroper commented Aug 23, 2017

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

SethTisue added a commit to SethTisue/sbt-houserules that referenced this issue Nov 28, 2017
sbt/sbt#3393 has been fixed, so the workaround code should no
longer be needed.  the call to `update` in the workaround code
is not dbuild-friendly (since it tries to retrieve dependencies
during dependency extraction, before dbuild has had a chance
to actually build the dependencies), so it's worth removing
sjrd added a commit to sjrd/scala-js that referenced this issue Apr 10, 2018
Mostly to get the fix to sbt/sbt#3393.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants