views:

162

answers:

1

I'm not sure this is the problem, but it looks like it might be the case. I'm getting build errors telling me that certain packages don't exist. These packages are packages that exist in .jar files within my lib directory. Any other packages within my java source files that I'm compiling and copying to the classes directory are working just fine. Here are some of the basics of my Ant build script related to this issue:

<property name="app.name" value="myapp" />
<property name="base.dir" value="${basedir}" />
<property name="build.dir" value="${base.dir}/build" />
<property name="build.webinf.dir" value="${build.dir}/WEB-INF" />
<property name="build.classes.dir" value="${build.webinf.dir}/classes" />
<property name="build.lib.dir" value="${build.webinf.dir}/lib" />
<property name="catalina.dir" value="C:\Program Files\Apache Software Foundation\apache-tomcat-5.5.28" />
<property name="catalina.lib.dir" value="${catalina.dir}/shared/lib" />
<property name="config.dir" value="${base.dir}/config" />
<property name="dist.dir" value="${basedir}/dist"/>
<property name="lib.dir" value="${base.dir}/lib" />
<property name="src.dir" value="${base.dir}/src" />
<property name="www.dir" value="${base.dir}/www" />

<path id="compile.classpath">
    <fileset dir="${lib.dir}">
        <include name="*.jar" />
    </fileset>
    <pathelement location="${catalina.dir}/common/classes" />
    <fileset dir="${catalina.dir}/common/endorsed">
        <include name="*.jar" />
    </fileset>
    <fileset dir="${catalina.dir}/common/lib">
        <include name="*.jar" />
    </fileset>
    <pathelement location="${catalina.dir}/shared/classes"/>
    <fileset dir="${catalina.lib.dir}">
        <include name="*.jar" />
    </fileset>
</path>

<target name="init">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${build.webinf.dir}" />
    <mkdir dir="${build.classes.dir}" />
    <mkdir dir="${build.lib.dir}" />
    <mkdir dir="${dist.dir}" />
    <mkdir dir="${src.dir}" />
</target>

<target name="prepare_www_dir" description="Copies all static web content onto the build path.">
    <copy todir="${build.dir}">
        <fileset dir="${www.dir}"/>
    </copy>
</target>

<target name="prepare_lib_dir" description="Copies all libraries onto the build lib path.">
    <copy todir="${build.lib.dir}">
        <fileset dir="${lib.dir}" includes="**/*.jar" />
    </copy>
</target>

<target name="compile" depends="init,prepare_www_dir,prepare_lib_dir" description="Compiles source code, and copies it onto the build class path.">
    <javac srcdir="${src.dir}" destdir="${build.classes.dir}">
        <classpath refid="compile.classpath" />
    </javac>
</target>
+7  A: 
<fileset dir="${lib.dir}">
    <include name="**/*.jar" />
</fileset>
mhaller
Worked! I can't believe I didn't see that. Thanks!
hal10001
Yea, directly from the docs: http://ant.apache.org/manual/using.html
Jeremy Raymond