Apache IVY Unable to resolve dependencies for MAVEN Projects

1.4k views Asked by At

I have a setup of Apache Ivy(Version 2.4.0) and Netbeans IDE(8.0.2). I have not been able to resolve dependencies for full blown maven projects(For example:org.glassfish.jersey). Apache Ivy successfully resolves dependencies for more specific modules like (org.glassfish.jersey.core).

Non working Example:

<dependency org="org.glassfish.jersey" name="project" rev="2.13" conf="solrj->*"/>

Working Examples:

<dependency org="org.apache.solr" name="solr-solrj" rev="5.0.0" conf="solrj->default"/>
<dependency org="org.glassfish.jersey.core" name="jersey-server" rev="2.13" conf="JerseyCore-2.13->default,optional"/>
<dependency org="org.glassfish.jersey.core" name="jersey-client" rev="2.13" conf="JerseyCore-2.13->default,optional"/>
<dependency org="org.glassfish.jersey.core" name="jersey-common" rev="2.13" conf="JerseyCore-2.13->default,optional"/>

ivy.xml

<ivy-module version="2.0">
<info organisation="org.sonatype.nexus.examples" module="simple-project" revision="1.0.0-SNAPSHOT"/>

<configurations>
    <conf name="solrj" description="Jars from the SOLRJ Library Collection"/>        
</configurations>

<dependencies>
    <dependency org="org.glassfish.jersey" name="project" rev="2.13" conf="solrj->*"/>

    <dependency org="org.apache.solr" name="solr-solrj" rev="5.0.0" conf="solrj->default"/>
</dependencies>

ivysettings.xml

<ivysettings>
<settings defaultResolver="ibiblio"/>
<resolvers>     
    <ibiblio name="ibiblio" m2compatible="true"/>
</resolvers>

build.xml(Just the IVY Part).

<!-- Resolve all the dependencies that we declared in the build.xml file.
Resolving means that ivy will download the jar file from the MAVEN 2 Repository
and put them under the directory that you specify in the build.xml file.
In my case this is where all the jar files will be downloaded "C:\Users\ajalgaon\Accurev\solrj\lib" -->
<target name="init">  
    <ivy:settings file="ivysettings.xml" />
    <ivy:resolve/>
    <ivy:report todir="prebuilt/ivy-report" graph="false"/>
    <ivy:retrieve conf="solrj" pattern="prebuilt/jars/solrj-lib/[artifact].[ext]"/>

</target>

Apache IVY Successfully resolves dependencies for the solr-solrj module. But it does not resolve dependency for "org.glassfish.jersey". Apache IVY Does not resolve dependencies for anything that has the attribute name="project" in the ivy.xml file. Kindly let me know if I need to post more information here. Thanks a lot in advance.

1

There are 1 answers

3
Mark O'Connor On BEST ANSWER

Cannot reproduce your issue.

Example

├── build.xml
├── ivy.xml
└── target
    ├── ivy-reports
    │   ├── ivy-report.css
    │   └── org.sonatype.nexus.examples-simple-project-solrj.html
    └── jars
        ├── commons-io.jar
        ├── httpclient.jar
        ├── httpcore.jar
        ├── httpmime.jar
        ├── noggit.jar
        ├── slf4j-api.jar
        ├── solr-solrj.jar
        ├── stax2-api.jar
        ├── woodstox-core-asl.jar
        └── zookeeper.jar

ivy.xml

<ivy-module version="2.0">
  <info organisation="org.sonatype.nexus.examples" module="simple-project" revision="1.0.0-SNAPSHOT"/>

  <configurations>
    <conf name="solrj" description="Jars from the SOLRJ Library Collection"/>        
  </configurations>

  <dependencies>
    <dependency org="org.glassfish.jersey" name="project" rev="2.13" conf="solrj->*"/>

    <dependency org="org.apache.solr" name="solr-solrj" rev="5.0.0" conf="solrj->default"/>
  </dependencies>

</ivy-module>

build.xml

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <property name="build.dir" location="target"/>

    <available classname="org.apache.ivy.Main" property="ivy.installed"/> 

    <target name="resolve" depends="install-ivy" description="Use ivy to resolve classpaths">
        <ivy:resolve/>

        <ivy:report todir='${build.dir}/ivy-reports' graph='false' xml='false'/>

        <ivy:retrieve conf="solrj" pattern="${build.dir}/jars/[artifact].[ext]"/>
    </target>

    <target name="install-ivy" description="Install ivy" unless="ivy.installed">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
        <fail message="Ivy has been installed. Run the build again"/>
    </target>

    <target name="clean" description="Cleanup build files">
        <delete dir="${build.dir}"/>
    </target>

    <target name="clean-all" depends="clean" description="Additionally purge ivy cache">
        <ivy:cleancache/>
    </target>

</project>