How to pull out a substring in Ant

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

Generate manifest class-path from in Ant

<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.

generate jars with source code using Ant

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

How in Ant output values of properties?

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}” />

Execute Ant task just if a condition is met

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

How to set the path environment variable from ant script

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

How can I print a fileset to a file, one file name per line?

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>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)