Search code examples
mavenresourcebundle

Maven - Excluding Resource from a specific artifact


I'm new to maven, and found myself stuck with something which is really bothering me.

I have a multi-module project, and my parent pom.xml contains the following plugin:

    <plugin>
            <artifactId>maven-remote-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>process-remote-resources</id>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <resourceBundles>
                            <resourceBundle>
                                ${shared.resources.version}
                            </resourceBundle>
                        </resourceBundles>
                        <includes>
                            <include>version.info</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>

This code generates a version.info file and places them in each of my module jar files. I was wondering if it's possible to make this code create the version.info file for only 2 modules out of the 3.

For example if I have modules: A, B and C. I would like the version.info file to be in A and B but not in C. I hope I explained myself well enough, in case not please let me know.

Thanks in advance, Meny


Solution

  • Best solution would be moving this plugin configuration to the project/build/pluginManagement element of the parent pom:

    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>process-remote-resources</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <resourceBundles>
                               <resourceBundle>
                                ${shared.resources.version}
                               </resourceBundle>
                            </resourceBundles>
                            <includes>
                               <include>version.info</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
    

    and call it at project/build/plugins in module poms:

    <plugins>
        <plugin>
            <artifactId>maven-remote-resources-plugin</artifactId>
        </plugin>
    </plugins>
    

    if such refactoring of parent pom is not allowed then override plugin configuration with skip set into true or use the none phase to disable unwanted plugin calls: http://thomaswabner.wordpress.com/2010/02/16/howto-disable-inherited-maven-plugin/