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>
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/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With