4

我的项目有一个父模块,其中有 3 个子模块。我正在尝试使用 maven 程序集插件创建一个胖罐子。但是,我想要的是创建一个胖 jar,然后应用 assembly.xml 文件来进一步捆绑我的项目。

模块1 pom.xml

<dependencies>
    <dependency>
        <groupId>common</groupId>
        <artifactId>commonutils</artifactId>
        <version>1.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptor>src/main/assembly/oozie.xml</descriptor>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我的汇编文件

<assembly>
<id>bundle</id>
<formats>
    <format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>search</baseDirectory>

<fileSets>
    <fileSet>
        <directory>${project.basedir}/src/main/workflow</directory>
        <outputDirectory>/</outputDirectory>
        <excludes>
            <exclude>*/**.properties</exclude>
        </excludes>
    </fileSet>
    <fileSet>
        <directory>${project.build.directory}</directory>
        <outputDirectory>/lib</outputDirectory>
        <includes>
            <include>*.jar</include>
        </includes>
    </fileSet>
</fileSets>

<files>
    <file>
        <source>${project.basedir}/src/main/workflow/job.properties</source>
        <outputDirectory>/</outputDirectory>
        <filtered>true</filtered>
    </file>
</files>

<moduleSets>
    <moduleSet>
        <useAllReactorProjects>true</useAllReactorProjects>
        <binaries>
            <outputDirectory>/</outputDirectory>
            <unpack>false</unpack>
            <dependencySets>
                <dependencySet>
                    <outputDirectory>lib</outputDirectory>
                    <unpack>false</unpack>
                    <scope>runtime</scope>
                </dependencySet>
            </dependencySets>
        </binaries>
    </moduleSet>
</moduleSets>

运行时

mvn package

最终的 jar 只包含模块代码而不是它的所有依赖项?这里有什么问题??

4

1 回答 1

1

使用完全满足此目的的预定义程序集描述符jar-with-dependencies 。

于 2013-06-13T08:46:21.037 回答