0

The PropertyFile task is pretty perfect for what I want to do, and the following illustrates what I want to do:

    <PropertyFile file="${warSrc}/web/WEB-INF/my.properties">
        <entry key="compilationDate" operation="=" type="date" default="now" />
    </PropertyFile>

I just want to set that property to the date the compile script was last run. Unfortunately, this task appears to not be distributed with my ant bundle, and while I could alter my workspace to have it, that means everyone who brings this project in will have to do the same, and I want to use just the core ant tasks to avoid that extra config step.

Some kind of usage of the Replace tasks seems perfect, but I am not sure how to use those to look for a line starting with compilationDate=, and then replace the rest of the content of the line with the current date.

Entropy
  • 1,219
  • 6
  • 21
  • 45

1 Answers1

0

So, the question probably reveals that I am a ant neophyte. I figured out a couple things most regular ant users already knew. First, that PropertyFile is an optional task in ant.jar, so no additional importing was needed, but it is an optional task which evidently does not get made available by default.

The following syntax defines the propertyfile task, and then ran it and it did almost perfectly what I wanted.

    <taskdef name="propertyfile" classname="org.apache.tools.ant.taskdefs.optional.PropertyFile" >
        <classpath>
            <fileset dir="${ant.library.dir}">
                <include name="ant.jar" />
            </fileset>
        </classpath>
    </taskdef>
    <echo message="task defined" />

    <propertyfile file="my.properties">
        <entry key="version" operation="=" type="date" default="now" />
    </propertyfile>
Entropy
  • 1,219
  • 6
  • 21
  • 45