Maven build plugin complains about missing files no matter what I do

I have a similar situation with Adding the jar-with-dependencies artifact from another Maven module , however, the proposed solution did not work for me. I tried using both moduleSets and dependencySets . So, let's go:

Introduction:

I have a multi-module maven project:

 parent | +-myProject | +-myProjectTests 

I want myProjectTests to have jar-with-dependencies created by myProject in its output directory to run integration tests, etc. (I use a framework that requires the actual launch of the jar)

parent pom.xml :

 <project> <groupId>myGroup</groupId> <artifactId>parent</artifactId> <packaging>pom</packaging> <modules> <module>myProject</module> <module>myProjectTests</module> </modules> </project> 

myProject pom.xml :

 <project> <groupId>myGroup</groupId> <artifactId>myProject</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build> </plugins> </project> 

myProjectTests pom.xml :

 <project> <groupId>myGroup</groupId> <artifactId>myProjectTests</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <dependencies> <dependency> <groupId>myGroup</groupId> <artifactId>myProject</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>prepareTests</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>prepare.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> 

prepare.xml

 <assembly> <id>prepareTests</id> <formats> <format>dir</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> ????? </assembly> 

moduleSets:

If I try to specify moduleSets for ????? in my prepare.xml file:

 <moduleSets> <moduleSet> <useAllReactorProjects>true</useAllReactorProjects> <includes> <include>myGroup:myProject</include> </includes> <binaries> <attachmentClassifier>jar-with-dependencies</attachmentClassifier> <unpack>false</unpack> </binaries> </moduleSet> </moduleSets> 

I get this output:

 [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'myGroup.myProject' [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'myGroup.myProject' [WARNING] NOTE: Currently, inclusion of module dependencies may produce unpredictable results if a version conflict occurs. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (prepareTests) on project myProjectTests: Failed to create assembly: Error creating assembly archive prepareTests: You must set at least one file. -> [Help 1] 

I looked at the maven documentation and interns for solutions and tried many different combinations of different flags, all with the same error.

dependencySets:

If I specify dependencySets in like this:

 <dependencySets> <dependencySet> <includes> <include>myGroup:myProject:jar-with-dependencies:0.0.1-SNAPSHOT</include> </includes> <unpack>false</unpack> </dependencySet> </dependencySets> 

I get this:

 [WARNING] Cannot include project artifact: myGroup:myProjectTests:pom:0.0.1-SNAPSHOT; it doesn't have an associated file or directory. [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'myGroup:myProject:jar-with-dependencies:0.0.1-SNAPSHOT' [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (prepareTests) on project myProjectTests: Failed to create assembly: Error creating assembly archive prepareTests: You must set at least one file. -> [Help 1] 

Again, I tried a lot of different flag combinations and removed the jar-with-dependencies classifier, all of which had no effect.

There is nothing useful in debug logs in both cases, and I explored some of the possibilities offered by debug logs.

I just want: the jar-with-dependencies file created by myProject is placed in the output directory myProjectTests during the package phase, ideally without using direct file paths. How do I get maven for this?

+6
source share
1 answer

It turns out that this is a well-known maven error - the build plugin does not work correctly when the submodules do not have the aggregator project as their parent - http://jira.codehaus.org/browse/MASSEMBLY-600 . Looks like I have to use direct file dependencies.

+8
source

Source: https://habr.com/ru/post/957358/


All Articles