无法使用ant启动Grails

时间:2013-12-30 14:54:49

标签: grails ant build

我正在将一个项目从grails 1.3.6切换到grails 2.2.4。该项目构建在独立的构建VM上,并使用ant 1.7.1。系统变量设置为指向ant 1.7.1和grails 2.2.4。 Grails 2.2.4使用windows命令行成功启动。这是应该编译grails文件的ant脚本的摘录:

任务设置 -

<path id="grails.classpath">
  <fileset dir="${env.grails.home}/dist" includes="grails-bootstrap-*.jar"/>
  <fileset dir="${env.grails.home}/lib">
    <include name="**/groovy-all*.jar"/>
    <include name="**/ivy*.jar"/>
    <include name="**/gpars*.jar"/>
    <include name="**/gant_groovy*.jar"/>
  </fileset>
</path>

<taskdef name="grails" classname="grails.ant.GrailsTask"   classpathref="grails.classpath"/>

初始化执行:

<target name="-init">
  <record name="C:/log/compile_output.log" />
  <echo level="verbose">Deleting old compiled binaries, if existing...</echo>
  <delete dir="${dir.binaries}" failonerror="false" includeemptydirs="true"/>
  <delete dir="${dir.testBinaries}" failonerror="false" includeemptydirs="true"/>
  <grails home="${env.grails.home}" script="Clean"/>  ####THIS LINE IS FAILING
  <delete dir="${dir.dist}" failonerror="false" includeemptydirs="true"/>
  <echo level="verbose">Creating directories for the compiled binaries - '${dir.binaries}' and '${dir.testBinaries}' ...</echo>
  <mkdir dir="${dir.binaries}"/>
  <mkdir dir="${dir.testBinaries}"/>
  <mkdir dir="${dir.dist}"/>
  <grails home="${env.grails.home}" script="AddProxy" args="myProxy --host=webproxy.int.westgroup.com --port=80"/>
  <grails home="${env.grails.home}" script="SetProxy" args="myProxy"/>
</target>

<grails home="${env.grails.home}" script="Clean"/>失败。吐出的堆栈跟踪如下:

D:\Builds\141\Cobalt PAC\PAC\Sources\ant\CompileAntScript.xml:72: Unable to star
t Grails: java.lang.reflect.InvocationTargetException
    at grails.ant.GrailsTask.runGrails(GrailsTask.java:137)
    at grails.ant.GrailsTask.execute(GrailsTask.java:98)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
 ...............
Caused by: java.lang.NoClassDefFoundError: jline/CompletionHandler
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.<init>(GrailsScript
Runner.java:96)

我还确保正确设置了grails环境。使用调试输出,我看到行Setting project property: env.grails.home -> C:\grails-2.2.4。与这样一个老蚂蚁版本有冲突吗?

----编辑-----

我创建了一个新的grails项目,并在我的机器上运行相同的命令。我得到完全相同的问题,所以我猜它不是一个脏缓存问题。我也在构建服务器上尝试了ant 1.8.2并收到了同样的问题。

看起来与JIRA 8496

有关

1 个答案:

答案 0 :(得分:0)

我使用来自GrailsTask的javadoc信息的非常简单的ant配置遇到了同样的问题。最后,我通过为Burt Beckwith描述的grails创建宏来将ant(版本1.8.4)与grails(版本2.3.7)集成在一起。

示例:

<target name="init-grails">
  <property environment='env'/>
  <property name='grails.home' value='${env.GRAILS_HOME}' />
  <property name='grails.bin' value='${grails.home}/bin' />
  <condition property='grails' value='${grails.bin}/grails.bat'><os family='windows'/></condition>
  <property name='grails' value='${grails.bin}/grails' />

  <macrodef name='grails'>
    <attribute name='action' />
    <attribute name='environment' default='dev' />
    <element name='preargs' optional='true' />
    <element name='args' optional='true' />
    <sequential>
       <exec executable='${grails}' failonerror='true'>
          <preargs />
          <arg value='@{environment}'/>
          <arg value='@{action}'/>
          <args />
       </exec>
    </sequential>
  </macrodef>
</target>

<target name="clean" depends="init-grails">
  <grails action="clean"/>
</target>