I wrote a build script in ant. The source code of my project is versioned in svn.
As a part of my project I had to write a java class, that contains information from subversion. In general, the build script works fine. All needed information will be gathered, except one. This is the name of the author who commited the last change in the reporsitory. Though I read the manual, I still come up with any ideas.
My question to you is: does exist a way to get also this detail with an ant script?
Thanks
EDIT:
<target name="version" description="set version number">
<echo message="Setting version information ..." />
<copy file="build/Version.java.template"
tofile="./cq/apps/src/de/anna/util/Version.java" />
<tstamp>
<format property="TODAY_De"
pattern="yyyy/MM/dd HH:mm:ss"
locale="de,De"/>
</tstamp>
<replace file="./cq/apps/src/de/anna/util/Version.java">
<replacefilter token="@APPNAME@" value="${app.name}" />
<replacefilter token="@BUILDVERSION@" value="${build.number}" />
<replacefilter token="@BUILDDATE@" value="${TODAY_De}" />
</replace>
<exec executable="${version.tool}" spawn="false" dir=".">
<arg line=". cq/apps/src/de/anna/Util/Version.java cq/apps/src/de/anna/Util/Version.java" />
</exec>
</target>
What I want to add in file Version.java, who is the author of last commit and the id of the change entry. (I think/thought $Author$ and $Id$ were the variables)
Forget about SubWCRev and think about Subversion. That’s what your working with.
In Subversion, you need to set a property called
svn:keywords, and set that value to the keywords you want to use. This is explained in the on line Subversion manual in Keyword Substitution.By using the
svn:keywordsproperty, you have the Subversion repository handle the variable names for you. For example, you have a file calledinformation.txtthat looks like this:Checking that file into Subversion doesn’t change
$Author$or$Revision$.Now, you set the property
svn:keywordson theinformation.txtfile:You can do this through TortoiseSVN too via the Context Menu TortoiseSVN–>Properties
Now, when you look at the file, the fields changed:
Not what you want? Another thing you can do is simply execute
svn infoand get the properties you want in XML format. Then you can use the<xmlProperties>task to read them in as properties:I use the
<exec>task to grab the Subversion information and put it in the property${svn.info}. I then use the<echo>task to output it to the${target.dir}/info.txtfile. After that, I can read the file via the<xmlproperty>task and pull out the information below.From there, I now have all the Subversion revision and repository information stored in various properties.
If you know resource collections, you can actually do this without first writing the file to
${target}/info.txtHope this is what you’re looking for.