How to recompile with -Xlint:unchecked in Ant build task?
Add the following element in <javac></javac> section: <compilerarg value=”-Xlint:unchecked” />
Add the following element in <javac></javac> section: <compilerarg value=”-Xlint:unchecked” />
I use scriptdef to create a javascript tag to substring, for exemple: <project> <scriptdef name=”substring” language=”javascript”> <attribute name=”text” /> <attribute name=”start” /> <attribute name=”end” /> <attribute name=”property” /> <![CDATA[ var text = attributes.get(“text”); var start = attributes.get(“start”); var end = attributes.get(“end”) || text.length(); project.setProperty(attributes.get(“property”), text.substring(start, end)); ]]> </scriptdef> …….. <target …> <substring text=”asdfasdfasdf” start=”2″ end=”10″ … Read more
The former: <target name=”all” depends=”compile,jsps”> This is documented in the Ant Manual.
Ant uses XML, so you can use the normal XML entities like ": tasklist /FI "IMAGENAME eq java.exe" /FI "MEMUSAGE gt 50000"
<path id=”build.classpath”> <fileset dir=”${basedir}”> <include name=”lib/*.jar”/> </fileset> </path> <pathconvert property=”manifest.classpath” pathsep=” “> <path refid=”build.classpath”/> <mapper> <chainedmapper> <flattenmapper/> <globmapper from=”*.jar” to=”lib/*.jar”/> </chainedmapper> </mapper> </pathconvert> <target depends=”compile” name=”buildjar”> <jar jarfile=”${basedir}/${test.jar}”> <fileset dir=”${build}” /> <manifest> <attribute name=”Main-Class” value=”com.mycompany.TestMain”/> <attribute name=”Class-Path” value=”${manifest.classpath}”/> </manifest> </jar> </target> For further information check out this article.
I would modify your jar task to include multiple filesets; one for the classes and one for the source files. <jar destfile=”${target.dir}/my-app.jar”> <fileset dir=”${target.dir}/classes” /> <fileset dir=”${src.dir}” includes=”**/*.java”/> </jar> Packaging should be treated as a separate concern from compiling. This will give you more flexibility. For example, you may want to add other filesets to … Read more
This statement: <property file=”${user.home}/build.properties”/> Reads a property file(i.e. all properties in that file), and does not set the property named file. This would be correct. You first set a property and then echo it: <property name=”file” value=”${user.home}/build.properties”/> <echo message=”${file}” />
An Ant target can have an optional if or unless clause. This means to execute the task only if the property is set, with an if clause, or is unset with the unless clause1. Interestingly, that if or unless clause is checked after any dependent task is first executed. This means, you can do this … Read more
Is this for an <exec> task? You can set environment variables when you run an <exec> task: <exec executable=”${my.command}”> <env key=”foo” value=”bar”/> <arg line=”some value”/> </exec> You can use <property environment=”env”/> to expand the path: <property environment=”env”/> <exec executable=”${my.command}”> <env key=”PATH” value=”${env.PATH}:${my.directory}”/> </exec> If this is for some custom task that requires an environment variable, … Read more
Use the PathConvert task: <fileset id=”myfileset” dir=”../sounds”> <include name=”*.wav” /> <include name=”*.ogg” /> </fileset> <pathconvert pathsep=”${line.separator}” property=”sounds” refid=”myfileset”> <!– Add this if you want the path stripped –> <mapper> <flattenmapper /> </mapper> </pathconvert> <echo file=”sounds.txt”>${sounds}</echo>