Maven多模块创建1个jar

时间:2017-12-06 05:26:18

标签: java maven maven-plugin maven-assembly-plugin

我有一个多模块maven项目

abc
  +-- child1
  +-- child2
  +-- child3
  +-- distribution

所以我的最后一个jar看起来像

META-INF/
META-INF/MANIFEST.MF
com/
com/myapp/
com/myapp/service/
com/myapp/service/
com/myapp/service/ServiceFactory.class
com/myapp/service/Counter.class
META-INF/maven/
META-INF/maven/com.myapp/
META-INF/maven/com.myapp/abc/
META-INF/maven/com.myapp/abc/pom.xml
META-INF/maven/com.myapp/abc/pom.properties

child1 pom.xml

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
            <parent>
                <artifactId>abc</artifactId>
                <groupId>com.myapp</groupId>
                <version>1.0-SNAPSHOT</version>
            </parent>

            <packaging>jar</packaging>

            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                    <version>1.7.25</version>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.7.0</version>
                        <configuration>
                            <source>${maven.compiler.source}</source>
                            <target>${maven.compiler.target}</target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </project>

abc pom.xml

<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>
     <artifactId>abc</artifactId>
     <groupId>com.myapp</groupId>
     <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>child1</module>
        <module>distribution</module>
    </modules>
</project>

目前slf4j在最后一个罐子里面 我想创建一个包含child1和child2的jar,但不包含slf4j,它是child1的依赖项。 有人能指出我正确的方向吗?

0 个答案:

没有答案