2

I am in the middle of converting over our build system from Ant to Ant with Ivy, and have run into an issue specifying a particular jar we need.

  • groupId: net.sf.json-lib
  • artifactId: json-lib
  • version: 2.3

I specified it in Ivy as:

<dependency org="net.sf.json-lib"  artifact="json-lib"
    rev="2.3"     conf="compile->default"/>

And got the following error:

[ivy:retrieve]  ==== public: tried
[ivy:retrieve]    http://buildl01.tcprod.local/artifactory/libs-release/net/sf/json-lib/json-lib/2.3/json-lib-2.3.jar
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          ::              FAILED DOWNLOADS            ::
[ivy:retrieve]          :: ^ see resolution messages for details  ^ ::
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          :: net.sf.json-lib#json-lib;2.3!json-lib.jar
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::

Notice Ivy tried to download the file json-lib-2.3.jar from the repository.

I did a search on the Central Maven Repository and found that the artifact isn't called json-lib-2.3.jar but either json-lib-2.3-jdk-13.jar or json-lib-2.3-jdk-15.jar.

The problem is the way the name of the artifact is specified. The version number appears in the middle of the jar name. If the artifact was `json-lib-jdk-15-2.4.jar, I could do this:

<dependency org="net.sf.json-lib"  artifact="json-lib"
    rev="2.3"     conf="compile->default">
    <artifact name="json-lib-jdk-15"/>
</dependency>

How can I specify this jar for downloading?

rolve
  • 10,083
  • 4
  • 55
  • 75
David W.
  • 105,218
  • 39
  • 216
  • 337
  • 1
    I just found out that this question has been asked before: http://stackoverflow.com/q/6942989/1374678 – rolve Nov 19 '12 at 21:02

1 Answers1

7

The "thing" at the end of the jar name is called the classifier. It is used to target specific platforms or to provide sources or Javadoc.

To get the jar, you need to define the classifier like this:

<ivy-module version='2.0' xmlns:m="http://ant.apache.org/ivy/maven">
...
<dependency org="net.sf.json-lib" artifact="json-lib" rev="2.3"conf="compile->default">
    <artifact name="json-lib" type="jar" m:classifier="jdk15"/>
</dependency>

Read this article for more information.

rolve
  • 10,083
  • 4
  • 55
  • 75
  • Now I'm getting _The prefix "m" for attribute "m:classifier" associated with an element type "dependency" is not bound_. I bet I have to munge my ivysettings.xml somehow first. – David W. Nov 19 '12 at 21:24
  • 1
    Thanks. The answer you [pointed to](http://stackoverflow.com/q/6942989/1374678) did work. – David W. Nov 19 '12 at 22:27