Maven zip artifact copy, unzip and rename

I have a maven module which is packaged as a zip with naming my-artifact-1.0-SNAPSHOT.zip using maven-shade-plugin.

Once the artifact has been installed into local maven repo, I need:

  1. Copy zip to configured local folder.
  2. Unzip archive.
  3. Rename unzipped folder from my-artifact-1.0-SNAPSHOT to my-artifact.

This process should be cross-platform working on Windows, Linux, MacOS machines.

I read that it could be accomplished by using:

  1. maven-dependency-plugin plus another plugin
  2. maven-groovy-plugin

What would the best way to implement such a flow? Any examples are very appreciated.

No need for antrun in my opinion, the maven-dependency-plugin should do the trick:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>[your.group.id]</groupId>
                                <artifactId>my-artifact-1.0-SNAPSHOT</artifactId>
                                <version>[your.version]</version>
                                <type>zip</type>
                                <outputDirectory>${project.basedir}/my-artifact/</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Regards,

Tom

You have a maven plugin that can execute Ant-Tasks. This tasks let you execute a lot of works. For example, to unzip a file:

<plugins>
   <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.8</version>
      <executions>
         <execution>
            <phase>generate-resources</phase>
            <configuration>
               <tasks>
                  <unzip src="path/to/zip/file.zip" dest="path/to/unzip" />
               </tasks>
            </configuration>
            <goals>
               <goal>run</goal>
            </goals>
         </execution>
      </executions>
   </plugin>
</plugins>

You can check all availables task in the apache ant page (see references).

Reference:
https://ant.apache.org/manual/Tasks