我一直在使用 Maven EAR 插件为一个新项目创建我的 ear 文件。我在插件文档中注意到您可以为模块指定排除语句。例如我的插件的配置如下...
<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>
对于需要排除 4-5 个模块的小型项目,这种方法绝对适用。但是,在我的项目中,我有 30 多个,而且我们才刚刚开始该项目,因此随着它的扩展,这可能会增长。
除了显式声明每个模块的排除语句之外,是否可以使用通配符或排除所有 Maven 依赖项标志以仅包含我声明的那些模块并排除其他所有内容?有人知道更优雅的解决方案吗?