我的问题是maven组件插件是否仍然引用了未在artefactory / repository中安装的ear类型的依赖项。
考虑下面的多模块项目,父母:
<?xml version="1.0" encoding="UTF-8"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>parent</name>
<modules>
<module>module1</module>
<module>assembly</module>
</modules>
</project>
带耳模块:
<?xml version="1.0"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
</parent>
<groupId>com.test</groupId>
<artifactId>module1</artifactId>
<packaging>ear</packaging>
<name>EAR Module</name>
</project>
和汇编模块:
<?xml version="1.0"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
</parent>
<groupId>com.test</groupId>
<artifactId>assembly</artifactId>
<packaging>jar</packaging>
<name>Assembly Module</name>
<dependencies>
<!-- Note - the dependencies (and their associated dependencies etc) are
subsequently available for assembly dependencySet includes -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<type>ear</type>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
使用程序集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>bundle</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<!--
Include EAR
-->
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>xxxxxxxxx.ear</outputFileNameMapping>
<outputDirectory>eardirectory</outputDirectory>
<includes>
<include>${pom.groupId}:module1:ear</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
从具有空存储库的全新签出中,在执行带有错误的mvn编译时,父项目pom失败
[错误]无法在项目汇编上执行目标:无法解析项目com.test的依赖项:assembly:jar:1.0:找不到工件com.test:module1:ear:1.0 ...
然而,如果我第一次进入ear模块并进行mvn安装,那么从父模块进行的后续mvn编译就可以正常工作。
此外,如果耳模块是标准jar模块,则此问题不存在。这样,如果依赖模块是jar类型,则在从父代进行初始mvn编译之前,不需要先将其安装到本地repos中。
将装配pom中的依赖关系切换为范围&#39;运行时&#39;允许初始mvn编译成功,但mvn测试将失败。将依赖项设置为可选也不成功。
有人可以建议一个潜在的解决方案吗?
我希望我不需要沿着fileSet路径,或者使用maven-dependency-plugin。此依赖项仅存在于pom中,以便程序集插件可以打包/引用它。它不适用于编译/运行时/测试。所以maven依赖范围都没有任何意义。