Search code examples
mavengrailsmodulepom.xmlinvocationtargetexception

Cannot mvn compile a parent pom with a grails module


I have a simple maven parent project containing

<modules>
  <module>myGrailsPlugin<module>
  <module>someVanillaMavenProject<module>
</modules>

Folder structure is straightforward.

parent
|_ myGrailsPlugin
    |_ pom.xml
    |_ MyGrailsPlugin.groovy
|_ someVanillaMavenProject
    |_ pom.xml
|_ pom.xml

Both modules, can be build sucessfully, when built individually. However when I run

mvn compile

on the parent project I get the following error.

Embedded Error: java.lang.reflect.InvocationTargetException
MyGrailsPlugin.groovy (The system cannot find the file specified.)

The file myGrailsPlugin.groovy exist in the top level of the myGrailsPlugin folder and is the grails plugin descriptor. Seems maven does not look up the file in this folder.

Any idea how do fix this?


The pom.xml of the GrailsPlugin looks like that.

...
<build>
    ...
    <pluginManagement />
    <plugins>
        <plugin>
            <groupId>org.grails</groupId>
            <artifactId>grails-maven-plugin</artifactId>
            <version>${grails.version}</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>set-version</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <command>set-version</command>
                        <args>${project.version}</args>
                    </configuration>
                </execution>
                <execution>
                    <id>package-plugin</id>
                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <command>package-plugin</command>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        ...
    </plugins>
</build>
...

Regards, Will


Solution

  • After a while I figured out this is a bug in the grails gwt plugin. The src/gwt folder will be looked up in the parent directory instead of the submodules directory. But this does not exist. So copying the complete folder to the parent will let the build complete sucessfully. I didn't like this workaround and decided to change my build configuration to build the modules separately.