问题描述
我不明白如何在程序集中的<dependencySet>
中添加部分依赖项
例如,我依赖于group:artifact1和group:artifact2,它们都依赖于group:artifact0.
我创建了程序集描述符,该程序集描述符应该复制具有所有依赖项的group:artifact2.
如果pom.xml中对group:artifact1的依赖性出现在对group:artifact2的依赖性之前,则我在目标目录中只有group:artifact2,但是如果我更改依赖性的顺序,那么我在目标目录中都有这两个工件. >
结果,我想拥有两个目录,这些目录具有不同的库集.
这里有一个简单的例子
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>
<groupId>com.kudrevatykh.stackoverflow</groupId>
<artifactId>assembly-question</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<spring.version>3.2.3.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>install</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>install.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
install.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>install</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>dir</format>
</formats>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.springframework:spring-jdbc:jar</include>
</includes>
<useTransitiveFiltering>true</useTransitiveFiltering>
<outputDirectory>/</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
mvn --version
输出
Apache Maven 3.0.4 (r1232337; 2012-01-17 12:44:56+0400)
Maven home: C:\Users\akudrevatykh\bin\apache-maven-3.0.4
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: C:\Users\akudrevatykh\bin\jdk1.7.0_11\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
maven-assembly插件已打开一个旧错误 https://issues.apache.org/jira/browse/MASSEMBLY-357 (带有类似示例).
I don't understand how to add part of dependencies to <dependencySet>
in assembly
for example I have dependency on group:artifact1 and group:artifact2 that both depend on group:artifact0.
I create assembly descriptor that should copy group:artifact2 with all dependencies.
If dependency on group:artifact1 in pom.xml appears before dependency on group:artifact2, I have only group:artifact2 in target dir, but if I change order of dependencies, than I have both artifacts in target dir.
In result I want to have two directories with different set of libraries.
Simple example here
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>
<groupId>com.kudrevatykh.stackoverflow</groupId>
<artifactId>assembly-question</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<spring.version>3.2.3.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>install</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>install.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
install.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>install</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>dir</format>
</formats>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.springframework:spring-jdbc:jar</include>
</includes>
<useTransitiveFiltering>true</useTransitiveFiltering>
<outputDirectory>/</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
mvn --version
output
Apache Maven 3.0.4 (r1232337; 2012-01-17 12:44:56+0400)
Maven home: C:\Users\akudrevatykh\bin\apache-maven-3.0.4
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: C:\Users\akudrevatykh\bin\jdk1.7.0_11\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
There is old bug opened for maven-assembly plugin https://issues.apache.org/jira/browse/MASSEMBLY-357 with similar examples.
这篇关于Maven程序集插件的DependencySet与传递依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!