我有我现有的JAVA项目。
我必须通过此项目的Java文件运行Groovy脚本。
我正在使用Groovy Grails工具套件(GGTS)。
源代码具有以下导入:
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
import groovy.lang.MetaMethod;
现在我正在尝试使用build.xml(ANT)配置来构建它。
的build.xml
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath refid="groovy.classpath" />
</taskdef>
<target name="compile.groovy" description="Compile both groovy&Java"depends="init">
<groovyc srcdir="src" destdir="bin/classes">
<classpath refid="groovy.classpath" />
<javac debug="on" deprecation="true" />
</groovyc>
</target>
但是我收到以下错误:
package groovy.lang does not exist [javac] import groovy.lang.*;
请协助为什么不能识别groovy-all-2.0.7.jar !!
答案 0 :(得分:2)
您是否尝试从groovy-all
目录中删除ant/lib
,将其添加到项目下的lib
目录中,然后执行以下操作:
<path id="groovy.all.classpath">
<fileset dir="${basedir}/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.all.classpath"/>