Newbie
Newbie

Reputation: 2708

Classpath element is not a jar

I am trying to write a ant build which calls a Java class

<target name="validate" depends="forge-jar">        
    <taskdef name="spec" classname="SpecBuild" classpathref="java.classpath" />
            <spec a="${forge}" mail="${mail}" dd="${dd}" wdd="${wdd}"/>
    </target>
<target name="forge-jar" >
            <path id="project.class.path">
            <pathelement location="classes/" />
            <pathelement path="classes/ant/tasks/SpecBuild.class" />
        </path>
        <path id="java.classpath">
            <path refid="project.class.path" />
        </path>
        <javac includeantruntime="false" srcdir="src" destdir="classes" classpathref="java.classpath">
            <filename name="**/SpecBuild.java" />
        </javac>
    </target>

In the SpecBuild.java class if I use slf4j logger I am getting this warning :-

CLASSPATH element /Users/classes/ant/tasks/SpecBuild.class is not a JAR.
  [taskdef] CLASSPATH element /Users/classes/ant/tasks/SpecBuild.class is not a JAR.

Can anyone please help me fix this

Upvotes: 3

Views: 2430

Answers (1)

VS-java
VS-java

Reputation: 72

You can specify the 'classes' directory in the class path as below. Remove the 'SpecBuild.class' file from pathElement location. You can either use 'includes' property and mention the file name in it or just include the 'classes' directory as below (exclude the JUni test cases package, if you have).

  <classpath>
      <pathelement path="${classpath}"/>
      <fileset dir="lib">
        <include name="**/*.jar"/>
      </fileset>
      <pathelement location="classes"/>
      <dirset dir="${build.dir}">
        <include name="apps/**/classes"/>
        <exclude name="apps/**/*Test*"/>`enter code here`
      </dirset>
</classpath>

Good luck.

Upvotes: 2

Related Questions