I need to create a Grails project with Maven, and I need to add an extra grails command. I use grails-maven-plugin to create a pom file and I can create a war file with $ mvn package
When creating this application, I will need to run another grails command, one of which does not directly correspond to the maven build phase. Turning to docs , I add a second runtime element to the grails-maven plugin as follows:
<plugin> <groupId>org.grails</groupId> <artifactId>grails-maven-plugin</artifactId> <version>${grails.version}</version> <extensions>true</extensions> <executions> <execution> <goals> <goal>init</goal> <goal>maven-clean</goal> <goal>validate</goal> <goal>config-directories</goal> <goal>maven-compile</goal> <goal>maven-test</goal> <goal>maven-war</goal> <goal>maven-functional-test</goal> </goals> </execution> <execution> <id>stats</id> <phase>init</phase> <goals> <goal>exec</goal> </goals> <configuration> <command>stats</command> </configuration> </execution> </executions> </plugin>
In this example, I am trying to execute grails stats in the init maven phase. (In the end, the statistics will be replaced with something more useful.) When I ran:
$ mvn package
output includes:
[INFO] [grails:validate {execution: default}] [INFO] [grails:init {execution: default}] [INFO] [grails:config-directories {execution: default}] [INFO] [resources:resources {execution: default-resources}]
which obviously does not contain grails stats execution. I can execute the statistics command via Maven directly, as follows:
$ mvn grails:exec -Dcommand=stats
it is not executed only when adding a target to pom.
I am using Java 1.5.0_22, Grails 1.3.7 and Maven 2.2.1.
source share