One of my projects has a structure like this:
.\ca\<modulename>\dist\<modulename>.zip
I want to make a package that just has the zip files in a single package, so if I have submodules mod1
, mod2
, modn
, I'll end up with:
ZIP CONTENT:
mod1.zip
mod2.zip
...
modn.zip
What I've done so far is create a maven project and, using maven dependency
and assembly
plugins I got to this:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>es.xunta.emprego.cntxes</groupId>
<artifactId>myproject-cas</artifactId>
<version>${cas.version}</version>
<overWrite>true</overWrite>
<outputDirectory>target/dependency</outputDirectory>
<type>zip</type>
<includes>ca/**/dist/*.zip</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/main/assembly/zip.xml</descriptor>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- this is used for inheritance merges -->
<phase>package</phase>
<!-- append to the packaging phase. -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
With this being assembly/zip.xml
:
<?xml version="1.0" encoding="UTF-8" ?>
<assembly>
<id>bin</id>
<formats>
<!-- formato de salida del empaquetado -->
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<directory>target/dependency</directory>
<includes>
<include>/**/dist/*.zip</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>
But this is respecting my original zip's folder structure, so the result is:
ZIP CONTENT
ca\mod1\dist\mod1.zip
ca\mod2\dist\mod2.zip
...
ca\modn\dist\modn.zip
It might seem a small issue but the number of modules is big and gathering the different zip files is very annoying having to browse through every folder. I've been struggling with assembly
and dependency
but haven't found a way to achieve what I want. Note that I'm using wildcards (ca/**/dist/*.zip
) because I don't know prior to compilation the name of the files that will be there.
Any help please?