Ant:javac即使在类路径中也找不到类

时间:2014-08-18 06:16:56

标签: java ant classpath

我们的build.xml文件包含以下内容:

<path id="our.classpath">
    <fileset dir="${in.libs}"/>
    <fileset file="/home/ouruser/fortify/Core/lib/sourceanalyzer.jar"/>
</path>

<target name="compile">
    <pathconvert property="test" refid="our.classpath"/>
    <echo message="CLASSPATH=${test}"/>

    <javac debug="true"
           debuglevel="source,lines,vars"
           destdir="${out.classes}"
           includeAntRuntime="no"
           fork="false"
           source="1.7" target="1.7">
        <src path="${src1.dir}"/>
        <src path="${src2.dir}"/>
        <classpath refid="our.classpath"/>
        <compilerarg value="-Xlint:-path"/>
        <compilerarg line="-proc:none"/>
        <compilerarg line="-s &quot;${out.classes}&quot;"/>
    </javac>
</target>

<target name="fortify">
     <antcall target="compile">
         <param name="build.compiler" value="com.fortify.dev.ant.SCACompiler"/>
     </antcall>
</target>

当我运行ant fortify时,我得到以下输出:

fortify:

compile:
 [echo] CLASSPATH=<a long list of jar files snipped>:/home/ouruser/fortify/Core/lib/sourceanalyzer.jar

BUILD FAILED
/home/ouruser/build.xml:542: The following error occurred while executing this line:
/home/ouruser/build.xml:230: Class not found: com.fortify.dev.ant.SCACompiler

echo输出中可以看出,sourceanalyzer.jar文件位于javac任务使用的类路径中。

当我运行jar -tvf /home/ouruser/fortify/Core/lib/sourceanalyzer.jar | grep SCACompiler.class时,列出了SCACompiler类:

8408 Fri Apr 04 11:17:26 EDT 2014 com/fortify/dev/ant/SCACompiler.class

那么为什么Ant会说Class not found: com.fortify.dev.ant.SCACompiler

1 个答案:

答案 0 :(得分:0)

代替com/fortify/dev/ant/SCACompiler.class课程,请使用

com.fortify.dev.ant.SourceanalyzerTask
相关问题