Unzip and burn the file using Maven?

Question : is there any way in Maven (without resorting to the ant plugin) to unzip the file, cd to a directory, delete the file, and rezip it, all as part of the assembly?

This is necessary because it is a complex assembly, and you do not need to use gradle to complete this task.

+4
source share
1 answer

The requirement to unzip, delete the file and the firmware can again also be fulfilled in one step with truezip-maven-pluginand remove, which:

Delete the fileset from the existing archive.

official examples also cover this scenario.

:

<properties>
    <archive>${project.basedir}/sample.zip</archive>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>truezip-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <id>remove-a-file</id>
                    <goals>
                        <goal>remove</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <fileset>
                            <!-- note how the archive is treated as a normal file directory -->
                            <directory>${archive}</directory>
                            <includes>
                                <include>hello.txt</include>
                            </includes>
                        </fileset>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

:

mvn clean package

${archive} ( a sample.zip pom.xml, project.basedir) hello.txt, rezip .

, properties, . , :

  • Zip ,
  • , , Maven , Maven
  • , , , , , . , maven-resources-plugin copy-resources.
+2

Source: https://habr.com/ru/post/1655851/


All Articles