3

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>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Georgios Stathis
  • 533
  • 1
  • 6
  • 21

1 Answers1

5

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/.

Tunaki
  • 132,869
  • 46
  • 340
  • 423