Unzip dependency in maven

后端 未结 2 1697
刺人心
刺人心 2020-11-29 08:13

I have the following dependency in maven


  org.hyperic
  sigar-dist
           


        
相关标签:
2条回答
  • 2020-11-29 08:48

    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:

    • Unpacking project dependencies
    • dependency:unpack-dependencies
    0 讨论(0)
  • 2020-11-29 09:02

    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>
    
    0 讨论(0)
提交回复
热议问题