0

I am using Ant with Ivy and so my compile task looks like:

<target name="compile" depends="prepare, retrieve" ..

where the retrieve task is used to resolve and fetch Ivy dependencies. So, since my compile task depends on the retrieve task, the resolving of Ivy dependencies is triggered with every compilation. Ditto for run since the run task depends on compile.

This wastes time so I would like to have a dry-compile which would not depend on the Ivy task.

The use case would be that if no Ivy dependency has changed I would be able to do an ant dry-compile or even an ant dry-run without triggering the Ivy resolving functionality.

Is there a way to do that in Ant without copy-pasting the targets to create variants with different depends attributes?

My ivy.xml file is:

<ivy-module version="2.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
  <info organisation="foo" module="bar" status="integration"/>
  <dependencies>
      <dependency org="org.apache.commons" name="commons-lang3" rev="3.1"/>
  </dependencies>
</ivy-module>

and the Ant resolve target (on which target compile depends) is:

<target name="test-ivy" description="Test ivy installation">
    <ivy:settings />
</target>

<target name="resolve" depends="test-ivy">
    <ivy:resolve/>
    <ivy:retrieve sync="true" pattern="${ivylibs.dir}/[artifact]-[revision](-[classifier]).[ext]"/> 
</target>
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • You have `retrieve`? You need to use `` to resolve the dependencies. You should then use `` to create a path that you can use. This way, you don't need to retrieve the jars. You still need to resolve, but if you don't clean the Ivy cache, it shouldn't take too long. Are you doing a _clean_ with each build? – David W. Sep 22 '13 at 00:52
  • @DavidW. no, not clean on each build, resolve takes about 3-4 seconds which is too long if all I want to do is catch a simple syntax error. – Marcus Junius Brutus Sep 22 '13 at 11:17

1 Answers1

0

A simpler option is to switch off network based resolution and force ivy to use cached data.

See the following answer for more details:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185