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.

Dependency classifier is not resolved for Ivy

See original GitHub issue

I have the dependency which is taken from Ivy repository but uses classifier, e.g.:

libraryDependencies ++= Seq(
  "co.oops" %% "useless" % "0.0.1",
  "co.oops" %% "useless" % "0.0.1" classifier "tests"
)

Dependency with tests classifier is not resolved, or to be correct it is but it is not correctly put in class path.

I’ve prepared repo for simulation of the issue at https://github.com/teliatko/coursier-issue-ivy-classifiers

Procedure after checkout is:

$ cd useless
$ sbt publishLocal
$ cd ../issue
$ sbt
> update
> show fullClasspath

Dependency co.oops.useless in on classpath only once and without classifier. Dependency tree produced by Coursier looks like this:

$ sbt
> coursierDependencyTree
issue
├─ co.oops:useless_2.11:0.0.1
|  ├─ org.scala-lang:scala-library:2.11.8
|  └─ org.scalactic:scalactic_2.11:3.0.1
|     ├─ org.scala-lang:scala-library:2.11.8
|     └─ org.scala-lang:scala-reflect:2.11.8
|        └─ org.scala-lang:scala-library:2.11.8
├─ co.oops:useless_2.11:0.0.1
|  ├─ org.scala-lang:scala-library:2.11.8
|  └─ org.scalactic:scalactic_2.11:3.0.1
└─ org.scala-lang:scala-library:2.11.8

It shows co.oops:useless_2.11:0.0.1 twice and always without classifier tests. So tests classifier is somewhere lost along the way.

When I copy produced artifacts and pom into ~/.m2 and enable Resolver.mavenLocal in issue/build.sbt (of course leaving out Resolver.defaultLocal) everything works.

The Resolver.defaultLocal uses pattern (see SBT sources):

"[organisation]/[module]/" + PluginPattern + "[revision]/[type]s/[artifact](-[classifier]).[ext]"

Thus classifier part is in. Default SBT resolution works with classifier part correctly.

Side note: issue build already contains workaround from #444

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nathankleyncommented, Jul 13, 2017

We had previously abandoned our move to Coursier because of this issue (and not being able to figure out how to solve it). Hadoop publishes loads of test classified JARs, but most notably the hadoop-common and hadoop-hdfs JARs which contain (among other things) the MiniDFSCluster class used for unit/integration testing Hadoop related things.

"org.apache.hadoop" % "hadoop-hdfs" % "2.7.3" % "test" classifier "tests"
"org.apache.hadoop" % "hadoop-common" % "2.7.3" % "test" classifier "tests"

Of course we can now follow the workaround presented in #444 but it’s a little icky at it should IMHO be the default to do this as it is in SBT plain.

2reactions
lustefaniakcommented, Apr 18, 2017

sbt-coursier doesn’t resolve https://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-testkit_2.11/2.3.1 dependency on

<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.3.4</version>
<classifier>tests</classifier>
</dependency>

Which is required for embedded ES as it contains MockNode.class

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ivy not pulling transitive dependencies on jars with classifiers
Everything is under the <dependency> entity and no sub-entities and it worked just fine. By default, it found the pom.xml , converted it ......
Read more >
1127804 – ivy artifacts with type,ext,classifier resolve incorrectly
This problem is due to limitations of Maven POM format (Maven doesn't have separate POM for test JARs) and I cannot do anything...
Read more >
Gradle fails to resolve between ivy dependencies with and ...
in the dependency graph and not resolved any one. I tried using Dependency dependencySubstitution (with classifier) and also tried by force ...
Read more >
Ivy doesn't handle the classifier attribute of artifacts inside ...
Ivy doesn't handle the classifier attribute of artifacts inside dependency elements. Status: Assignee: Priority: Resolution: Resolved.
Read more >
Gradle Dependency Resolution Between Java 7 and Java 8 ...
and any project, say baz , building on Java 7 consumes them with classifier - jdk7 along with group, name and version. compile...
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