to create a distribution I decided to use the maven assembly plugin. But in my case, I also need resources from other projects or simply artifacts. Let's use one simple example here and I'm confident that I can solve the more complex ones myself later.
We have a zip artifact on our local repository server which maven is configured to use. The zip file has a flat hierarchy and contains a native code wrapper, a jar file, README and example configurations. For the distribution package we want the first two. The wrapper should be placed in a bin/ directory, the jar file in a lib/ directory. But the zip file is only ever needed for the assembly step. I don't need it to compile or test. And reading the documentation on dependency scopes I didn't find a matching one for this particular use case. The other issues are described in the code below: When I don't specify the zip as a dependency I can't use the artifact later. And I can't place the unpacked files in the correct places.
Maybe my whole approach is wrong? I'd love to hear your opinions.
pom.xml
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/dist.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
dist.xml
<dependencySets>
<dependencySet>
<includes>
<!-- does only work when specified as a dependency in pom.xml -->
<include>my:archive</include>
</includes>
<outputDirectory>unpacked</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
<includes>
<include>wrapper</include>
<include>extraLib.jar</include>
<!-- can't move or rename -->
</includes>
</unpackOptions>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets>