Skip to content

Instantly share code, notes, and snippets.

@blt
Created Mar 14, 2011
Embed
What would you like to do?
<project name="AgentBridge" basedir="." default="main">
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="com.fluentstream.agentbridge.Main"/>
<property name="lib.dir" value="lib"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}"
classpathref="classpath"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="junit" depends="jar">
<junit printsummary="yes">
<classpath>
<path refid="classpath"/>
<path refid="application"/>
</classpath>
<batchtest fork="yes">
<fileset dir="${src.dir}" includes="*Test.java"/>
</batchtest>
</junit>
</target>
<target name="clean-build" depends="clean,jar"/>
<target name="main" depends="clean,run"/>
</project>
blt@doritos:~/projects/agentbridge
$ ant compile
Buildfile: /home/blt/projects/agentbridge/build.xml
compile:
[mkdir] Created dir: /home/blt/projects/agentbridge/build/classes
[javac] Compiling 2 source files to /home/blt/projects/agentbridge/build/classes
a
BUILD SUCCESSFUL
Total time: 0 seconds
blt@doritos:~/projects/agentbridge
$ ant jar
Buildfile: /home/blt/projects/agentbridge/build.xml
compile:
jar:
[mkdir] Created dir: /home/blt/projects/agentbridge/build/jar
[jar] Building jar: /home/blt/projects/agentbridge/build/jar/AgentBridge.jar
BUILD SUCCESSFUL
Total time: 0 seconds
blt@doritos:~/projects/agentbridge
$ ant junit
Buildfile: /home/blt/projects/agentbridge/build.xml
compile:
jar:
junit:
BUILD FAILED
/home/blt/projects/agentbridge/build.xml:45: Reference application not found.
Total time: 0 seconds
blt@doritos:~/projects/agentbridge
$ tree
.
├── agentbridge.proto
├── build
│   ├── classes
│   │   ├── com
│   │   │   └── fluentstream
│   │   │   └── agentbridge
│   │   │   └── Main.class
│   │   └── MainTest.class
│   └── jar
│   └── AgentBridge.jar
├── build.xml
├── client.cpp
├── lib
│   ├── ant-junit.jar
│   ├── junit.jar
│   └── log4j-1.2.16.jar
├── Makefile
├── README
├── server.cpp
└── src
├── com
│   └── fluentstream
│   └── agentbridge
│   └── Main.java
└── MainTest.java
@das-g

This comment has been minimized.

Copy link

@das-g das-g commented Jul 31, 2011

This looks like an error I noticed when I tried the ANT hello world tutorial. See my fork for a possible fix. I've just started learning ANT, but I guess reference lookup is scoped, so you have to refer to XML elements on the same or higher levels, not some nested within other elements.

@blt

This comment has been minimized.

Copy link
Owner Author

@blt blt commented Jul 31, 2011

Thanks for the comment. I wrote and fixed and finished this code so long ago that I don't hardly even remember what all the fuss was about.

@das-g

This comment has been minimized.

Copy link

@das-g das-g commented Jul 31, 2011

Ah, I half suspected that might be the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment