如何从子构建中排除父webapp目录

时间:2016-12-02 08:32:23

标签: maven maven-shade-plugin jar-with-dependencies

我有一个父maven模块runtime,它包含webApp目录,用于存储与网络相关的内容。(html,js等...)。在我的子模块中employee也跟随因此,当我构建具有依赖关系的子项目jar时,它包含两个webapp内容相互覆盖。我的要求是从我的子(employee)jar中依赖依赖关系排除父webapp目录。我使用{{ 3}}将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>

0 个答案:

没有答案