Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use maven-antrun-plugin to unzip multiple files with regex definition for the file

I am trying to use the maven-antrun-plugin in order to unzip a file. How can this file be defined by using a regular expression? E.g. unzip all files that match: sample[0-9].zip.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>prepare</id>
            <phase>initialize</phase>
            <configuration>
                <tasks>
                    <unzip src="${project.build.directory}/{REGEX_GOES_HERE}.zip" dest="${project.build.directory}/dest/" />
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
like image 323
Georgios Stathis Avatar asked Dec 01 '25 20:12

Georgios Stathis


1 Answers

You can use the Ant Unzip task by specifying to consider it a fileset where the file names match a given regular expression.

<unzip dest="${project.build.directory}/dest/">
  <fileset dir="${project.build.directory}">
    <filename regex="^sample[0-9].zip$"/>
  </fileset>
</unzip>

In the above snippet, all ZIP files under ${project.build.directory} whose name are exacly sample[0-9].zip will be unzipped into ${project.build.directory}/dest/.

like image 61
Tunaki Avatar answered Dec 04 '25 11:12

Tunaki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!