Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Ant offer a way to bypass dependency?

Tags:

build

ant

The build.xml has a test and a build target. The test target obviously depends on the build target.

How can I run the test target only, temporarily skipping the compilation, without modifying the build.xml file ?

I'm asking because the compilation is too long, and kept up-to-date by a continuous integration server ; and I'm chasing after an issue with the unit tests.

like image 224
philant Avatar asked Dec 17 '08 14:12

philant


People also ask

What are the dependencies between components in ant?

Based upon this description, the dependencies between components can be illustrated as follows: These projects are contained in sibling directories underneath a top level “ example ” directory. The standard way to build a component from Ant is to declare a build or compile target and use the javac task.

How do I prevent ant from executing the target?

The simple way to avoid executing the target is to set the "unless" attribute of the target to the name of some property. If you then set this property on the command line when running Ant, it will bypass that target.

Can I omit a dependency in Maven Ant tasks?

It can be omitted if Maven Ant Tasks was installed in Ant's lib directory. (since 2.0.8) For each dependency resolved using either inline declaration or a pom reference, the property groupId:artifactId:type [:classifier] is defined pointing to the corresponding file. For example, a resolved dependency on junit can be accessed in the following way:

How do I build a component from an Ant target?

The standard way to build a component from Ant is to declare a build or compile target and use the javac task. Other targets can build a distributable or clean up generated files. For example: Traditionally, a script similar to the example above would have been copied into each of the component directories.


1 Answers

Use the unless attribute.

<target name="test" unless="dont.run.tests">

If you don't want "test" to run, just

ant -Ddont.run.tests=true

It should be undefined if you want the tests to run. Ant just checks for whether it's defined at all. Also, there's an if attribute that does the converse.

Here's an article on the both.

like image 174
sblundy Avatar answered Nov 15 '22 20:11

sblundy