taskdef class com.intellij.ant.Javac2 cannot be found

I am trying to build using ant from Intellij Maia 94.539 build (Mac OS 10.6) and receiving the above error.  This error has been noted before and I am surprised to see it again.

Here is an excerpt from the Intellij-created ant file.

  <property name="javac2.home" value="${idea.home}/lib"/>
  <path id="javac2.classpath">
    <pathelement location="${javac2.home}/javac2.jar"/>
    <pathelement location="${javac2.home}/jdom.jar"/>
    <pathelement location="${javac2.home}/asm.jar"/>
    <pathelement location="${javac2.home}/asm-commons.jar"/>
  </path>
  <taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>


And here is the stack trace and error is below.  Any suggestions?

Thanks,
Sean

-----------------------------

taskdef
/Users/sdavis/workspace/git/RedCompass/redcompass.xml:17: taskdef class com.intellij.ant.Javac2 cannot be found
     at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:609)
     at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:228)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     at org.apache.tools.ant.Task.perform(Task.java:348)
     at org.apache.tools.ant.Target.execute(Target.java:357)
     at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
     at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
     at org.apache.tools.ant.Main.runBuild(Main.java:743)
     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:32)
Caused by: java.lang.ClassNotFoundException: com.intellij.ant.Javac2
     at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1400)
     at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341)
     at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
     at java.lang.Class.forName0(Native Method)
     at java.lang.Class.forName(Class.java:247)
     at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:583)
     ... 20 more
--- Nested Exception ---
java.lang.ClassNotFoundException: com.intellij.ant.Javac2
     at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1400)
     at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341)
     at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
     at java.lang.Class.forName0(Native Method)
     at java.lang.Class.forName(Class.java:247)
     at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:583)
     at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:228)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     at org.apache.tools.ant.Task.perform(Task.java:348)
     at org.apache.tools.ant.Target.execute(Target.java:357)
     at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
     at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
     at org.apache.tools.ant.Main.runBuild(Main.java:743)
     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:32)
/Users/sdavis/workspace/git/RedCompass/redcompass.xml:17: taskdef class com.intellij.ant.Javac2 cannot be found
     at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:609)
     at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:228)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     at org.apache.tools.ant.Task.perform(Task.java:348)
     at org.apache.tools.ant.Target.execute(Target.java:357)
     at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
     at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
     at org.apache.tools.ant.Main.runBuild(Main.java:743)
     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:32)
Caused by: java.lang.ClassNotFoundException: com.intellij.ant.Javac2
     at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1400)
     at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341)
     at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
     at java.lang.Class.forName0(Native Method)
     at java.lang.Class.forName(Class.java:247)
     at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:583)
     ... 20 more
0
6 comments

Hi.

Is ${idea.home} property defined?

Alexander.

1

Thanks.  That was the problem.  In the dialog for creating an ant build file, there is a checkbox to define ${idea.home} based on the current instantiation of IntelliJ.  If that box is not checked, the error occurs.  It is obvious in retrospect.

Sean

0

I've ticked that checkbox but I still get

ant.xml:86: taskdef class com.intellij.ant.Javac2 cannot be found

Do I need to do something about this?

"requires "javac2" and task from idea"

0

Hello.

What is your IDEA version?

Alexander.

0

Found it, it only worked if I didn't use folders like this


<property file="suite.properties"/>

instead of this:

<property file="ant/suite.properties"/>

0

Everything looks fine now but I'm getting an error

Class not found........javac2

<property name="javac2.home" value="${idea.home}/lib"/>
  <path id="javac2.classpath">
    <pathelement location="${javac2.home}/javac2.jar"/>
    <pathelement location="${javac2.home}/jdom.jar"/>
    <pathelement location="${javac2.home}/asm.jar"/>
    <pathelement location="${javac2.home}/asm-commons.jar"/>
    <pathelement location="${javac2.home}/jgoodies-forms.jar"/>
  </path>
  <target name="register.custom.compilers">
    <taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
    <taskdef name="instrumentIdeaExtensions" classname="com.intellij.ant.InstrumentIdeaExtensions" classpathref="javac2.classpath"/>
  </target>


the ant build completes with no errors, but not swf is output


<target name="compile.module.suite.production" depends="register.custom.compilers" description="Compile module SUITE; production classes">

    <mkdir dir="${suite.output.dir}"/>

    <javac2 destdir="${suite.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.suite}/javac">

      <compilerarg line="${compiler.args.suite}"/>

      <bootclasspath refid="suite.module.bootclasspath"/>

      <classpath refid="suite.module.production.classpath"/>

      <src refid="suite.module.sourcepath"/>

      <patternset refid="excluded.from.compilation.suite"/>

    </javac2>



    <copy etc

0

Please sign in to leave a comment.