简体   繁体   中英

Ant can't find classpath classes

So I'm extending my company's ant build script to add in a special module we want build in some cases. I've written an ant script that points to where I know the compiled class files for the rest of our codebase are, because they get compiled earlier in the build process. I know with 100% certainty the files are in this location.

However, whenever I try to compile this module, the classpath reference can't see those classes, and I get a bunch of "package does not exist" and "can't find symbol" errors.

I just can't seem to figure out what I'm doing wrong. Hoping for help here.

Here's my build script code:

<property name="classpath" value="${dir.dev}/out/production/Main"
<path id="pfClasspath">
    <fileset dir="${classpath}">
        <include name="**/*.class"/>
    </fileset>
    <fileset dir="${dir.dev.lib}">
        <include name="**/*.jar" />
    </fileset>
    <fileset file="${lib.json}" /> <!-- TODO try removing this -->
</path>
<target name="compile" depends="prepare">
    <javac source="1.7" classpathref="pfClasspath" srcdir="${dir.project}/src" destdir="${dir.project.build.classes}" />
</target>

The directory the "classpath" property is pointing at 100% contains all of the class files for the rest of the project. That level is the equivalent of the "src" directory on the sources side, immediately within it are the com/companyName/etc... folders.

My code contains references to the classes compiled at this location. Yet ant isn't finding them. Any help?

Try

<path id="pfClasspath">
    <pathelement path="${classpath}" />
    ...
</path>

instead. Specifying the classpath does not mean to specify every single class file that's on the classpath, which is what you do when you define your <path> element using a <fileset> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM