There are modules A, B and C. Module A is a dependency for modules B and C. All jar-s built in the module A are to be distributes into Maven Central but only after integration tests in modules B and C are passed.
To achieve the goal above, I decided to implement a multi-module project with a dedicated module D just for distribution.
As the distribution module D has its own specific coordinates, jar-s from module A are to be renamed.
My idea was to copy jar-s from module A as dependencies to the target dir of the module D with renaming according to the module D coordinates. Here's the module D pom:
<parent>
<groupId>...</groupId>
<artifactId>parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>${project.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>${project.artifactId}-${project.version}.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>${project.version}</version>
<type>jar</type>
<classifier>sources</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>${project.artifactId}-${project.version}-sources.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>${project.version}</version>
<type>jar</type>
<classifier>javadoc</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>${project.artifactId}-${project.version}-javadoc.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
jar-s are copied from the module A to the module's D target directory but only module's D pom is updated in my local repository after install phase is completed. There are no records about installing of copied jar-s in build log either.
At the same time, jar-s from module A are successfully installed.
I tried to change packaging of the module D to jar, but only jar with binaries was installed after that, and jar-s with sources and javadoc weren't installed.
At the moment the following workaround is found:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<javadoc>
${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar
</javadoc>
<sources>
${project.build.directory}/${project.artifactId}-${project.version}-sources.jar
</sources>
</configuration>
</execution>
</executions>
</plugin>
Is there any other less clumsy solution?
Thanks.
It turns out that it's not enough just to copy needed jar-s to target, but those jar-s are to be additionally attached using build-helper-maven-plugin.
So, here's the parent pom (a bit simplified to be consistent with the question details and for the sake of clearness):
Here's the pom of the distributed module D (a bit simplified as well):
After artifacts are attached they're automatically recognized by all other plugins, e.g., gpg, install, deploy, etc.