Unzip dependency in maven

前提是你 提交于 2019-11-27 04:46:37

You can do it with dependencies:unpack-dependencies:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.2</version>
    <executions>
      <execution>
        <id>unpack-sigar</id>
        <phase>package<!-- or any other valid maven phase --></phase>
        <goals>
          <goal>unpack-dependencies</goal>
        </goals>
        <configuration>
          <includeGroupIds>org.hyperic</includeGroupIds>
          <includeArtifactIds>sigar-dist</includeArtifactIds>
          <outputDirectory>
             ${project.build.directory}/wherever/you/want/it
             <!-- or: ${project.basedir}/wherever/you/want/it -->
          </outputDirectory>
        </configuration>
      </execution>
    </executions>
</plugin>

Reference:

just a follow up on answer from @Sean Patrick Floyd

this is my final pom.xml to download and unpack tomcat

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.koushik.javabrains</groupId>
    <artifactId>tomcat</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>tomcat</name>

    <properties>
        <tomcat.version>8.0.27</tomcat.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>unpack-tomcat</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.apache.tomcat</includeGroupIds>
                            <includeArtifactIds>tomcat</includeArtifactIds>
                            <outputDirectory>
                                ${project.build.directory}
                                <!-- or: ${project.basedir}/wherever/you/want/it -->
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>${tomcat.version}</version>
            <type>zip</type>
        </dependency>
    </dependencies>
</project>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!