Maven-ear-plugin - excluding multiple modules i.e. jars, wars etc.

Posted by James Murphy on Stack Overflow See other posts from Stack Overflow or by James Murphy
Published on 2010-03-16T09:28:31Z Indexed on 2010/03/16 9:36 UTC
Read the original article Hit count: 418

Filed under:
|
|

I've been using the Maven EAR plugin for creating my ear files for a new project. I noticed in the plugin documentation you can specify exclude statements for modules. For example the configuration for my plugin is as follows...

  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.4.1</version>
        <configuration>
            <jboss>
                <version>5</version>
            </jboss>
            <modules>
                <!-- Include the templatecontroller.jar inside the ear -->
                    <jarModule>
                        <groupId>com.kewill.kdm</groupId>
                        <artifactId>templatecontroller</artifactId>
                        <bundleFileName>templatecontroller.jar</bundleFileName>
                        <includeInApplicationXml>true</includeInApplicationXml>
                    </jarModule>
                    <!-- Exclude the following classes from the ear -->
                    <jarModule>
                       <groupId>javax.activation</groupId>
                       <artifactId>activation</artifactId>
                       <excluded>true</excluded>
                    </jarModule>
                    <jarModule>
                   <groupId>antlr</groupId>
                   <artifactId>antlr</artifactId>
                   <excluded>true</excluded>
                </jarModule>
                ... declare multiple excludes
                <security>
                    <security-role id="SecurityRole_1234">
                        <role-name>admin</role-name>
                    </security-role>
                </security>
            </configuration>
        </plugin>
    </plugins>

This approach is absolutely fine with small projects where you have say 4-5 modules to exclude. However, in my project I have 30+ and we've only just started the project so as it expands this is likely to grow.

Besides explicitly declaring exclude statements per module is it possible to use wildcards or and exclude all maven dependencies flag to only include those modules i declare and exclude everything else? Is anyone aware of a more elegant solution?

© Stack Overflow or respective owner

Related posts about maven-2

Related posts about maven-plugin