问题
我有一个嵌套的多个模块(正确的术语?)当我mvn clean package
该项目实际上是我没有编写的其他东西的分支,在某个地方,我打破了构建过程,但我似乎无法找到我所做的。
项目结构如下:
poms如下(很抱歉将它们全部发布在这里,但我真的不确定在哪里看):
根
<groupId>com.something</groupId>
<artifactId>root</artifactId>
<packaging>pom</packaging>
<modules>
<module>child1</module>
<module>child2</module>
<module>distribution</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
分布
<parent>
<groupId>com.something</groupId>
<artifactId>root</artifactId>
</parent>
<artifactId>distribution</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors
<descriptor>src/main/assembly/distribution.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
child1
<parent>
<groupId>com.something</groupId>
<artifactId>root</artifactId>
</parent>
<artifactId>child1</artifactId>
<packaging>jar</packaging>
<dependencies>
many dependencies here...
</dependencies>
的child2
<parent>
<groupId>com.something</groupId>
<artifactId>root</artifactId>
</parent>
<artifactId>child2</artifactId>
<packaging>jar</packaging>
<dependencies>
many dependencies here...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
distribution.xml
<id>package</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>..</directory>
<outputDirectory>.</outputDirectory>
<fileMode>0644</fileMode>
<includes>
<include>README</include>
<include>CHANGELOG</include>
<include>LICENSE.txt</include>
<include>NOTICE.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>../bin</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>../workloads</directory>
<outputDirectory>workloads</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includeSubModules>true</includeSubModules>
<sources>
<includeModuleDirectory>true</includeModuleDirectory>
<fileSets>
<fileSet>
<directory>.</directory>
<fileMode>0644</fileMode>
<includes>
<include>README</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/conf</directory>
<outputDirectory>conf</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<outputDirectory>lib</outputDirectory>
<directory>target</directory>
<includes>
<include>*.jar</include>
</includes>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
</sources>
</moduleSet>
</moduleSets>
注意:代码在github上,如果有人有时间和想要查看真实项目,我很乐意提供存储库的链接!
答案 0 :(得分:2)
我相信这是设计的。这就是罐子的工作方式。如果您要在jar中打包依赖项,那么无论如何它们都无法工作。解决方案是使用阴影插件制作一个uberjar。 Here's a tutorial on how.
maven-assembly-plugin插件也可以这样做,但它没有那么多功能。无论哪种方式,如果你将它添加到你的child1 pom,它也会打包依赖项。