Ivy resolves jersey-servlet from Ant but not IvyDE

1.5k views Asked by At

I'm trying to build a restful server using Apache Jersey. I'm developing in Eclipse Indigo and using Ivy for dependency management with this ivy.xml file

<?xml version="1.0" encoding="UTF-8"?>

<!--=========================================================================-->
<!--
-->
<!--=========================================================================-->

<ivy-module version="2.2">      
    <info organisation="com.mypackage" module="mymodule"/>
    <dependencies>
        <dependency org="com.sun.jersey" name="jersey-servlet" rev="1.12"/>
    </dependencies>
</ivy-module>

This resolves fine calling ivy from ant, but from IvyDE I get this error

Some projects fail to be resolved
Impossible to resolve dependencies of com.mypackage#mymodule;working@Samsung-Windows
unresolved dependency: org.jboss.weld#weld-spi;1.1.4.Final: not found
unresolved dependency: javax.annotation#jsr250-api;${jsr250.api.version}: not found
unresolved dependency: org.jboss.weld#weld-api;1.1.4.Final: not found
unresolved dependency: javax.inject#javax.inject;${atinject.api.version}: not found
unresolved dependency: org.jboss.spec.javax.interceptor#jboss-interceptors-api_1.1_spec;${interceptor.api.version}: not found

To me the ${atinject.api.version} looks like it is somehow not resolving variables correctly somewhere.

My understanding of Ivy is very superficial, so I don't have any good ideas.

Both IvyDE and ant are using the same ivysettings.xml file (at least, I believe they are).

<?xml version="1.0" encoding="UTF-8"?>

<!--=========================================================================-->

<!--=========================================================================-->

<ivysettings>
   <settings defaultResolver="ibiblio"/>
   <resolvers>
          <ibiblio name="ibiblio" m2compatible="true"/>
          <ibiblio name="maven2" m2compatible="true"/>
          <ibiblio name="java-net-maven1" root="http://download.java.net/maven/1" pattern="${java.net.maven.pattern}" m2compatible="false"/>
          <ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true"/>
    </resolvers>
</ivysettings>

Any direction would be great.

Thanks a lot in advance.

Edit: Adding portion of Build.xml

I'm using apache-ivy-2.2.0 although the output claims:

[ivy:configure] :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ ::

This is the build.xml:

<?xml version="1.0"?>

<project name="IvyTest" default="ivy.retrieve" xmlns:ivy="antlib:org.apache.ivy.ant">
    <description>
        IvyTest
    </description>

    <!--=====================================================================-->
    <!-- Properties                                                          -->
    <!--=====================================================================-->

    <!-- General properties. -->
    <property name="bin" location="bin" />
    <property name="lib" location="lib" />
    <property name="lib.ivy" location="${lib}/ivy-managed" />

    <property name="ivy.version" value="2.2.0" />
    <property name="ivy.home" location="${bin}/apache-ivy-${ivy.version}" />
    <available property="ivy.installed" file="${ivy.home}/ivy-${ivy.version}.jar" />

    <property name="ant.build.javac.source" value="1.7" />
    <property name="ant.build.javac.target" value="1.7" />

    <!--=====================================================================-->
    <!-- Targets: Ivy                                                        -->
    <!--=====================================================================-->

    <!--============================ ivy.download ===========================-->
    <target name="ivy.download" unless="ivy.installed">
        <mkdir dir="${ivy.home}"/>
        <get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" dest="${ivy.home}/ivy-${ivy.version}.jar" usetimestamp="true"/>
    </target>

    <!--============================ ivy.init ===============================-->
    <target name="ivy.init" depends="ivy.download">
        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.home}/ivy-${ivy.version}.jar"/>
    </target> 

    <!--============================ ivy.resolve ============================-->
    <target name="ivy.resolve" description="Resolve dependencies with Ivy" depends="ivy.configure">
        <ivy:resolve />
    </target>

    <!--============================ ivy.retrieve ===========================-->
    <target name="ivy.retrieve" description="Retrieve dependencies with Ivy" depends="ivy.configure">
        <ivy:retrieve log="verbose" pattern="${lib.ivy}/[artifact]-[revision].[ext]" type="jar,bundle" sync="true"/>
    </target>

    <!--============================ ivy.configure ==========================-->
    <target name="ivy.configure" description="Configure Ivy settings file" depends="ivy.init">
        <ivy:configure file="ivysettings.xml"/>
    </target>

    <!--============================ ivy.clean ==============================-->
    <target name="ivy.clean" description="Cleans the Ivy cache" depends="ivy.init">
        <ivy:cleancache />
    </target>

</project>
2

There are 2 answers

5
Mark O'Connor On

By default ivy will download dependencies from Maven Central, so unless you're using your own Maven repository manager you won't need an ivy settings file. Having said that it's good practice to declare one and the following works fine for me:

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

Notice it's a lot simpler than your example. The old java.net repositories are not really used anymore, most (if not all) of their content has been migrated to Maven Central.

0
Jakob Hohlfeld On

As an update to your original question:

I also had the situation that I could resolve on the console using ant resolve but IvyDe (under Eclipse 4.2) was giving me the error "Impossible to resolve dependencies [...]"

Lead through this post I managed to edit IvyDE's settings (Workspace Preferences -> Ivy -> Settings) and add an ivysettings.properties file with this content:

ivy.home=${user.home}/.ant
ivy.jar.dir=${ivy.home}/lib
ivy.jar.file=${ivy.jar.dir}/ivy.jar

From now on everything worked fine.