当前位置: 动力学知识库 > 问答 > 编程问答 >

java - 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>.

分享给朋友:
您可能感兴趣的文章:
随机阅读: