Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load Ant properties from property files on the command line?

I have two property files [one.properties and two.properties]. I want to dynamically load the property files into my Ant project from the command line.

My build file name is build.xml.

Command line:

> ant build [How do I pass the property file names here?]
like image 966
Muthukumar Avatar asked Jul 05 '12 15:07

Muthukumar


1 Answers

Loading property files from the command line

ant -propertyfile one.properties -propertyfile two.properties 

Individual properties may be defined on the command line with the -D flag:

ant -Dmy.property=42


Loading property files from within an Ant project

LoadProperties Ant task

<loadproperties srcfile="one.properties" />
<loadproperties srcfile="two.properties" />

Property Ant task

<property file="one.properties" />
<property file="two.properties" />

Match property files using a pattern

JB Nizet's solution combines concat with fileset:

<target name="init" description="Initialize the project.">
  <mkdir dir="temp" />
  <concat destfile="temp/combined.properties" fixlastline="true">
    <fileset dir="." includes="*.properties" />
  </concat>
  <property file="temp/combined.properties" />
</target>
like image 67
Christopher Peisert Avatar answered Oct 14 '22 02:10

Christopher Peisert