Anass Bouchkioui Anass Bouchkioui - 3 months ago 14
Java Question

Maven - Import Plugins configuration from one project to another using maven-tiles

In order to use the same configuration of a maven plugin in many projects, I am trying to define this configuration in one core project, and then import it to the other projects.

Basing my solution on this discussion, I used Maven Tile Plugin, and I followed the steps that were explained in the documentation.


  • Definition of the configuration in the core project:

    1) pom.xml:

    <build>
    <plugins>
    <plugin>
    <groupId>io.repaint.maven</groupId>
    <artifactId>tiles-maven-plugin</artifactId>
    <version>2.8</version>
    <extensions>true</extensions>
    <configuration>
    <filtering>true</filtering>
    </configuration>
    </plugin>
    </plugins>
    </build>


    2) tile.xml:

    <project>
    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.10</version>
    <executions>
    <!-- .... -->
    </executions>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.19.1</version>
    <executions>
    <execution>
    <goals>
    <goal>integration-test</goal>
    <goal>verify</goal>
    </goals>
    <configuration>
    <!-- .... -->
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
    </project>


    3) Build the core project

  • Import of the configuration in the targeted project:



In the parent POM:

<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.8</version>
<configuration>
<buildSmells>pluginmanagement</buildSmells>
<tiles>
<tile>groupId:coreProjectId:1.1.0</tile>
</tiles>
</configuration>
</plugin>


From what I understand, the import of the core project using the tile plugin must allow the use of the configuration that was defined for the maven failsafe plugin. The problem is that the verify goal of the failsafe plugin isn't working that way (No integration Test is run with 'mvn verify')

Any suggestion to well define the maven tile plugin, or to use any other method to reuse the core configuration would be helpful.

Thank you for your help.

Answer

The buildSmells tag should be defined in the core project instead of the target project.

This is how the pom.xml should configured in the core project:

<build>
    <plugins>
        <plugin>
            <groupId>io.repaint.maven</groupId>
            <artifactId>tiles-maven-plugin</artifactId>
            <version>${plugin.tiles.version}</version>
            <extensions>true</extensions>
            <configuration>
                <buildSmells>pluginmanagement</buildSmells>
                <filtering>true</filtering>
            </configuration>
        </plugin>
    </plugins>
</build>
Comments