I have a ant build script which creates a war file. The file content are as follows.
<?xml version="1.0" encoding="UTF-8"?>
<project name="TestProj" default="war" basedir=".">
<property name="project-name" value="${ant.project.name}" />
<property name="builder" value="IaasTeam" />
<property name="war-file-name" value="${project-name}.war" />
<property name="source-directory" value="src" />
<property name="classes-directory" value="build/classes" />
<property name="web-directory" value="WebContent" />
<property name="web-xml-file" value="WebContent/WEB-INF/web.xml" />
<property name="lib.dir" value="WebContent/WEB-INF/lib" />
<property name="catalina.home" value="../../outside/project/lib"/>
<tstamp prefix="build-info">
<format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
<format property="current-time" pattern="hh:mm:ss a z" locale="en" />
</tstamp>
<property name="build-directory" value="build" />
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${catalina.home}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac includeantruntime="false" srcdir="src" destdir="build/classes" classpathref="classpath" />
</target>
<target name="war" depends="clean,compile">
<mkdir dir="${build-directory}" />
<delete file="${build-directory}/${war-file-name}" />
<war warfile="${build-directory}/${war-file-name}" webxml="${web-xml-file}">
<classes dir="${classes-directory}" />
<fileset dir="${web-directory}">
<!-- Need to exclude it since webxml is an attribute of the war tag above -->
<exclude name="WEB-INF/web.xml" />
</fileset>
<manifest>
<attribute name="Built-By" value="${builder}" />
<attribute name="Built-On" value="${build-info.current-date}" />
<attribute name="Built-At" value="${build-info.current-time}" />
</manifest>
</war>
</target>
I am using Jenkins as a build server (this is hosted on different machine kind of DEV environment).
I also use Gitlab as a repository and after pushing the latest code I have a hook for Jenkins job which gets triggered automatically and calls this build.xml.
Now the issues here is that when I run this script on my local machine everything works well but when Jenkins execute this it fails during the compilation phase giving me below error.
compile:
[mkdir] Created dir: /app/infra/jenkins/workspace/TestProj/build/classes
[javac] Compiling 49 source files to /app/infra/jenkins/workspace/TestProj/build/classes
BUILD FAILED
/app/infra/jenkins/workspace/TestProj/build.xml:27: /app/infra/jenkins/outside/project/lib does not exist.
The reason for this issue is the build server does not have any directoy called outside/project/lib.
The only reason of adding this directory in my build.xml is to have the container specific jar files ready for compiling.
How can I fix this issue?
Do I need to copy container specific jars on my build server? Or is there any way to tell Jenkins that not to copy this external jars but just use them for compilation.
Where would Jenkins find the jars? They need to be accessible otherwise your build will fail. If you don't want to have the files checked in (which is very sensible), you could use Apache Ivy to download them for you.
This is the most common way of handling the situation you're having. Using a dependency management framework like Ivy (or Maven, or similar) will save you a lot of headaches down the line. I recommend you have a look at their tutorial. After you set it up, your ant build will take care of downloading the files you need.
Related
I have a problem with Ant Build Tool.
First, below you can see my project structure:
and the content of my build.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<project name="addonGenerator" default="main" basedir=".">
<property name="projectName" value="addonGenerator"/>
<property name="src.dir" location="src"/>
<property name="build.dir" location="bin"/>
<property name="dist.dir" location="dist"/>
<target name="compile" description="compile the source ">
<mkdir dir="${build.dir}"/>
<javac srcdir="${src.dir}" destdir="${build.dir}">
<classpath>
<pathelement path="lib/velocity-1.7.jar"/>
<pathelement path="lib/log4j-1.2.16.jar"/>
</classpath>
</javac>
</target>
<target name="dist" description="package, output to JAR">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${dist.dir}/${projectName}.jar" basedir="${build.dir}">
<zipgroupfileset dir="lib" includes="velocity-1.7.jar" />
<zipgroupfileset dir="lib" includes="log4j-1.2.16.jar" />
<manifest>
<attribute name="${projectName}" value="main"/>
<attribute name="Main-Class" value="main.java.AddonGenerator"/>
</manifest>
</jar>
</target>
<target name="clean" description="clean up">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="main" depends="clean, compile, dist"/>
</project>
I don't know how setup the Ant build.xml to build and run my project with external libraries and the java property file generator.properties
To include your generator.properties file in the .jar file, add your resources directory when building the .jar:
<jar jarfile="${dist.dir}/${projectName}.jar" basedir="${build.dir}">
<fileset dir="src/main/java/resources"/>
Since you are currently building a “fat jar” (by directly including the contents of your library .jars in your application .jar), you can run by simply invoking your .jar file. Such a target obviously requires the .jar file to be built, so it makes sense to depend on the "dist" target:
<target name="run" depends="dist">
<java jar="${dist.dir}/${projectName}.jar"/>
</target>
On another note, I don’t think you want to pass src as your source directory, unless your classes actually declare themselves with ‘package main.java;’ (which they shouldn’t). You should pass the actual root of your packages to the javac task:
<property name="src.dir" location="src/main/java"/>
You should also make the "dist" target depend on "compile", since, well, it depends on having compiled classes available.
I also would suggest that your default target, "main", avoid calling the "clean" target. You should not clean before every single build; that defeats one of the most useful benefits of Ant, namely the ability to update only the things that need to be updated. You should only clean when you need to, with a command like ant clean compile or simply ant clean.
Note that once "dist" depends on "compile", and once "main" no longer calls "clean", you can simply remove the "main" target and change your project’s default target to "dist". When you think about it, this makes sense: the default action is to build and package the application.
I need to create build file for ant to build my JavaFX project, I have searched a lot, but nothing helped me. It still show errors but compiles. When I tries to run jar file - exceptions. I have tried different paths, but still nothing.
Here is my build.xml.
<?xml version="1.0" encoding="UTF-8" ?>
<project name="JDBC Ant Project" default="default" basedir="." xmlns:**fx="javafx:com.sun.javafx.tools.ant"**(Uri is not registered)>
<property name="src.dir" location="src"/>
<property name="build.dir" location="classes"/>
<property name="out.dir" location="out"/>
<property name="docs.dir" location="docs"/>
<property name="bin.dir" location="bin"/>
<property name="lib.dir" location="lib"/>
<property name="jar.name" value="javafxtest.jar"/>
<property name="sdk.dir" location="/usr/lib/jvm/java-8-oracle/lib"/>
<target name="default" depends="clean,compile">
<path id="fxant">
<filelist>
<file name="/usr/lib/jvm/java-8-oracle/lib/ant-javafx.jar"/>
<file name="/usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar"/>
</filelist>
</path>
<*taskdef*(Failed to load types) resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpathref="fxant"/>
<fx:**application** id="HelloWorldID"
name="JDBC Java FX"
mainClass="Main"/>
<fx:resources id="appRes">
<fx:fileset dir="${out.dir}" includes="HelloWorld.jar"/>
</fx:resources>
<fx:jar destfile="${out.dir}/${jar.name}">
<fx:application refid="HelloWorldID"/>
<fx:resources refid="appRes"/>
<fileset dir="${build.dir}"/>
</fx:jar>
<fx:**deploy width**="300" **height**="250"
**outdir**="." **embedJNLP**="true"
**outfile**="helloworld">
<fx:**application** refId="HelloWorldID"/>
<**fx:resources** refid="appRes"/>
<**fx:info** title="JavaFX Hello World Application"
vendor="Oracle Corporation"/>
</fx:**deploy**>
</target>
<target name="clean">
<echo>Performing clean target</echo>
<delete dir="${build.dir}"/>
<delete dir="${docs.dir}"/>
<delete dir="${out.dir}"/>
</target>
<target name="init">
<echo>Performing init target</echo>
<mkdir dir="${build.dir}"/>
<mkdir dir="${docs.dir}"/>
<mkdir dir="${out.dir}"/>
</target>
<target name="compile" depends="clean, init">
<echo>Performing compiling</echo>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${build.dir}">
<classpath refid="build.classpath"/>
</javac>
</target>
<path id="build.classpath">
<fileset dir="${lib.dir}" casesensitive="no">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="javadoc" depends="compile">
<javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
<!-- Define which files / directory should get included, we include all -->
<fileset dir="${src.dir}">
<include name="**"/>
<exclude name="**/resources/**"/>
</fileset>
</javadoc>
</target>
<target name="build" depends="compile">
<jar destfile="${out.dir}/${jar.name}" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="Main"/>
</manifest>
</jar>
</target>
<target name="main" depends="compile, build, javadoc">
<description>Main target</description>
</target>
</project>
** is fully "red" in my IDEA (Intellij IDEA.
* is underlined .
But nevertheless it builds using ant -f build.xml. But when I tries to run jar file I am getting next exceptions.
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.....
.....
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2438)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2413)
at Main.start(Unknown Source)
Update on copying resources using JavaFX ant tasks
There is no folder with fxml, css and other files in my output jar file. If put it manually everything works, how to say ant to exlictly include folder ?
Based on the Java Deployment Tutorial JavaFX Ant Tasks HelloWorld build.xml sample, and modifying it to add a resources directory (which is a sibling to the project src, classes and dist directories). Place your fxml and css in the resources directory to get them included in the jar. The directory structure of the copied files will match the directory structure of the resources directory, so if you just put them in the resources directory with no sub-directories, the files will show up in the root of the jar file (so when you use the resources reference them relative to the root (e.g. FXMLLoader.load(getResource("/main.fxml"))). I made these modifications without testing as I don't use ant for builds anymore.
<property name="build.src.dir" value="src"/>
<property name="build.resources.dir" value="resources"/>
<property name="build.classes.dir" value="classes"/>
<property name="build.dist.dir" value="dist"/>
<target name="default" depends="clean,compile">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath="${JAVA_HOME}/lib/ant-javafx.jar"/>
<fx:application id="HelloWorldID"
name="JavaFXHelloWorldApp"
mainClass="HelloWorld"/>
<fx:resources id="appRes">
<fx:fileset dir="${build.dist.dir}" includes="HelloWorld.jar"/>
</fx:resources>
<fx:jar destfile="${build.dist.dir}/HelloWorld.jar">
<fx:application refid="HelloWorldID"/>
<fx:resources refid="appRes"/>
<fileset dir="${build.classes.dir}"/>
<fileset dir="${build.resources.dir}"/>
</fx:jar>
. . .
</target>
You likely have a runtime issue not a build issue
It would seem that the application builds fine and you are getting a runtime error trying to run your application, either due to an issue in your application code or because the resources required for execution are not present.
Try a simpler application which does not include any FXML and build and execute that - if that works than either your error was in your application code or in the code which copies the FXML resources to your build package.
On Intellij syntax highlighting of JavaFX Ant tasks
Regarding the "URI is not registered" error in Intellij, that is a bit of a red-herring. It just means that you haven't registered the schema for the fx namespace with Idea, so Idea cannot validate the document (and provide context sensitive code completion on XML tags). As long as you haven't made syntax or structure errors in your XML (which you probably haven't or ant would likely reject it), then you can ignore such error messages if you wish.
You can find more information on this here:
Intellij Idea Help - Referencing DTD or Schema
Note: I don't think Oracle provide a full XML schema for the JavaFX ant tasks, so it will probably not be possible for you to configure Idea to validate the JavaFX ant task elements of your ant build.xml file. However, that should not prevent you from building your application - your best policy is probably to configure Idea to ignore the JavaFX ant tasks XML schema, so it no longer displays annoying and misdirecting red highlights on your build.xml file.
Alternative Technology
You may (or may not) find using the JavaFX Maven plugin or JavaFX Gradle plugin a better solution for you than using the JavaFX Ant Tasks directly.
I have a openCV project in eclipse. Now I am trying to make it runnable Jar but not able to launch it , once trying to run the jar.
I tried following -
https://groups.google.com/forum/#!topic/javacv/ziqKIb7PgYk
but I couldn't understand properly. Can anyone explain the proper way to do the needful.
in my System , OpenCV is installed. Once I try to run the project from
eclipse , everything works fine . but when I try to do the same from
runnabelJar it doesn't. The problem I found it that I didn't include
.dll files , so how should I do it.
I finally got the solution. Yes we can easily make Runnable jars from eclipse while using javaCV , no need for ant or maven build.
No Need to set the class path with OpenCV, which you are only using javaCV and no intention for jni build.
Create a Java Project.
Copy all the jars.You can avoid x86 or linux or non required jars as
well.
Find the jre version , if 32 bit , get the path of OpenCV 32 bits
libraries else 64 bits. You can place those dlls any where in the
system.. No need to place it any specific path.
Go to OpenCV jar , expand it , click on Native Library Location ,
edit and browse the path
Thats it , job Done , now make Runnable jar or anything , it will work like charm.
Once you provide your runnable jar to any user, then either user's openCV path should be set in the class path or you provide the dlls , and you Load the library in any static block.
Building a jar with ANT (for javacv 0.9):
install opencv (and/or ffmpeg)
download javacv from https://github.com/bytedeco/javacv
Create a Java Project and create the directories 'lib', 'lib32' and 'lib64' in the root
and add the x64 jars from javacv to lib64 - same for lib32 and the others without bit-version in lib
Add the following jars to the buildpaht of your project (Add External JARs...) and set the Native library paths for opencv (and/or ffmpeg)
Sample Test class
public class Main {
public static void main(String[] args) throws Exception, IOException {
OpenCVFrameGrabber frameGrabber = new OpenCVFrameGrabber(new File(".\\tmp_files\\small.mp4"));
frameGrabber.start();
IplImage origImg = frameGrabber.grab();
//create canvas frame named 'Demo'
final CanvasFrame canvas = new CanvasFrame("Demo");
//Show image in canvas frame
canvas.showImage(origImg);
//This will close canvas frame on exit
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
}
ANT -script
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="main" name="Main">
<property environment="env"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<property name="build.dir" value="bin"/>
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="lib32.dir" value="lib32"/>
<property name="lib64.dir" value="lib64"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="jar.file" value="${jar.dir}/buildOpenCvTest32_64.jar"/>
<property name="manifest.file" value="${jar.dir}/MANIFEST.MF"/>
<property name="main.class" value="test.Main"/>
<path id="external.jars">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${libV.dir}" includes="**/*.jar"/>
</path>
<path id="project.classpath">
<pathelement location="${src.dir}"/>
<path refid="external.jars" />
</path>
<target name="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${jar.dir}"/>
<copy includeemptydirs="false" todir="${build.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="cleanall" depends="clean"/>
<target name="build" depends="init">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}" classpathref="project.classpath">
<src path="${src.dir}"/>
</javac>
</target>
<target name="build-jar" depends="build">
<delete file="${jar.file}" />
<delete file="${manifest.file}" />
<manifest file="${manifest.file}" >
<attribute name="built-by" value="${user.name}" />
<attribute name="Main-Class" value="${main.class}" />
</manifest>
<jar destfile="${jar.file}"
basedir="${build.dir}"
manifest="${manifest.file}">
<fileset dir="${classes.dir}" includes="**/*.class" />
<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />
<zipgroupfileset dir="${lib32.dir}" includes="**/*.jar" />
<zipgroupfileset dir="${lib64.dir}" includes="**/*.jar" />
</jar>
</target>
<target name="main" depends="build-jar">
<description>Main target</description>
</target>
</project>
Run ANT - the jar should run on every 32 and 64bit Windows system. same should work for ffmpeg library and for unix systems
I have the following setup for my application:
The project TestAll currently contain a java file that run all the TestAll javafiles in all my other projects and this works as expected. The problem im facing is that I want this TestAll.java to be run from a ant script and have it record the result in a report file. This javafile is dependent on all the other projects in my application.
This is what I have so far:
<?xml version="1.0"?>
<project name="Ant-Test" default="main" basedir=".">
<!-- Sets variables which can later be used. -->
<property name="src.dir" location="" />
<property name="build.dir" location="../bin" />
<property name="dist.dir" location="../dist" />
<property name="lib.dir" location="../lib" />
<property name="test.dir" location="../src" />
<property name="test.report.dir" location="../testreport" />
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Define the classpath which includes the junit.jar and the classes after compiling-->
<path id="junit.class.path">
<pathelement location="${lib.dir}/junit.jar" />
<pathelement location="${build.dir}" />
</path>
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${test.report.dir}" />
</target>
<!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile" depends="clean, makedir">
<javac srcdir="${src.dir}" destdir="${build.dir}">
<classpath refid="junit.class.path" />
</javac>
</target>
<target name="junit" depends="compile">
<junit printsummary="on" fork="true" haltonfailure="yes">
<classpath refid="junit.class.path" />
<formatter type="xml" />
<batchtest todir="${test.report.dir}">
<fileset dir="${src.dir}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<!--Creates the deployable jar file -->
<target name="jar" depends="compile">
<jar destfile="${dist.dir}\se.testall.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="test.Main" />
</manifest>
</jar>
</target>
<target name="main" depends="compile, jar, junit">
<description>Main target</description>
</target>
</project>
And the errors im getting is:
[javac] Compiling 1 source file to C:\Repositories\MyProject\TestAllProjects\bin
[javac] C:\Repositories\MyProject\TestAllProjects\src\se\testall\src\TestAllClass.java:6: error: package se.tlv.AProject.testall does not exist
[javac] import se.tlv.AnotherProject.testall.*;
[javac] ^
[javac] C:\Repositories\TestAllProjects\src\se\src\TestAllClass.java:7: error: package se.AnotherProject.testall does not exist
..and so on for all the internal imports in my TestAll project
This is most likley a classpath error where ANT in unable to find the files it needs, but I have no idea how to resolve it and have been trying for almost a full day. Any help is appreciated
The classpath provided to the javac task is: the junit jar, the build directory and the current directory.
Unless the current directory (where build.xml is located) is se, the javac task won't be able to find any java files to compile them.
Given that, the classpath for the javac task will need to include a path to each se directory in each project.
Edit:
Note: Unless you're planning on packaging the tests with the rest of the code, you should have two javac tasks that build to a build directory and a test build directory, then provide a path to each of those to junit so it can run the tests, but provide only the build directory path to the jar task.
I'm at my wit's end. I'm spending more time working on getting my build to work rather than actually developing software. I'm currently working on large-scale Java web application based on Tomcat 6.
Currently the code-base is about 25k LOC (although that's not quite representative because some of that is autogenerated for web services -- but the take away is that it's big) and I've been working exclusively with eclipse to do everything from debugging, to build path management to building. In the past, eclipse has always been more than enough, but I've never worked on a project this large before.
The first problem I had was when I started adding GWT content. It worked ok, but the build process was a bit hacky: I had to manually compile and then copy the js output into the appropriate directory and debugging was a nightmare (I realize some of those problems are just GWT and the way it works...). Now, the issue I'm running into is attempting to work on the project on a Windows machine (I had been working on a Mac, and will continue to work from a Mac from time to time). Eclipse added the Mac OS JVM libraries to the build path which, of course, Windows can't find.
I asked a question about working in two different environments and most of the answers pertained to using a build tool like Ant+Ivy or Maven. I've started investigating Maven and attempting to get my project to use it, but it's just been one headache after another and I haven't even begun to try to actually execute/debug my application in Tomcat through eclipse. The most frustrating part of all of this is it, to me, seems like these build tools are exceptionally complex (and to be fair, incredibly flexible) but, at least initially, make life even more difficult while you try to figure out how to simply compile a Java file.
So all of that to say, does anybody have suggestions for how to simplify this scenario? Dependency management would be nice, but I don't mind hunting down the JARs myself. The biggest thing I need is something that will just get out of my way and let me work on what I'm actually trying to work on, not spend hours debugging my typos in an xml file used by the build system.
Thanks in advance
I agree. You don't need Maven; you don't need Ivy. Start with Ant.
Here's a relatively generic Ant build.xml. Customize it as you wish.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xslt-converter" basedir="." default="package">
<property name="version" value="1.6"/>
<property name="haltonfailure" value="no"/>
<property name="out" value="out"/>
<property name="production.src" value="src"/>
<property name="production.lib" value="lib"/>
<property name="production.resources" value="config"/>
<property name="production.classes" value="${out}/production/${ant.project.name}"/>
<property name="test.src" value="test"/>
<property name="test.lib" value="lib"/>
<property name="test.resources" value="config"/>
<property name="test.classes" value="${out}/test/${ant.project.name}"/>
<property name="exploded" value="out/exploded/${ant.project.name}"/>
<property name="exploded.classes" value="${exploded}/WEB-INF/classes"/>
<property name="exploded.lib" value="${exploded}/WEB-INF/lib"/>
<property name="reports.out" value="${out}/reports"/>
<property name="junit.out" value="${reports.out}/junit"/>
<property name="testng.out" value="${reports.out}/testng"/>
<path id="production.class.path">
<pathelement location="${production.classes}"/>
<pathelement location="${production.resources}"/>
<fileset dir="${production.lib}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
<exclude name="**/*test*.jar"/>
</fileset>
</path>
<path id="test.class.path">
<path refid="production.class.path"/>
<pathelement location="${test.classes}"/>
<pathelement location="${test.resources}"/>
<fileset dir="${test.lib}">
<include name="**/junit*.jar"/>
<include name="**/*test*.jar"/>
</fileset>
</path>
<path id="testng.class.path">
<fileset dir="${test.lib}">
<include name="**/testng*.jar"/>
</fileset>
</path>
<available file="${out}" property="outputExists"/>
<target name="clean" description="remove all generated artifacts" if="outputExists">
<delete dir="${out}" includeEmptyDirs="true"/>
<delete dir="${reports.out}" includeEmptyDirs="true"/>
</target>
<target name="create" description="create the output directories" unless="outputExists">
<mkdir dir="${production.classes}"/>
<mkdir dir="${test.classes}"/>
<mkdir dir="${reports.out}"/>
<mkdir dir="${junit.out}"/>
<mkdir dir="${testng.out}"/>
<mkdir dir="${exploded.classes}"/>
<mkdir dir="${exploded.lib}"/>
</target>
<target name="compile" description="compile all .java source files" depends="create">
<!-- Debug output
<property name="production.class.path" refid="production.class.path"/>
<echo message="${production.class.path}"/>
-->
<javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}">
<classpath refid="production.class.path"/>
<include name="**/*.java"/>
<exclude name="**/*Test.java"/>
</javac>
<javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}">
<classpath refid="test.class.path"/>
<include name="**/*Test.java"/>
</javac>
</target>
<target name="junit-test" description="run all junit tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<junit printsummary="yes" haltonfailure="${haltonfailure}">
<classpath refid="test.class.path"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.out}">
<fileset dir="${test.src}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.out}">
<fileset dir="${junit.out}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${junit.out}" format="frames"/>
</junitreport>
</target>
<taskdef resource="testngtasks" classpathref="testng.class.path"/>
<target name="testng-test" description="run all testng tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<testng classpathref="test.class.path" outputDir="${testng.out}" haltOnFailure="${haltonfailure}" verbose="2" parallel="methods" threadcount="50">
<classfileset dir="${out}/test/${ant.project.name}" includes="**/*.class"/>
</testng>
</target>
<target name="exploded" description="create exploded deployment" depends="testng-test">
<copy todir="${exploded.classes}">
<fileset dir="${production.classes}"/>
</copy>
<copy todir="${exploded.lib}">
<fileset dir="${production.lib}"/>
</copy>
</target>
<target name="package" description="create package file" depends="exploded">
<jar destfile="${out}/${ant.project.name}.jar" basedir="${production.classes}" includes="**/*.class"/>
</target>
</project>
while maven may be a bit daunting at first glance, i think it really is a pretty nice tool. yes, it does have it's warts, but all in all i think it's one of the best choices for java. the "thing" you really need to get about maven is that everything is based on convention. if you do everything the conventional maven way, then your maven pom is generally very small and everything "just works". and there is plenty of getting started info out there to show you what the "maven convention" is. (and yes, you usually can do things your own way, but it's usually not worth it unless you are stuck w/ an existing project which would be difficult to re-organize).
There are alternatives to Ant/Ivy or Maven XML that might be worth a gander. They use a real programming language instead of an XML DSL.
http://buildr.apache.org/ (Ruby based)
http://www.gradle.org/index.php (Groovy based)
One simplification you can use when working solely in Eclipse is to let Eclipse take care of the compilation. A given project can have its own simple Ant script, which packages up whatever is need from bin into a jar.