I don't have a great deal of experience with ANT scripts. I have a Java application structured like this:
/src -> source files
/bin -> "mreq" package
/lib -> JAR files
/dist -> program JAR compile
I created an ANT script that copies the /lib folder files to /bin and compiles the contents in there together to make /dist/PortableRequestDispatcher.jar. It's supposed to be a stand-alone executable JAR. The problem I found is it looks for libraries in ../lib instead of inside itself like it should. As a result, it throws a ClassNotFound error.
I don't know why it's looking for the library files outside the JAR, and my lack of experience with ANT unfortunately has made this very difficult to resolve. I'm posting the script below. Can anyone help me by telling me what I need to do differently here?
/src -> source files
/bin -> "mreq" package
/lib -> JAR files
/dist -> program JAR compile
I created an ANT script that copies the /lib folder files to /bin and compiles the contents in there together to make /dist/PortableRequestDispatcher.jar. It's supposed to be a stand-alone executable JAR. The problem I found is it looks for libraries in ../lib instead of inside itself like it should. As a result, it throws a ClassNotFound error.
I don't know why it's looking for the library files outside the JAR, and my lack of experience with ANT unfortunately has made this very difficult to resolve. I'm posting the script below. Can anyone help me by telling me what I need to do differently here?
<project name="MultiRequest" basedir="." default="jar">
<description>
Build file for Portable Request Dispatcher
</description>
<tstamp>
<format property="date" pattern="MM/dd/yyyy" />
<format property="time" pattern="hh:mm:ss aa" unit="hour" />
</tstamp>
<path id="libraries.path">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean" description="Clean">
<delete dir="bin" />
<delete dir="dist" />
</target>
<target name="compile" description="Compile source files">
<echo file="src/mreq/Generated.java"
>package mreq;
public class Generated {
public static final String BUILD_DATE = "${date}";
public static final String BUILD_TIME = "${time} EST";
}</echo>
<mkdir dir="bin" />
<javac srcdir="src" destdir="bin" debug="true"
debuglevel="lines, vars, and source" includeantruntime="false"
>
<classpath refid="libraries.path" />
</javac>
</target>
<target name="jar" depends="clean, compile" description="Generation distribution">
<mkdir dir="dist" />
<mkdir dir="bin" />
<copy todir="bin" flatten="true">
<path refid="libraries.path" />
</copy>
<mkdir dir="bin" />
<copy todir="bin" flatten="true">
<fileset dir="res">
<include name="log4j.properties" />
</fileset>
</copy>
<manifestclasspath property="manifest.classpath" jarfile="dist/PortableRequestDispatcher.jar">
<classpath refid="libraries.path"/>
</manifestclasspath>
<jar destfile="dist/PortableRequestDispatcher.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="mreq.MultiDispatcher"/>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
</jar>
<mkdir dir="dist/cert" />
<copy todir="dist/cert">
<fileset dir="cert" />
</copy>
<mkdir dir="dist/cfg" />
<copy todir="dist/cfg">
<fileset dir="cfg" />
</copy>
<mkdir dir="dist/xml" />
<copy todir="dist/xml">
<fileset dir="xml" />
</copy>
</target>
<target name="run">
<java jar="dist/PortableRequestDispatcher.jar" fork="true" />
</target>
</project>
This post has been edited by saxman: 28 January 2013 - 09:54 PM


00