As I know, javadoc command line(/usr/bin/javadoc) has an option which named "-notimestamp" to remove the timestamp in the final html file.
How to do the same thing in Apache Ant Javadoc Task?
<javadoc
destdir="${docs.lib}"
author="false"
version="false"
use="true"
...
</javadoc>
Thanks.
Checking the task documentation, it supports nested arg elements. Try something like:
<javadoc
destdir="${docs.lib}"
author="false"
version="false"
use="true"
...>
<arg value="-notimestamp"/>
</javadoc>
There is also an additionalparam attribute. Try:
<javadoc
destdir="${docs.lib}"
author="false"
version="false"
use="true"
additionalparam="-notimestamp"
...
</javadoc>
Related
Is there any way to set an ant property by capturing the output of a shellscript? (or another ant task)
Something like this:
<property name="foo">
<value>
<exec executable="bar" />
</value>
</property>
Thanks!
It seems that exec task has an outputproperty-property, like so:
<exec executable="bar" outputproperty="foo" />
From the ANT exec task
Set the output attribute : Name of a file to which to write the output.
As Marble has suggested - set the outputproperty
When I tested they came out to be mutually exclusive. So set only 1 of them at a time.
To expand on #Nim's answer, complex commands can be generated using arg tags:
<exec executable="/usr/bin/git" outputproperty="git.branch">
<arg value="rev-parse"/>
<arg value="--abbrev-ref"/>
<arg value="HEAD"/>
</exec>
This can be referenced later like:
<attribute name="Git-Branch" value="${git.branch}"/>
I am researching replacements for Ant. I've looked at Gant and Gradle.
Is it possible to kick off a Gradle task from Ant? This is possible in Gant with a taskdef.
<taskdef
name = "gant"
classname = "org.codehaus.gant.ant.Gant"
classpathref = "classpath"
/>
<gant />
Is there something similar Gradle? I'm eager to start migrating from Ant to Gradle, but we have a large Ant infrastructure and any Gradle build scripts I create need to be callable from Ant.
Thanks!
Create a macrodef for gradle, call it just like any other task. Here is the setup and an example...
<!-- Gradle path stuff -->
<property environment="env" />
<condition property="gradle.executable" value="${env.GRADLE_HOME}/bin/gradle.bat" else="${env.GRADLE_HOME}/bin/gradle">
<os family="windows" />
</condition>
<!-- Macro def, gives us an ant 'gradle' task-->
<macrodef name="gradle">
<attribute name="task" />
<sequential>
<exec executable="${gradle.executable}" dir="." failonerror="true">
<arg value="#{task}" />
</exec>
</sequential>
</macrodef>
Example of using the macro def
<!-- Example, call grade with new macro -->
<target name="example">
<gradle task="build" />
</target>
Instead of switching build technology, why not use a combination of ivy and groovy to extend the capabilities of your existing ant builds?
An example is the following posting:
Parse HTML using with an Ant Script
BTW I'm a big fan of Gradle, however, like you I have to live with and support a large ANT legacy :-)
Actually I want to do the same thing and where implemented by calling a sh file and then the sh was calling the gradle but it was too much around the bush and finally the following code made it to work cool..
Hope this will help you..
<property environment="env" />
<property name="gradle.wrapper.executable" location="${env.GRADLE_HOME}/bin/gradle" />
<target name="dependencies-report" description="Creates a text file report of the depdency tree">
<exec executable="${gradle.wrapper.executable}" dir=".">
<arg value="dependencyReport" />
</exec>
</target>
Gradle doesn't offer an Ant task to run a Gradle build from Ant. What you could do is to invoke a Gradle command (like gradle build) from Ant.
In terms of Ant integration, Gradle offers two features: Importing Ant builds, and reusing Ant tasks.
Gradle is very different from Gant. Gradle is an entire new build system; Gant is a thin layer above Ant.
So, I've got a list of ${locales} and ${externs} and I'm trying to do this. It isn't working. Ant says that java doesn't support the nested "for" element. I suspect my approach is wrong. How should I be trying to do this?
<for list="${locales}" param="locale">
<sequential>
<java jar="whatever.jar" fork="true">
<for list="${externs}" param="extern-file">
<arg line='-f "--externs=${extern_dir}/#{extern-file}"' />
</for>
<arg line="... more stuff" />
</java>
</sequential>
</for>
Ant command-line line args support prefixes and suffixes, which might do the trick for this.
If ${externs} is a comma-separted list you'll need to make it space-separated, perhaps using the ant-contrib propertyregex task.
In outline:
<propertyregex property="externs.arg"
input="${externs}"
regexp="," replace=" " />
<for list="${locales}" param="locale">
<sequential>
<java jar="whatever.jar" fork="true">
<arg line="${externs.arg}"
prefix='-f "--externs=${extern_dir}/'
suffix='"' />
<arg line="... more stuff" />
</java>
</sequential>
</for>
Here are some alternative options you could consider.
Implement a custom Ant task to do what you need.
If you own the Java code you are invoking, update it to be more friendly to your requirements, e.g.
2.1. Passing list of locales and externs.
2.2. Accepting input from a file or standard input (both of which you could write to from Ant)
If you don't own the Java code, implement your own script or Java code to provide an adapter from something easy to pass from Ant to the required args of the target.
Is it possible specify Ant listener/logger inside build.xml, not on a command line?
Within the buildfile it's possible to make use of the ant api and create an internal task via scriptdef.
i.e. implemented with groovy:
http://josefbetancourt.wordpress.com/2011/08/18/buildlistener-groovy-scriptdef/
http://octodecillion.com/blog/buildlistener-groovy-scriptdef/
It's also possible to adjust the loglevel inside the buildfile, see :
https://stackoverflow.com/a/5464009/130683
https://stackoverflow.com/a/5479606/130683
It's not in the build file, but you can set the ANT_ARGS env variable to specify the logger
http://wiki.apache.org/ant/TheElementsOfAntStyle
Take a look at the Recorder task.
http://ant.apache.org/manual/Tasks/recorder.html
<target name="real-build">
<exec dir="${basedir}" executable="${ant.command}" failonerror="true">
<arg line="-f build-all.xml target ${ant.logger}" />
</exec>
</target>
i have an ant script as shown below:
<project name="nightly_build" default="main" basedir="checkout">
<target name="init">
<exec executable="C:/Work/Searchversion.exe"/>
<property file="initial.properties"/>
<property file="C:/Work/lastestbuild.properties"/>
<tstamp>
<format property="suffix" pattern="yyyyMMddHHmmss"/>
</tstamp>
</target>
<target name="main" depends="init">
<exec executable="C:/Program Files/True Blue Software/SnapshotCM/wco.exe">
<arg line='-h sinsscm01.sin.ds.net -S"/mobile/6.70_Extensions/6.70.102/ANT_SASE_RELEASE_${Version_Number}" /'/>
</exec>
</target>
</project>
i created the above script to replicate a command: wco -h sinsscm01.sin.ds.net -S"/mobile/6.70_Extensions/6.70.102/ANT_SASE_RELEASE_6.70.102.014" /
and 6.70.102.014 is found inside latestbuild.properties file in the form of:
Version_Number = 6.70.102.014
and this latestbuild.properties file is obtained when i execute C:/Work/Searchversion.exe
but when i execute this ant script using cruisecontrol, in my log file,
[Thread-24] INFO ScriptRunner - [exec] Cannot open snapshot 'sinsscm01.sin.ds.jdsu.net:/mobile/6.70_Extensions/6.70.102/ANT_SASE_RELEASE_${Version_Number}': No such snapshot
where ${Version_Number} should have been 6.70.102.014
How do i tackle this issue?
EDIT 1:
after trial and error and substituting with a built in property ${ant.version}, i realise that my property file could be loaded in correctly over here. can anyone point out my mistake? i dont see anything wrong though
EDIT 2:
Just additional infomation... This is actually a delegate ant script for cruisecontrol(used to perform nightly build). Here is my config.xml file for per minute build:
<cruisecontrol>
<project name="dms" buildafterfailed="true">
<listeners>
<currentbuildstatuslistener file = "logs/dms/status.txt"/>
</listeners>
<bootstrappers>
</bootstrappers>
<modificationset quietperiod="60">
<alwaysbuild/>
</modificationset>
<schedule interval="60">
<ant buildfile="nightly_build.xml" target="main"/>
</schedule>
<log dir="logs/dms">
<merge dir="checkout/dms/build/test-results" />
</log>
<publishers>
</publishers>
</project>
</cruisecontrol>
should properties file be loaded in config.xml?
Try breaking your arguments to wco.exe into separate child elements like this:
<exec executable="C:/Program Files/True Blue Software/SnapshotCM/wco.exe">
<arg value="-h" />
<arg value="sinsscm01.sin.ds.net" />
<arg value="-S" />
<arg value="/mobile/6.70_Extensions/6.70.102/ANT_SASE_RELEASE_${Version_Number}" />
<arg value="/" />
</exec>
I think ant isn't expanding ${Version_Number} because it is inside ' "..." ' in the version you posted.
As mentioned in the docs for <exec> you should avoid use of the <arg line=...> form.
You could add assertions in your init target that the required properties file exists and that the property is defined. For example:
<property name="version.file" value="C:/Work/lastestbuild.properties"/>
<available file="${version.file}" property="version.file.available"/>
<fail unless="version.file.available" message="file [${version.file}] is not available"/>
<property file="${version.file}"/>
<fail unless="version" message="property [version] is not defined"/>
<echo message="version: ${version}"/>
I think that will help you spot that the file does not exist.
I took a look at your other question about this script you're putting together. In the code which writes the version number to file, you use filename latestbuild.properties:
TextWriter latest = new StreamWriter("C:\\Work\\latestbuild.properties");
In your Ant script, you are loading a different filename lastestbuild.properties.
Unless you've fixed it since then, that will be your problem. (If you modified your external script to take the filename as a parameter, and defined the filename once as an Ant property - as in my sample above - it would help you avoid this kind of problem.)
Regarding your discovery that you need to wait for your external script before continuing in Ant, take a look at the Sleep task.