Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ant任务编译Groovy文件_Java_Ant_Groovy_Javac - Fatal编程技术网

Java 使用ant任务编译Groovy文件

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

我不明白当我试图运行编译任务时,为什么groovy.compile任务会运行

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