On 7/4/07, hezjing <[EMAIL PROTECTED]> wrote:

Hi!

I created the following 3 files,

ivy-compile.xml
<ivy-module version="1.0">
  <info organisation="jayasoft" module="hello-ivy" />
  <dependencies>
    <dependency org="org.slf4j" name="slf4j-api" rev="1.4.0" />
  </dependencies>
</ivy-module>

ivy-runtime.xml
<ivy-module version="1.0">
  <info organisation="jayasoft" module="hello-ivy" />
  <dependencies>
    <dependency org="org.slf4j" name="slf4j-api" rev="1.4.0" />
    <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.4.0" />
    <dependency org="log4j" name="log4j" rev="1.2.14" />
  </dependencies>
</ivy-module>

build.xml
<project xmlns:ivy="antlib:fr.jayasoft.ivy.ant" name="hello-ivy">
  <target name="resolve">
    <ivy:resolve file="ivy-compile.xml"/>
    <ivy:resolve file="ivy-runtime.xml"/>
  </target>
  <target name="init" depends="resolve">
    <ivy:cachepath pathid="compile.classpath" file="ivy-compile.xml" />
    <pathconvert property="ccp" refid="compile.classpath" />
    <echo message="${ccp}" />
    <ivy:cachepath pathid="runtime.classpath" file="ivy-runtime.xml" />
    <pathconvert property="rcp" refid="runtime.classpath" />
    <echo message="${rcp}" />
  </target>
</project>


When run > ant init, it resolved the dependencies and created
compile-time and runtime classpath, and printed the classpaths to the
console.

I was expecting that the compile-time classpath will contain Only
slf4-api-1.4.0.jar. However, both classpaths contains the same number
of JARs:


     [echo] C:\Documents and
Settings\hez\.ivy\cache\org.slf4j\slf4j-api\jars\slf4j-api-1.4.0.jar
;C:\Documents
and Settings\hez\.ivy\cache\org.slf4j\slf4j-log4j12\jars\slf4j-
log4j12-1.4.0.jar;C:\Documents
and Settings\hez\.ivy\cache\log4j\log4j\jars\log4j-1.2.14.jar

     [echo] C:\Documents and
Settings\hez\.ivy\cache\org.slf4j\slf4j-api\jars\slf4j-api-1.4.0.jar
;C:\Documents
and Settings\hez\.ivy\cache\org.slf4j\slf4j-log4j12\jars\slf4j-
log4j12-1.4.0.jar;C:\Documents
and Settings\hez\.ivy\cache\log4j\log4j\jars\log4j-1.2.14.jar



Do you think this is OK?


The problem is that Ivy is not meant to be used as you do. Indeed the
cachepath task relates to the last resolve if there is one. In your case it
simply ignores the file attribute, and reuse the last resolve. If you really
want to call multiple resolves and reuse theire results in several
cachepath, you need to take advantage of the scoping feature which is still
under development on the trunk. The scoping let you assign an id to a
resolve (or also a settings), and then tell which resolve id to use in a
post resolve task (like cachepath).

But I think in your situation this is overkill. You should better use one
ivy file only and use configurations to do what you want. Have you read this
tutorial:
http://incubator.apache.org/ivy/doc/tutorial/conf.html
?

Xavier

--

Hez




--
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://incubator.apache.org/ivy/
http://www.xoocode.org/

Reply via email to