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.

Use Ant for running program with command line arguments

Extending Richard Cook’s answer. Here’s the ant task to run any program (including, but not limited to Java programs): <target name=”run”> <exec executable=”name-of-executable”> <arg value=”${arg0}”/> <arg value=”${arg1}”/> </exec> </target> Here’s the task to run a Java program from a .jar file: <target name=”run-java”> <java jar=”path for jar”> <arg value=”${arg0}”/> <arg value=”${arg1}”/> </java> </target> You can … Read more

Ant to Maven – multiple build targets

You could do this with profiles… If you really wanted to use two separate profiles and customize the JAR plugin to include and exclude patterns of class and package names, you could easily do this by putting something like this in your POM: <profiles> <profile> <id>everything</id> <build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <classifier>everything</classifier> <includes> <include>**/*</include> </includes> … Read more

javac1.8 class not found

Class not found: javac1.8 This error is known to happen with Apache Ant versions less than 1.9.0 – which aren’t compatible with Java 8. If you’re using a version of Ant < 1.9.0, you should update to a 1.9.x release. Here is the related bug report: https://issues.apache.org/bugzilla/show_bug.cgi?id=53347 Btw, if you just want to compile with … Read more

Ant is using wrong java version

Just had this issue, it happened because I’d first added the build file to the ant-view when the default JRE was 1.6. There was no project-specific JRE and I changed the default to 1.5, even eclipse was running in 1.5, and JAVA_HOME was 1.5 too. Running the ant target from the command line used JRE … Read more

How do I use Nant/Ant naming patterns?

The rules are: a single star (*) matches zero or more characters within a path name a double star (**) matches zero or more characters across directory levels a question mark (?) matches exactly one character within a path name Another way to think about it is double star (**) matches slash (/) but single … Read more

comparing databases and generating sql script using liquibase

Obtaining the SQL statements, representing the diff between two databases, is a two step operation: Generate the XML “diff” changelog Generate SQL statements Example This example requires a liquibase.properties file (simplifies the command-line parameters): classpath=/path/to/jdbc/jdbc.jar driver=org.Driver url=jdbc:db_url1 username=user1 password=pass1 referenceUrl=jdbc:db_url2 referenceUsername=user2 referencePassword=pass2 changeLogFile=diff.xml Now run the following commands to create the SQL statements: liquibase diffChangeLog … Read more

Run ant from Java

Is there a tutorial on how to run Ant from Java? Part of my answer to this question might help: See this article and this article: File buildFile = new File(“build.xml”); Project p = new Project(); p.setUserProperty(“ant.file”, buildFile.getAbsolutePath()); p.init(); ProjectHelper helper = ProjectHelper.getProjectHelper(); p.addReference(“ant.projectHelper”, helper); helper.parse(p, buildFile); p.executeTarget(p.getDefaultTarget());

Custom JUnit Report?

The junitreport task uses XSLT to produce the report from the XML files generated by the junittask. You can customize the output by specifying your own XSLT using the styledir attribute of the nested report element: <!– use reportstyle/junit-frames.xsl to produce the report –> <report styledir=”reportstyle” format=”frames” todir=”testreport”/> For customizing the the output, one option … Read more