我一直在使用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+,而我们才刚刚开始这个项目,所以随着它的扩展,这个数字很可能会增长。
除了显式地声明每个模块的exclude语句之外,是否可以使用通配符或排除所有maven依赖项标志,以便只包含我声明的那些模块并排除其他所有内容?有没有人知道更优雅的解决方案?
发布于 2010-03-17 06:16:48
除了显式地声明每个模块的exclude语句之外,是否可以使用通配符或排除所有maven依赖项标志,以便只包含我声明的那些模块并排除其他所有内容?
没有提供这个开箱即用的特性(而且我不认为它很容易配置,ear必须非常精确地打包)。然而,这里不清楚的是如何获得需要排除的依赖项。根据你的回答,可能有几种方法来处理它们:
如果它们是您的工件的依赖项,您可以将它们中的一些声明为可选,以避免传递地检索它们。
然而,在没有看到整体情况的情况下,很难回答。
发布于 2010-03-16 17:33:50
不确定是否支持通配符,但编写自己的mojo非常简单。您可以包装现有的mojo,然后采用一些您自己设计的任意配置,例如通配符语法。
更好的是,您可以将您的mojo提交给maven团队(!)
发布于 2013-09-19 16:37:15
我也面临着类似的问题。但这是因为我有一个多模块项目,其中有几个ear具有提供的作用域,我只是从子ear pom中删除了父标记,使其独立。然后使用include来包含我需要的任意多的jars。
希望这能有所帮助!
https://stackoverflow.com/questions/2453201
复制相似问题