简体   繁体   中英

Ant: javac cannot find class even though it's in the classpath

Our build.xml file contains the following:

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

When I run ant fortify , I get the following output:

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

As you can see from the echo output, the sourceanalyzer.jar file is in the classpath that is used by the javac task.

When I run jar -tvf /home/ouruser/fortify/Core/lib/sourceanalyzer.jar | grep SCACompiler.class jar -tvf /home/ouruser/fortify/Core/lib/sourceanalyzer.jar | grep SCACompiler.class , the SCACompiler class is listed:

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

So why does Ant say Class not found: com.fortify.dev.ant.SCACompiler ?

代替com/fortify/dev/ant/SCACompiler.class类,使用

com.fortify.dev.ant.SourceanalyzerTask

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