我的文件夹中有多个zip文件。我想解压缩所有这些文件并放入目标文件夹。我想避免在我的pom.xml文件中指定每个zip文件。请检查我写的插件。难道没有更好的解决方案接受* .zip文件吗?非常感谢。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>prepare</id>
<phase>validate</phase>
<configuration>
<tasks>
<unzip src="${user.home}/${dasmo.storage}/calendar-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/controls-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/devices-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/events-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/logs-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/places-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/provisioning-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/recordings-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/scripts-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/smartcontrols-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/storage-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/system-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/webrtc-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<!--
<unzip src="${user.home}/${dasmo.storage}/calendar-persistence.zip" dest="${user.home}/${dasmo.storage}/" />
<copy file="${basedir}/../gwr-devices-module/${config.location}" todir="${project.build.directory}/${dasmo.storage}/devices/" />
<copy file="${basedir}/../gwr-logs-module/${config.location}" todir="${project.build.directory}/${dasmo.storage}/logs/" />
<copy file="${basedir}/../gwr-logs-module/src/main/resources/*.zip" todir="${user.home}/${dasmo.storage}/" />
<unzip src="${user.home}/${dasmo.storage}/*.zip" dest="${user.home}/${dasmo.storage}/" />
-->
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
答案 0 :(得分:-1)
<script>
部分中创建代码。示例:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>unzip-files-in-folder</id>
<phase>process-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>
// ... your unzip code goes here ...
</script>
</scripts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>