Java 使用ant任务编译Groovy文件
我不明白当我试图运行编译任务时,为什么groovy.compile任务会运行Java 使用ant任务编译Groovy文件,java,ant,groovy,javac,Java,Ant,Groovy,Javac,我不明白当我试图运行编译任务时,为什么groovy.compile任务会运行 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> <classpath> <path refid="compile.classpath"/> </classpath> </taskdef> <target name="groovy.c
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<path refid="compile.classpath"/>
</classpath>
</taskdef>
<target name="groovy.compile">
<groovyc srcdir="src/groovytest" destdir="bin/classes"/>
</target>
<target name="compile" description="Compile *.java file" depends="init, groovy.compile">
<javac srcdir="src" destdir="bin/classes" debug="on" deprecation="true">
<classpath refid="compile.classpath"/>
</javac>
</target>
有没有一种方法可以使用javac ant任务而不是groovyc ant任务编译.groovy?没有,您需要使用
groovyc
任务,但是,您应该能够通过执行以下操作来使用联合编译器:
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<path refid="compile.classpath"/>
</classpath>
</taskdef>
<target name="compile" description="Compile both groovy and java files" depends="init">
<groovyc srcdir="src" destdir="bin/classes">
<javac debug="on" deprecation="true"/>
</groovyc>
</target>
我发现唯一的问题是需要在类路径中包含groovy-all-XX.jar。嵌入式任务从父任务继承类路径、srcdir和destdir。