ant

Ant regexp. Read value of matched expression.

I need to replace all occurrence of some regular expression in xml file with proper values loaded from property file. As example in xml file I have < port=${jnpPort}/> in property file I have port=3333 I want to have xml file with entries like < port=3333/> Now using <replaceregexp match="\$\{(.*)\}" replace="${\1}" flags="g" byli...

Specifying the Eclipse compiler completely from _within_ build.xml

As an experiment we want to build our products using the Eclipse java compiler (ecj-3.5.jar downloaded from eclipse.org) on the runtime version of Java 6 instead of the JDK, and as I understand it, it is a matter of adding this jar to the ant classpath, and setting the build.compiler property to point to the adapter. By including <pro...

How to run ant from an Eclipse plugin, send output to an Eclipse console, and capture the build result (success/failure)?

From within an Eclipse plugin, I'd like to run an Ant build script. I also want to display the Ant output to the user, by displaying it in an Eclipse console. Finally, I also want to wait for the Ant build to be finished, and capture the result: did the build succeed or fail? I found three ways to run an Ant script from eclipse: Ins...

Preserve file permissions when unzipping and the zipping files using ant

I'm writing an ant build.xml file which does the following: Takes a zipped folder (.zip) Unzips it Adds a number of files Zips up the resulting files An extract of the code from build.xml: <!-- Unzip SDK to a temporary directory --> <unzip src="${zipFile}" dest="tmp"/> <!-- pull in the files from another directory --> <copy todir="...

Netbeans: "Run -> Test Project" doesn't do anything.

Hello, everyone! I have many JUnit tests, which are all created by Netbeans' assistant (so nothing customized). I can run every test manually by doing "Test File" (Ctrl+F6). But when I use "Run -> Test Project", the message "No Tests executed" is displayed. Do I have to register every JUnit test somewhere? Or what could be the problem...

How to emulate "-lib foo.jar" from _within_ build.xml

By specifying "-lib foo.jar" to ant I get the behaviour that the classes in foo.jar is added to the ant classloader and are available for various tasks taking a class name argument. I'd like to be able to specify the same behaviour but only from inside build.xml (so we can do this on a vanilla ant). For taskdefs we have functioning cod...

Passing parameter to hbm2ddl

I have parametrized persistence.xml. I am trying to generate ddl schema using hbm2ddl. How can i pass parameters to this tool ? My persistence.xml looks like <property name="hibernate.connection.driver_class" value="${persistence.connection.driver.class}"/> <property name="hibernate.dialect" value="${persistence.dialect}"/> <property n...

Ivy loading unnecessary dependencies?

I'm migrating a maven project to ant + ivy (it's an arbitrary decision, and it has to be done ). The thing is that comparing both WAR files, the ant and the maven one, the former has a lot more 3rd party jars than the first one... At first I thought that they were transitive dependencies but when I run mvn dependency:tree they don't...

How to split an fileset in Ant into multiple sets

I have a set of files that I am picking up in an ant build, which I want to split into equal sized sub sets. What is a good simple way to do this in Ant without adding custom tasks. Example: Fileset contains TestOne.java TestTwo.java TestThree.java TestFour.java TestFive.java TestSix.java I would like 3 filesets Fileset1 TestOn...

Ant scp task not working, even with jsch on ant/lib

I need to copy a war file via scp. I have added the jsch-0.1.42.jar to $ANT_HOME/lib but I'm still getting this error: Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.Scp was not found. This looks like one of Ant's optional components. This is the result of running ant -diagnostics just in case: http://...

Ant Build faling with correct class path and database properties.

Buildfile: C:\MyJava\workspace\springapp\build.xml build: buildtests: dropTables: [echo] DROP TABLES USING: org.hsqldb.jdbcDriver jdbc:hsqldb:hsql//localhost [sql] Executing commands [sql] 1 of 1 SQL statements executed successfully createTables: [echo] CREATE TABLES USING: org.hsqldb.jdbcDriver jdbc:hsqldb:hsql//lo...

EXEC args (value) with quotes on linux from ANT script

bash shell: ./mimic_cmd "startDaemon()" Corresponding ANT code: <exec failonerror="true" executable="/bin/mimic_cmd"> <arg value='"startDaemon()"' /> </exec> Does the ANT code exactly represent the above command at the bash shell? Based on the debug info, it looks like it: [exec] Executing '/bin/mimic_cmd' with arguments...

How to add system property equivalent to java -D in Ant

Hi. I need to set java -Djava.library.path=/some/path and I want to do it when I am running my ant script, building my jar. I think I have to use <sysproperty key="java.library.path" value="/some/path"/> but it doesnt work. I cannot make the syntax work. The only thing I have Googled and found is sysproperty in conjunction with <...

Ant common usage calling java methods

What is the common usage of using ant to execute a java class or method. I have multiple methods within on class that I need to call if ant run or restore are run. Both run and restore are methods of the same java class but, I cannot seem to get ant run to execute Class.beginExecution() and ant restore to execute Class.beginRestore().. ...

Launching Windows Explorer from ANT?

Is there any way of launching Windows Explorer from ant without stopping the build? Here is what I have so far: <project default="default"> <target name="default"> <fail unless="customerName"> You need to set the customerName. -DcustomerName=Value </fail> <fail unless="htmlCode"> You need to set the htmlCode. -Dcusto...

Is it possible to include / exclude a list of files by refid in ant?

We currently have an ant task that contains something similar to the following: <filelist dir="${css.dir}" id="ordered_css"> <file name="interface/foo.css" /> <file name="pages/monkey.css" /> <file name="pages/ninja.css" /> <file name="pages/sidebar.css" /> <file name="pages/bar.css" /> ...

ANT delete task and Windows 7 UAC permissions

When I do a simple delete of the contents of a folder, I get an error: <delete includeemptydirs="true"> <fileset dir="${developmentenvironment.www.dir}" includes="**/*"/> </delete> C:\Users\...\build.xml:42: Unable to delete file C:\...\www\appserv\AUTHORS.txt When, I try to delete the file in the OS, it requires elevated permiss...

Is there a way to loop over files in ant without using ant-contrib?

I know ant-contrib has a for loop, but I'd rather avoid adding it to my project unless necessary. It feels like I'm missing something obvious here. I just want to execute a task for a lot of files. ...

Ant Tokenizer: Selecting an individual Token

I have the following ant task: <loadfile property="proj.version" srcfile="build.py"> <filterchain> <striplinecomments> <comment value="#"/> </striplinecomments> <linecontains> <contains value="Version" /> </linecontains> </filterchain> </loadfile> <echo message="${proj.vers...

Simple Mavenization of existing Ant build files

If you have an existing ant file, what is the best way to convert the project to Maven. I've checked out things like fAnt, but if I'm going to mess with this stuff, I might as well go full-bore for Maven. I expected something to exist that can just start the pom.xml for me based on the existing build.xml, but I haven't found anything yet...