Adding a Grails Command to Maven Phases - What am I doing wrong?

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.

+4
source share
2 answers

OK, my problem was confusing the goals and phases of Maven. Notice i tried

 <phase>init</phase> 

and I tried other items from the goal list, but these are not Maven phases.

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

0
source

Based on the information I can find about this plugin, you should add the grails: prefix to your goals.

I have no experience with this plugin, so I could be wrong =)

Literature:

for example: <goal>grails:init</goal>

0
source

Source: https://habr.com/ru/post/1379710/


All Articles