【问题标题】:maven war overlay won't exclude dependanciesmaven 战争覆盖不会排除依赖项
【发布时间】:2020-01-23 21:07:20
【问题描述】:

我有一个项目,我试图用来自另一个模块的已编译 jar 和 war 项目中的一些文件覆盖预构建的战争。

+pom.xml
|
+-+depandancy_dir
| |
| + source.war
|
+-+ jar
| |
| + pom.xml
| + src
|  ...
|
+-+war_dir
  |
  + pom.xml
  + src
    .... no jars

我想排除一些配置为 jar 的 maven 依赖项的 jar。

我已经在 pom 中为战争尝试了以下所有排除行。无论如何都会出现不需要的罐子。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <dependentWarExcludes>**/unwanted-core-1.1.jar</dependentWarExcludes>
                <overlays>
                    <overlay>
                       <groupId>src.war</groupId>
                       <artifactId>base.war</artifactId>

                       <excludes>
                            <exclude>**/unwanted-core-1.1.jar</exclude>     
                            <packagingExcludes>**/unwanted-core-1.1.jar</packagingExcludes>                           
                            <exclude>WEB-INF/lib/unwanted-core-1.1.jar</exclude>     
                            <packagingExcludes>WEB-INF/lib/unwanted-core-1.1.jar</packagingExcludes>                           
                       </excludes>

                    </overlay>
                </overlays>
            </configuration>
        </plugin>

我在eclipse下运行maven。 war插件报告版本maven-war-plugin:2.2:war

【问题讨论】:

    标签: maven maven-war-plugin


    【解决方案1】:

    原来我试图以错误的方式解决问题。排除继续依赖。

      <dependencies>
            <dependency>
            <!-- the jar of custom code -->
                <groupId>my.group</groupId>
                <artifactId>jar</artifactId>
                <version>1.0.0-SNAPSHOT</version>
                <exclusions>
                   <exclusion>  <!-- declare the exclusion here -->
                        <groupId>org.unwanted</groupId>
                        <artifactId>unwanted-core</artifactId>
                   </exclusion>
                </exclusions>
            </dependency>
            <dependency>
    <!-- the war I am overlaying -->
                <groupId>my.group</groupId>
                <artifactId>a.base.war</artifactId>
                <version>1.0</version>
                <scope>system</scope>
                <systemPath>${basedir}/../dependancies/jreport.war</systemPath>
                <type>war</type>
            </dependency>
    
      </dependencies>
    

    以下链接帮助了我。

    https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

    Maven: remove a single transitive dependency

    【讨论】:

      猜你喜欢
      • 2012-06-17
      • 1970-01-01
      • 1970-01-01
      • 2013-08-23
      • 2016-07-12
      • 1970-01-01
      • 2012-08-08
      • 2011-08-03
      • 1970-01-01
      相关资源
      最近更新 更多