7

I've got a super POM gathering versions, plugin & dependency definitions for its 2 child submodules: one for a webapp (running with jetty:run), the other one for DB migrations ("running" with liquibase:update).

This works fine so long as I changed the directory to one of the submodules'. However, when I run jetty:run or liquibase:update on the parent POM, I'd like to see the plugin execution "forwarded" to the corresponding submodule.

Do you have any idea if such a thing can be achieved?

Thanks in advance,

Rolf

P.S.: sorry for the late update

PARENT POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <modules>
            <module>webapp</module>
            <module>db-migrations</module>
    </modules>

    <!-- [...] -->

    <pluginManagement>
            <!-- [...] -->
            <plugins>
                    <!-- JETTY -->
                    <plugin>
                            <groupId>org.mortbay.jetty</groupId>
                            <artifactId>maven-jetty-plugin</artifactId>
                            <version>${jetty-plugin.version}</version>
                            <configuration>
                                    <contextPath>/</contextPath>
                                    <scanIntervalSeconds>10</scanIntervalSeconds>
                                    <connectors>
                                            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                                    <port>9999</port>
                                                    <maxIdleTime>60000</maxIdleTime>
                                            </connector>
                                    </connectors>
                            </configuration>
                    </plugin>
                    <!-- LIQUIBASE -->
                    <plugin>
                            <groupId>org.liquibase</groupId>
                            <artifactId>liquibase-maven-plugin</artifactId>
                            <version>${liquibase.version}</version>
                            <configuration>
                                    <changeLogFile>src/main/resources/tv/esporx/master.xml</changeLogFile>
                                    <propertyFile>${env.file}</propertyFile>
                            </configuration>
                            <executions>
                                    <execution>
                                            <phase>process-resources</phase>
                                            <goals>
                                                    <goal>updateSQL</goal>
                                                    <goal>update</goal>
                                            </goals>
                                    </execution>
                            </executions>
                    </plugin>
    </pluginManagement>
</project>

DB MIGRATIONS

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- [...] -->

    <dependencies>
            <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
            </dependency>
    </dependencies>

    <build>
            <plugins>
                    <plugin>
                            <groupId>org.liquibase</groupId>
                            <artifactId>liquibase-maven-plugin</artifactId>
                    </plugin>
            </plugins>
    </build>
</project>

WEBAPP

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- [...] -->

    <build>
            <plugins>
                    <plugin>
                            <groupId>org.mortbay.jetty</groupId>
                            <artifactId>maven-jetty-plugin</artifactId>
                    </plugin>
            </plugins>
    </build>
</project>
fbiville
  • 8,407
  • 7
  • 51
  • 79
  • Can you share relevant pom snippet? For instance, are you using `` in your parent pom? – Raghuram Mar 28 '12 at 04:58
  • Can you show the pom's ? Cause otherwise it's not possible to give any suggestions. – khmarbaise Mar 28 '12 at 14:53
  • done, sorry for my late reply. As you can see, everything is already gathered within the parent pom file. However, both plugins are effectively used at the child level only. What'd be nice would be to tell Maven that mvn liquibase:update (or updateSQL) as well as mvn jetty:run on parent level to forward the invocation to the appropriate child projects. – fbiville Mar 31 '12 at 02:53

1 Answers1

6

If you have made an mvn install before other steps you can use

mvn -pl ChildModule lifecycle

from the root level of your project.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235