0

I was to retrieve a jar from ivy cache to a lib folder, below is the ivy.xml code:

    <configurations>
        <conf name="specificFolder"  description="add jar to web-inf/lib folder"/>
    </configurations>
    <dependencies>
        <dependency org="javax.servlet" name="servlet-api" rev="2.4" transitive="false" conf="specificFolder"/>
        <dependency org="org.springframework" name="spring-beans" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring-webmvc" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring-web" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring-context" rev="2.5.5" transitive="false" />
        <dependency org="org.springframework" name="spring" rev="1.2.6" transitive="false" />

then this is ant target:

<target name="test">
    <ivy:retrieve pattern="lib/[artifact](.[ext])" sync="true" type="jar" conf="specificFolder"/>
</target>

But I got "Unresolved Dependency", this anything I am doing wrong?

Joy
  • 179
  • 3
  • 14

1 Answers1

2

I reproduced your problem and here is the relevant error message:

[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]       ::          UNRESOLVED DEPENDENCIES         ::
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]       :: javax.servlet#servlet-api;2.4: configuration not found in javax.servlet#servlet-api;2.4: 'specificFolder'. It was required from com.myspotontheweb#demo;????? specificFolder
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::

The root cause is the following dependency declaration:

<dependency org="javax.servlet" name="servlet-api" ... conf="specificFolder"/>

While the configuration exists in your module it does not exist in the remote Maven module. For more details on how see the following answer:

Working example

ivy.xml

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="specificFolder"  description="add jar to web-inf/lib folder"/>
    </configurations>
    <dependencies>
        <dependency org="javax.servlet" name="servlet-api" rev="2.4"            conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-beans" rev="2.5.5"   conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-webmvc" rev="2.5.5"  conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-web" rev="2.5.5"     conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring-context" rev="2.5.5" conf="specificFolder->master"/>
        <dependency org="org.springframework" name="spring" rev="1.2.6"         conf="specificFolder->master"/>
    </dependencies>

</ivy-module>

Notes:

  • This example uses configuration mappings instead of "transitive=false". The local configuration is "specificFolder" and the remote configuration is the special "master". "master" is provided by Maven modules and means the remote artifact with no dependencies. I think this approach is simpler once it's understood how configurations work. (Very powerful concept in Maven)
  • what does the little arrow -> do in the ivy dependency section?
Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Thanks for your detailed explanation and knowledge share, it really help! Thanks again. – Joy Jan 11 '13 at 04:47