Grails Maven Plugin

provide <grails> ant task to allow nice ant integration, e.g. for cruisecontrol

Details

  • Type: Sub-task Sub-task
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

any grails commandline like
grails run-test
should be available via an ant task like
<grails command="run-test" />

issues:

  • respect GRAILS_HOME
  • allow another argument (e.g. domain class)
  • allow a different directory to work in (default: ${basedir})
  • throw BuildException on any problem

benefits:

  • easy integration in ant, e.g. for use in cruisecontrol
  • IDE integration is for free

Issue Links

Activity

Hide
Mark Rambow added a comment -

Hi, this feature would also improve the IDE integration. On all Java projects so far I used ant extensively also from Eclipse and Netbeans.

Show
Mark Rambow added a comment - Hi, this feature would also improve the IDE integration. On all Java projects so far I used ant extensively also from Eclipse and Netbeans.
Hide
Adam Stachelek added a comment -

In continuous build and integration environments, the ability to use Ant for the grails command line tasks would go a long way towards Grails integrating more smoothly, without the requirement for the continuous integration environment to call out of Java to issue shell commands.

Show
Adam Stachelek added a comment - In continuous build and integration environments, the ability to use Ant for the grails command line tasks would go a long way towards Grails integrating more smoothly, without the requirement for the continuous integration environment to call out of Java to issue shell commands.
Hide
Graeme Rocher added a comment - - edited

We didn't add it because and probably should have, but its pretty simple to do with an Ant macro (no need for a specific Ant task):

<macrodef name="grails">
     <attribute name="grailsStarter"
default="org.codehaus.groovy.grails.cli.support.GrailsStarter"/>
     <attribute name="grailsScriptRunner"
default="org.codehaus.groovy.grails.cli.GrailsScriptRunner"/>
     <attribute name="command" default="help"/>
     <sequential>
         <java fork="true" classname="@{grailsStarter}" dir="${basedir}">
             <env key="GRAILS_HOME" value="${grails.home}"/>
             <env key="JAVA_OPTS" value="-XX:MaxPermSize=512m -Xmx1024m"/>
             <sysproperty key="grails.home" value="${grails.home}"/>
             <sysproperty key="groovy.starter.conf"
value="${grails.home}/conf/groovy-starter.conf"/>

             <sysproperty key="disable.auto.recompile" value="false"/>
             <sysproperty key="server.port" value="7070"/>
             <sysproperty key="enable.jndi" value="true"/>
             <sysproperty key="base.dir" value="${basedir}" />

             <!-- <sysproperty key="tools.jar" value="C:\Program
Files\Java\jdk1.5.0_09\lib\tools.jar"/> -->

             <classpath>
                 <pathelement
location="${grails.home}/lib/groovy-all-1.5.4.jar"/>
                 <pathelement
location="${grails.home}/dist/grails-cli-1.0.1.jar"/>
             </classpath>

             <arg line="--main
org.codehaus.groovy.grails.cli.GrailsScriptRunner"/>
             <arg line="--conf ${grails.home}/conf/groovy-starter.conf"/>
             <arg line="--classpath
${grails.home}/lib/groovy-all-1.5.4.jar:${grails.home}/ldist/grails-cli-1.0.1.jar."/>

             <arg value="@{command}"/>
         </java>

     </sequential>
 </macrodef>

This can then be used like:

<grails command="run-app" />
Show
Graeme Rocher added a comment - - edited We didn't add it because and probably should have, but its pretty simple to do with an Ant macro (no need for a specific Ant task):
<macrodef name="grails">
     <attribute name="grailsStarter"
default="org.codehaus.groovy.grails.cli.support.GrailsStarter"/>
     <attribute name="grailsScriptRunner"
default="org.codehaus.groovy.grails.cli.GrailsScriptRunner"/>
     <attribute name="command" default="help"/>
     <sequential>
         <java fork="true" classname="@{grailsStarter}" dir="${basedir}">
             <env key="GRAILS_HOME" value="${grails.home}"/>
             <env key="JAVA_OPTS" value="-XX:MaxPermSize=512m -Xmx1024m"/>
             <sysproperty key="grails.home" value="${grails.home}"/>
             <sysproperty key="groovy.starter.conf"
value="${grails.home}/conf/groovy-starter.conf"/>

             <sysproperty key="disable.auto.recompile" value="false"/>
             <sysproperty key="server.port" value="7070"/>
             <sysproperty key="enable.jndi" value="true"/>
             <sysproperty key="base.dir" value="${basedir}" />

             <!-- <sysproperty key="tools.jar" value="C:\Program
Files\Java\jdk1.5.0_09\lib\tools.jar"/> -->

             <classpath>
                 <pathelement
location="${grails.home}/lib/groovy-all-1.5.4.jar"/>
                 <pathelement
location="${grails.home}/dist/grails-cli-1.0.1.jar"/>
             </classpath>

             <arg line="--main
org.codehaus.groovy.grails.cli.GrailsScriptRunner"/>
             <arg line="--conf ${grails.home}/conf/groovy-starter.conf"/>
             <arg line="--classpath
${grails.home}/lib/groovy-all-1.5.4.jar:${grails.home}/ldist/grails-cli-1.0.1.jar."/>

             <arg value="@{command}"/>
         </java>

     </sequential>
 </macrodef>
This can then be used like:
<grails command="run-app" />
Hide
Marc Guillemot added a comment -

What about providing an Ant file containing this macro in Grails' distribution?

This would allow users to use <import file="/path/to/grail/ant/util/file.xml"/> and then just use the macro. Beside the saved macro definition users could be sure to have it in sync with the Grails version they use.

Show
Marc Guillemot added a comment - What about providing an Ant file containing this macro in Grails' distribution? This would allow users to use <import file="/path/to/grail/ant/util/file.xml"/> and then just use the macro. Beside the saved macro definition users could be sure to have it in sync with the Grails version they use.
Hide
Adam Stachelek added a comment -

Graeme, I've tried the macro you've provided (thanks). I'm able to successfully run clean and war tasks, but when test-app runs it cannot find any of my unit tests (which are in test/unit, without any packages). Is there additional configuration required to include the test sources in the classpath for this macro?

Show
Adam Stachelek added a comment - Graeme, I've tried the macro you've provided (thanks). I'm able to successfully run clean and war tasks, but when test-app runs it cannot find any of my unit tests (which are in test/unit, without any packages). Is there additional configuration required to include the test sources in the classpath for this macro?
Hide
Trevor Hawrysh added a comment -

I looked into why the test-app command would not find and execute the tests.

The result I found was the --classpath line is an incorrect path in many ways.

<arg line="--classpath ${grails.home}/lib/groovy-all-1.5.4.jar:${grails.home}/ldist/grails-cli-1.0.1.jar."/>

1. the ldist directory does not exist, it should be dist
2. the current basedir should be included as . but there is no path separator at the end it should be :.
3. the path separator is not correct for windows

Here is the proper format for windows

<arg line="--classpath ${grails.home}/lib/groovy-all-1.5.4.jar;${grails.home}/dist/grails-cli-1.0.1.jar;."/>

but I would fix this by defining a path inside the <macrodef><sequential> as

<path id="grails_cp">
<pathelement location="${grails.home}/lib/groovy-all-1.5.4.jar"/>
<pathelement location="${grails.home}/dist/grails-cli-1.0.1.jar"/>
<pathelement location="${basedir}"/>
</path>

then use this path like this:

<arg line="--classpath ${gails_cp}"/>

ant will create the proper path for your OS.

Show
Trevor Hawrysh added a comment - I looked into why the test-app command would not find and execute the tests. The result I found was the --classpath line is an incorrect path in many ways. <arg line="--classpath ${grails.home}/lib/groovy-all-1.5.4.jar:${grails.home}/ldist/grails-cli-1.0.1.jar."/> 1. the ldist directory does not exist, it should be dist 2. the current basedir should be included as . but there is no path separator at the end it should be :. 3. the path separator is not correct for windows Here is the proper format for windows <arg line="--classpath ${grails.home}/lib/groovy-all-1.5.4.jar;${grails.home}/dist/grails-cli-1.0.1.jar;."/> but I would fix this by defining a path inside the <macrodef><sequential> as <path id="grails_cp"> <pathelement location="${grails.home}/lib/groovy-all-1.5.4.jar"/> <pathelement location="${grails.home}/dist/grails-cli-1.0.1.jar"/> <pathelement location="${basedir}"/> </path> then use this path like this: <arg line="--classpath ${gails_cp}"/> ant will create the proper path for your OS.
Hide
Peter Ledbrook added a comment -

Grails 1.0.3 will come with a "grails-macros.xml" file in "$GRAILS_HOME/src/grails". Please try it out. You can even grab it from svn if you want and use it with an older version of Grails - you will just have to update the classpaths.

Show
Peter Ledbrook added a comment - Grails 1.0.3 will come with a "grails-macros.xml" file in "$GRAILS_HOME/src/grails". Please try it out. You can even grab it from svn if you want and use it with an older version of Grails - you will just have to update the classpaths.
Hide
Frederick Vong added a comment -

In the macro,

<!-- <sysproperty key="tools.jar" value="C:\Program Files\Java\jdk1.5.0_09\lib\tools.jar"/> -->

If I don't uncomment the above line, it will complain that it cannot find the javac and say JAVA_HOME point to jdk's jre directory.

However, for my environment I can make it work without hard coding the path by doing

<sysproperty key="tools.jar" value="${java.home}/../lib/tools.jar"/>

Show
Frederick Vong added a comment - In the macro, <!-- <sysproperty key="tools.jar" value="C:\Program Files\Java\jdk1.5.0_09\lib\tools.jar"/> --> If I don't uncomment the above line, it will complain that it cannot find the javac and say JAVA_HOME point to jdk's jre directory. However, for my environment I can make it work without hard coding the path by doing <sysproperty key="tools.jar" value="${java.home}/../lib/tools.jar"/>
Hide
Graeme Rocher added a comment -

There is already the macro.xml file now, so closing this issue

Show
Graeme Rocher added a comment - There is already the macro.xml file now, so closing this issue
Hide
Peter Ledbrook added a comment -

With the work done for Maven integration, a Grails Ant task should be fairly straightforward to implement and work in a more flexible manner.

Show
Peter Ledbrook added a comment - With the work done for Maven integration, a Grails Ant task should be fairly straightforward to implement and work in a more flexible manner.
Hide
Peter Ledbrook added a comment -

Note to self: update the template "build.xml" for Grails applications so that it uses the Ant task.

Show
Peter Ledbrook added a comment - Note to self: update the template "build.xml" for Grails applications so that it uses the Ant task.
Hide
Peter Ledbrook added a comment -

The Ant task is now done and "grails.org" has an Ant build that uses it in combination with Ivy. I'll still have to provide a decent template build file.

Show
Peter Ledbrook added a comment - The Ant task is now done and "grails.org" has an Ant build that uses it in combination with Ivy. I'll still have to provide a decent template build file.
Hide
Graeme Rocher added a comment -

Is there a different issue for the template build file? Otherwise I think this should be re-opened

Show
Graeme Rocher added a comment - Is there a different issue for the template build file? Otherwise I think this should be re-opened
Hide
Peter Ledbrook added a comment -

Created GRAILS-3812 for that.

Show
Peter Ledbrook added a comment - Created GRAILS-3812 for that.

People

Vote (8)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: