question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

^compile does not resolve internal `dependsOn` project dependency

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffreyolchovycommented, 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 https://github.com/sbt/sbt/issues/3325

0reactions
eed3si9ncommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaring Dependencies between Subprojects
The api project has a dependency on the shared project. It has no build script and gets nothing injected by another build script....
Read more >
How to let gradle build dependent sub-project first when using ...
Gradle build order is never on the project level, but always on the task level. from(configuration.schemas) would infer task dependencies ...
Read more >
4. Dependency Management - Gradle Beyond the Basics [Book]
Every Gradle project has an internal list of repositories. By default, this list is empty, but we can add to it by using...
Read more >
Add build dependencies - Android Developers
This page describes how to use dependencies with your Android project, ... If the library does not already exist locally, Gradle pulls it...
Read more >
Introduction to the Dependency Mechanism - Apache Maven
There is no limit to the number of levels that dependencies can be ... Compile dependencies are available in all classpaths of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found