Issue
I have a multi-module Maven project that looks like:
- Reactor -> type pom
Ultimately when I package this up for release, the only dependencies a consumer of this library should need are:
- All (which at build, embeds Scripts, Resources, JarFile and Frontend's files)
- JarFile (which would be used if they want to develop against the public Java APIs defined in this Jar)
I noted if I deploy ONLY the All and JarFile, and only add those 2 dependencies to a consuming project and build my consuming project, I get maven build errors saying Scripts, Resources and Frontend cannot be found (since they're referenced by the All's pom)
- When using the All artifact directly (in its build state), why does Maven care if it can't resolve the All pom's dependencies? Should those be an implementation detail OF the All project?
- Is there any way I can configure the release so that I only have to do release the All zip and JarFile jar artifacts? And not these "implementation detail" artifacts?
Solution
Q1: When using the All artifact directly (in its build state), why does Maven care if it can't resolve the All pom's dependencies? Should those be an implementation detail OF the All project?
Maven 3 resolves dependencies transitively by design.
Q2: Is there any way I can configure the release so that I only have to do release the All zip and JarFile jar artifacts? And not these "implementation detail" artifacts?
Yes, you may use flatten-maven-plugin
to flatten the POM before publishing with the configuration described on usage page:
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<!--<version>1.2.2</version>-->
<configuration>
<flattenMode>minimum</flattenMode>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Answered By - Illya Kysil
Answer Checked By - Timothy Miller (JavaFixing Admin)