[英]Integrating Existing Java Project with Groovy
I have my Existing JAVA project. 我有我现有的JAVA项目。
I have to run a Groovy script through a Java file from this project. 我必须通过此项目的Java文件运行Groovy脚本。
I'm Using Groovy Grails Tool Suite (GGTS). 我正在使用Groovy Grails工具套件(GGTS)。
Source Code has following imports: 源代码有以下导入:
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
import groovy.lang.MetaMethod;
Now I am trying to build it using build.xml (ANT) configuration. 现在我尝试使用build.xml(ANT)配置来构建它。
BUILD.xml 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>
But I get the following error : 但是我收到以下错误:
package groovy.lang does not exist [javac] import groovy.lang.*;
Please assist as to why the groovy-all-2.0.7.jar is not recognised!! 请协助为什么不能识别groovy-all-2.0.7.jar !!
Have you tried removing groovy-all
from your ant/lib
directory, adding it to a lib
directory under your project, and then doing: 您是否尝试从
ant/lib
目录中删除groovy-all
,将其添加到项目下的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"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.