LOrD_ARaGOrN
LOrD_ARaGOrN

Reputation: 4486

zip and than unzip a Maven project inside other project to extract some files?

Is there any way in Maven (without using ant plugin) to zip another project, and unzip it in ${project.build.directory}. In pom.xml, i created below entry in pom.xml under profile

<plugin>
    <groupId>com.orgname.someproject</groupId>
    <artifactId>someproject-onsite</artifactId>
    <version>1.2.3</version>
    <configuration>
        <packaging>zip</packaging>
        <execution>
            <id>unzip</id>
        <goals>
            <goal>unzip</goal>
        </goals>
        <outputDirectory>${project.build.directory}</outputDirectory>
        </execution>
    </configuration>
</plugin>

when i run mvn clean install, it creates the build successfully but i can't see zip or unzip files.

Upvotes: 0

Views: 227

Answers (1)

LOrD_ARaGOrN
LOrD_ARaGOrN

Reputation: 4486

Output Directory: we can specify where exactly we want unzipped files, includes: we can filter/specify which directory we want

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.2.1</version>
    <executions>
        <execution>
            <id>unpack</id>
            <goals>
                <goal>unpack</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.myorg.abcd</groupId>
                        <artifactId>config-abcd</artifactId>
                        <version>1.2.3</version>
                        <type>zip</type>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                    </artifactItem>
                </artifactItems>
                <includes>mnbv/bin/**/*.*</includes>
            </configuration>
        </execution>
    </executions>
</plugin>

Upvotes: 1

Related Questions