Question

I am trying to change a dependency in Tormenta project from

libraryDependencies += "storm" % "storm-kafka" % "0.9.0-wip6-scala292-multischeme"

to

libraryDependencies += "net.wurstmeister.storm" % "storm-kafka-0.8-plus" % "0.4.0"

The build is failing because sbt is trying to download http://clojars.org/repo/net/wurstmeister/storm/storm-kafka-0.8-plus_2.9.2/0.4.0/storm-kafka-0.8-plus-0.4.0.jar even though I don't specify %% in libraryDependencies.

Why is sbt appending _2.9.2 to the artifact to be downloaded?!

Was it helpful?

Solution

The pom.xml from the Clojars Repository contains following entries:

<properties>
  <scalaVersion>2.9.2</scalaVersion>
  <kafkaArtifact>kafka_2.9.2</kafkaArtifact>
  <envClassifier/>
</properties>

during resolving Ivy will use following pattern for computing download URL

[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]

and it will substitute [scalaVersion] with the values read from the pom.xml. Hence the invalid URL and the error.

Edit

As I've promised promised the detailed description what happens:

Ivy will download POM of the library. Somewhere in the process of downloading dependencies, Ivy will call MyModuleDescriptorProvider#provideModule. The function will return ModuleDescriptor obtained by parsing already downloaded POM file.

To do that Ivy calls CustomPomParser#parseDescriptor. After some series of calls we arrive at CustomPomParser#defaultTransformImpl, which first line is val properties = getPomProperties(md).

The resulting properties contain the Scala version property defined in the POM file. The properties are stored in the ModuleDescriptor as an extra module attributes.

Later when the download URL is built, the pattern I have mentioned previously is used. The place holders, are substituted in a method IvyPatternHelper.subsitute. Arguments to the method contain the parsed attributes and the substitution leads to the faulty URL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top