How do I specify net.sf.json-lib#json-lib#2.3 in Ivy or Maven?

ivy, java, maven, pom.xml

Solution

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.

Problem

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?

Original source