java - 如何在与 Maven 的 war 中更新 MANIFEST

标签 java maven overlay war maven-assembly-plugin

我需要更新war的META-INF.MF文件

问题是

我的war文件依赖于其他war文件,即依赖于另一个war文件

结构看起来像:-

    web.war
        on top of web.war created Client.war ( Customization  )
            on top of Client.war created lite.war

在 web.war 中包含具有默认属性的 META-INF

While generating Client.war i got META_INF from web.war
......

lite.war 包含它自己的 META-INF 但它被 base wars 覆盖了

Maven 控制台输出:-

    [INFO] Processing war project
    [INFO] Copying webapp resources [**********/trunk/src/lite/src/main/webapp]
    [DEBUG]  + META-INF/MANIFEST.MF has been copied.
    [DEBUG]  + WEB-INF/web.xml has been copied.
    [DEBUG]  + WEB-INF/jboss-app.xml has been copied.
    [DEBUG]  + WEB-INF/web-2.5.xml has been copied.
    [DEBUG]  + WEB-INF/jboss_classloading.txt has been copied.
     .
     .
    [DEBUG]  + index.jasp has been copied.
    [DEBUG]  + WEB-INF/classes/org/wtc/web/board/Myboard.class has been copied.

    ..........

    [INFO] Processing overlay [ id wtc.eagle:Client]
    [DEBUG] Expanding:******/.m2/repository2/wtc/eagle/Client/2.0/Client-2.0.war into********/trunk/src/lite/target/war/work/wtc.eagle/Client
    [DEBUG] ********/trunk/src/lite/target/war/work/wtc.eagle/Client/META-INF/maven/wtc.eagle/Client/pom.properties: mode 100664, chmod 664
    [DEBUG] ********/trunk/src/lite/target/war/work/wtc.eagle/Client/META-INF/maven/wtc.eagle/Client/pom.xml: mode 100664, chmod 664
    .
    .....
    [INFO] Webapp assembled in [7854 msecs]
    [DEBUG] Excluding [] from the generated webapp archive.
    [DEBUG] Including [**] in the generated webapp archive.
    [INFO] Building war: ******/trunk/src/lite/target/Lite-1.0.war
    [DEBUG] adding directory META-INF/
    [DEBUG] adding entry META-INF/MANIFEST.MF

你能帮我看看如何覆盖 lite.war 中的 META-INF 文件吗

提前致谢...

POM.XML :-

      <?xml version="1.0" encoding="UTF-8"?>
       <project xmlns="http://maven.apache.org/POM/4.0.0" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>eaglerplite</artifactId>
        <groupId>com.wtc.eaglerp</groupId>
        <version>1.0</version>
    </parent>
<groupId>com.wtc.eaglerp</groupId>
<artifactId>lite</artifactId>
<packaging>war</packaging>
<version>1.0</version>

 <name>LIte </name>
    <url>http://javate.sourceforge.net</url>
<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <scope>provided</scope>
         </dependency>
         <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zk</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zkplus</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zul</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zhtml</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zkex</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zk</groupId>
                <artifactId>zkmax</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.common</groupId>
                <artifactId>zcommon</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.common</groupId>
                <artifactId>zweb</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.zkoss.zkforge.el</groupId>
                <artifactId>zcommons-el</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.beanshell</groupId>
                <artifactId>bsh</artifactId>
        </dependency>
        <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.jruby</groupId>
                <artifactId>jruby</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.python</groupId>
                <artifactId>jython</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>rhino</groupId>
                <artifactId>js</artifactId>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>net.sf.jasperreports</groupId>
                <artifactId>jasperreports</artifactId>
                <scope>provided</scope>
        </dependency>
<dependency>
    <groupId>wtc.eagle</groupId>
    <artifactId>Client</artifactId>
    <version>2.0</version>
    <type>war</type>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>eagle</groupId>
    <artifactId>webui</artifactId>
    <version>360</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.wtc.eaglerp</groupId>
    <artifactId>baselite</artifactId>
    <version>1.0</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>
<dependency>
<groupId>eagle</groupId>
<artifactId>timelinez</artifactId>
<version>1.0</version>
</dependency>
<dependency>
    <groupId>eagle.theme</groupId>
    <artifactId>Pistacho</artifactId>
    <version>2.0</version>
</dependency>
  </dependencies>
 <build>
       <finalName>Lite-1.0</finalName>
        <sourceDirectory>${basedir}/src/main/webapp/WEB-INF/src/</sourceDirectory>
        <outputDirectory>${basedir}/src/main/webapp/WEB-INF/classes/</outputDirectory>
    <plugins>   
    <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <webResource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                            <includes>
             <!--                   <include>META-INF/**</include>    -->
                                <include>META-INF/MANIFEST.MF</include>
             <!--                   <include>WEB-INF/web.xml</include> -->
                            </includes>
                        </webResource>
                        <webResource>
                              <directory>${basedir}/src/main/webapp</directory>
                          </webResource>
                    </webResources>
                 </configuration>
            </plugin>
  </plugins>
</build>
</project>

最佳答案

试试下面的配置,在pom.xml中加入这个配置

<plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <webResource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                            <includes>
                                <include>META-INF/MANIFEST.MF</include>
                                <include>META-INF/context.xml</include>
                                <include>WEB-INF/web.xml</include>
                            </includes>
                        </webResource>
                        <webResource>
                            <directory>../projectname-webapp</directory>
                        </webResource>
                    </webResources>
                </configuration>
            </plugin>

关于java - 如何在与 Maven 的 war 中更新 MANIFEST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11150732/

相关文章:

maven - 如何使用离线仪器生成Jacoco集成测试报告?

jquery - 反向 jQuery 高度动画

overlay - 用于快速 IO 的 Beagle Bone Black PRU 设备覆盖不起作用

java - 将无状态 session bean 注入(inject)自定义 JsonDeserializer 失败

java - IText如何调整pdf页面

java - Java 中对两个字节变量求和的异常

eclipse - 使用 build-helper-maven 附加源目录

java - 如何使用 switch 将 Javascript 匿名函数转换为 Java?

java - gradle 项目是否有等效的 `mvn dependency:build-classpath` ?

android - 你好 MapView,移动标记