How I can create a Ant task to compile GUI forms (XML) in Intellij IDEA? I use Scala and Java in my project. Java only for GUI class, and I create it with Intellij IDEA UI Designer.
+1
A:
IDEA provides a Ant task, javac2, that does this. It's a drop-in replacement for the standard javac Ant task.
First, you'll need to include something like the following near the top of your Ant build file.
<path id="javac2.class.path">
<pathelement location="${idea.dir}/redist/forms_rt.jar"/>
<pathelement location="${idea.dir}/redist/javac2.jar"/>
<pathelement location="${idea.dir}/redist/annotations.jar"/>
</path>
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.class.path"/>
Here "${idea.dir}" refers to the directory of your IDEA installation. Those jars are redistributable, so you can copy them into your project if you wish, and refer to them there. Once you've done that, just replace any calls to "javac" tasks with "javac2", and everything should just work.
To compile scala, of course, you'll need calls to either scalac or fsc, but those are unaffected by all of this.
Dave Griffith
2010-08-08 14:11:18
Ant show me: "/My/project/path/build.xml:16: taskdef class com.intellij.ant.Javac2 cannot be found", why?
isola009
2010-08-08 19:21:31
I change "redist" by "lib" and then Ant don't show me these error.Now, Ant show me this error: /My/project/path/build.xml:16: taskdef A class needed by class com.intellij.ant.Javac2 cannot be found: org/objectweb/asm/ClassVisitor
isola009
2010-08-08 19:32:15
Hmm, looks like you need to add <pathelement location="${idea.dir}/lib/asm.jar"/>as well. Not sure why you jars are in lib rather than redist. Community Edition, possibly?
Dave Griffith
2010-08-09 01:35:06
Yes! I use Community Edition. I added asm.jar and no works.
isola009
2010-08-09 09:25:31
A:
Same problem here. Solved this way:
<property name="idea.lib" value="C:\\Program Files (x86)\\JetBrains\\IntelliJ IDEA Community Edition 9.0.3\\lib"/>
<path id="javac2.classpath">
<pathelement location="${idea.lib}/javac2.jar"/>
<pathelement location="${idea.lib}/jdom.jar"/>
<pathelement location="${idea.lib}/asm.jar"/>
<pathelement location="${idea.lib}/asm-commons.jar"/>
<pathelement location="${idea.lib}/jgoodies-forms.jar"/>
</path>
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
msf
2010-09-22 12:43:16