1

I handle the build of a Java product with dependencies with ant.

Here is my project.properties file:

project.name=foo
project.version=1.0.0
thirdpart.commons-cli.version=1.2
thirdpart.guava.version=16.0.1

This is loaded using the following in my build.xml ant script:

<property file="project.properties"/>   

I would like to loop over all properties starting by "thirdpart." and retrieve each time the name between "thirdpart." & ".version" and the value of the property.

Idea behind is then to retrieve the correct jar file from a shared server. Those informations will help me to build up the correct URL to retrieve them, while allowing me to change my dependencies version easily.

How to proceed with ant ? (Thanks for your help).

RandomCoder
  • 6,606
  • 6
  • 22
  • 28

1 Answers1

0

Instead of building your own dependency manager I would suggest using Apache ivy.

Several advantages. Instead of building and populating a shared server, you could download from Maven Central. Standard Maven repository managers (nexus, artifactory, archiva) can be used to host repositories inside your firewall.

Examples:

Your dependencies

Here's an example ivy.xml file to retrieve your dependencies

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

    <configurations>
        <conf name="compile" description="Required to compile application"/>
    </configurations>

    <dependencies>
        <!-- compile dependencies -->
        <dependency org="commons-cli" name="commons-cli" rev="1.2" conf="compile->default"/>
        <dependency org="com.google.guava" name="guava" rev="17.0-rc2" conf="compile->default"/>    
    </dependencies>

</ivy-module>
Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Thanks for this, but the purpose of my question was to evaluate if my need can be fullfilled without switching to an additional technology. Maven build is of course the next step if can't do differently. Question is, can I do differently with pure ant script ? – RandomCoder Apr 17 '14 at 15:22
  • I guess that lack of answers is an answer. Seems it is not possible to loop over ant properties sharing the same prefix. I will take into account your well developed idea to solve my problem. Many thanks ! – RandomCoder Apr 29 '14 at 07:47