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 internal dependsOn project dependency #3392

Open
jeffreyolchovy opened this issue Jul 31, 2017 · 8 comments
Open
Labels
Bug uncategorized Used for Waffle integration

Comments

@jeffreyolchovy
Copy link

steps

Given a project definition which includes both an sbt plugin and a non-plugin project that the sbt plugin depends on:

inThisBuild(
  Seq(
    organization := "com.example",
    version := "0.1"
  )
)

lazy val root = (project in file("."))
  .aggregate(library, plugin)
  .enablePlugins(CrossPerProjectPlugin)

val library = (project in file("library"))
  .settings(
    scalaVersion := "2.10.6",
    crossScalaVersions := Seq("2.10.6", "2.12.3")
  )

val plugin = (project in file("plugin"))
  .settings(
    sbtPlugin := true,
    crossSbtVersions := Seq("0.13.16", "1.0.0-RC3")
  )
  .dependsOn(library)

problem

When attempting to cross-compile the plugin for the given sbt versions, the following error occurs during dependency resolution:

> ^compile
[info] Setting `sbtVersion in pluginCrossBuild` to 0.13.16
[info] Set current project to plugin (in build file:/Users/jeffo/Projects/jvm/sbt-issue/)
[success] Total time: 0 s, completed Jul 31, 2017 9:58:42 AM
[info] Setting `sbtVersion in pluginCrossBuild` to 1.0.0-RC3
[info] Set current project to plugin (in build file:/Users/jeffo/Projects/jvm/sbt-issue/)
[info] Resolving com.example#library_2.12;0.1 ...
[warn] 	module not found: com.example#library_2.12;0.1
[logging elided] ...
[info] Resolving jline#jline;2.14.3 ...
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	::          UNRESOLVED DEPENDENCIES         ::
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	:: com.example#library_2.12;0.1: not found
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn] 	Note: Unresolved dependencies path:
[warn] 		com.example:library_2.12:0.1
[warn] 		  +- com.example:plugin:0.1 (scalaVersion=2.12, sbtVersion=1.0)
[trace] Stack trace suppressed: run last plugin/*:update for the full output.
[error] (plugin/*:update) sbt.ResolveException: unresolved dependency: com.example#library_2.12;0.1: not found

expectation

I would expect that when issuing ^compile, the internal projects that my plugin depends on would be available to it without have to do a publishLocal or +publishLocal.

notes

The ^compile task succeeds if I manually issue +publishLocal from the library project before attempting ^compile.

sbt version: 0.13.16, cross building for 0.13.16 and 1.0.0-RC3

@dwijnand
Copy link
Member

Strange. This should've been solved in #3356.

@dwijnand dwijnand added this to the 0.13.17 milestone Jul 31, 2017
@dwijnand
Copy link
Member

Oh! Cos #3356 only changes ^^ (aka pluginSwitch) and not ^/pluginCross.

@dwijnand
Copy link
Member

dwijnand commented Aug 2, 2017

No it's not that. Even the setting of scalaVersion in ^^ is too shallow: it only sets the scalaVersion in the Global scope and the current project scope, which is insufficient for the setup in your repro.

I refer to my notes here about how existing functionality (++ and set every) works.

@jeffreyolchovy
Copy link
Author

So is the current functionality the desired functionality for sbt?

@dwijnand
Copy link
Member

dwijnand commented Aug 2, 2017

Not in my book - given that there's a possible manual translation to make that legitimate build work for sbt 1, ^ and ^^ should work as you expected it to.

If your question is because you're stuck, then there are ways to avoid the problem. I haven't hit this particular bug because I set my scalaVersion in terms of sbtVersion in pluginCrossBuild: https://github.com/dwijnand/sbt-project-graph/blob/v0.2.1/build.sbt#L16-L20

@jeffreyolchovy
Copy link
Author

Nope, not stuck, just curious. Used the same workaround, but I think I sourced it from something else of yours (maybe another open issue or a different plugin).

@eed3si9n
Copy link
Member

eed3si9n commented Aug 5, 2017

To avoid adding scalaVersion at the project level by default, in #3356 I started appending scalaVersion at the project level only for the current subproject. In the hindsight I was walking into the situation like this whenever there's a plugin that depends on other subprojects.

We could try issuing ++2.x.y inside ^^ command as fix.

@eed3si9n eed3si9n added the Bug label Aug 5, 2017
@jeffreyolchovy
Copy link
Author

jeffreyolchovy commented Aug 5, 2017

@eed3si9n I had tried that, but unfortunately I ran into another issue which forced me to reinstate the scalaVersion on the subprojects. I am still trying to track down exactly what is the cause of this other issue, but it's something like:

- projectA is a plugin
- projectB is a plugin
- projectA and projectB both cross build for 0.13 and 1.0
- projectA and projectB do not set scalaVersion
- projectA and projectB both use scripted
- projectB depends on projectA using `dependsOn`

When running ^compile for projectB, I would get:

[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	::          UNRESOLVED DEPENDENCIES         ::
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	:: org.scala-sbt#scripted-sbt_2.10;1.0.0-RC3: not found
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn] 	Note: Unresolved dependencies path:
[warn] 		org.scala-sbt:scripted-sbt_2.10:1.0.0-RC3 ((sbt.ScriptedPlugin) ScriptedPlugin.scala#L104)
[warn] 		  +- com.example:project-a:0.1.0 (scalaVersion=2.10, sbtVersion=1.0)

The way I worked around this was not using dependsOn, but just adding a libraryDependency (and issuing publishLocal) to projectA on projectB like I did for the library and plugin dependsOn issue above.

I believe this only happens when I have the scripted dependency, so maybe I should be doing something different in my plugins.sbt when attempting to cross-build for 0.13 and 0.1. Currently, my plugins.sbt has the standard:

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value

UPDATE:
Seems like this other issue would be fixed by #3325

@dwijnand dwijnand removed this from the 0.13.17 milestone Jan 3, 2018
@eed3si9n eed3si9n added the uncategorized Used for Waffle integration label Sep 18, 2018
@eed3si9n eed3si9n removed the x/waffle label Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug uncategorized Used for Waffle integration
Projects
None yet
Development

No branches or pull requests

3 participants