如何从子版本中排除父Webapp目录

问题描述 投票:0回答:0

我有一个父Maven模块runtime ,它包含webApp目录来存储与Web相关的东西。(html,js等...)。在我的子模块中, employee也遵循相同的结构。所以当我构建具有依赖项的子项目jar时它包含两个相互覆盖的webapp内容。我的要求是从具有依赖项的子(雇员)jar中排除父webapp目录。我使用Maven Shade插件将具有依赖项的jar捆绑在一起。请让我知道如何实现此目标。

父pom文件(运行时)

<project>
<modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.sample.myproject</groupId>
        <artifactId>base</artifactId>
        <version>3.0.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>runtime</artifactId>
    <name>Runtime Engine</name>
    <packaging>jar</packaging>

<dependencies>
            <dependency>
//dependencies goes here
            </dependency>

</dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/config</directory>
                <filtering>true</filtering>

            </resource>
            <resource>
                <directory>src/main/webapp</directory>
            </resource>
        </resources>        
//plugins goes here (maven-jar-plugin)
</build>
</project>

儿童pom(员工)

<project>
    <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.sample.myproject</groupId>
            <artifactId>base</artifactId>
            <version>1.0.0-SNAPSHOT</version>

        </parent>
        <artifactId>employee</artifactId>
        <name>Employee Engine</name>
        <packaging>jar</packaging>

    <dependencies>
                <dependency>
    //dependencies goes here
    <dependency>
            <groupId>com.sample.myproject</groupId>
            <artifactId>runtime</artifactId>
            <version>3.0.0-SNAPSHOT</version>
    </dependency>
                </dependency>

    </dependencies>
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                </resource>
                <resource>
                    <directory>src/main/config</directory>
                    <filtering>true</filtering>

                </resource>
                <resource>
                    <directory>src/main/webapp</directory>
                </resource>
            </resources>        
    //plugins goes here (maven-jar-plugin)
    <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>2.3</version>
          <executions>
             <!-- Run shade goal on package phase -->
            <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <!-- add Main-Class to manifest file -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>com.sample.myproject.employee.AppStarter</mainClass>
                </transformer>
              </transformers>
              <filters>
                                        <filter>
                                            <artifact>*</artifact>
                                            <excludes>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                                <exclude>META-INF/LICENSE</exclude>
                                                <exclude>LICENSE</exclude>
                                            </excludes>
                                        </filter>
                                    </filters>
                                    <shadedArtifactAttached>true</shadedArtifactAttached>
                                    <shadedClassifierName>jar-with-dependencies</shadedClassifierName>
            </configuration>
              </execution>
          </executions>
        </plugin>
    </build>
    </project>
maven maven-shade-plugin jar-with-dependencies
© www.soinside.com 2019 - 2024. All rights reserved.