简体   繁体   中英

How can I untar an artifact in maven?

How do I untar an artifact to use to compile my source?

Do I need to copy the tar file before untarring it?

I have something like below...

    <build>
      <plugins>
        <plugin>
          <artifactId>abcId</artifactId>
          <version>1</version>
          <executions>
            <execution>
              <id>abc untar</id>
              <phase>process-resources</phase>
              <goals>
                <goal>exec</goal>
              </goals>

            <configuration>
              <executable>tar</executable>
              <workingDirectory>???</workingDirectory>
              <arguments>
                <argument>xvf abc.tar</argument>
              </arguments>
            </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>

You can untar an artifact by using dependency:unpack goal of maven dependency plugin . Here is a modified version of the example .

      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>2.4</version>
         <executions>
           <execution>
             <id>unpack</id>
             <phase>process-resources</phase>
             <goals>
               <goal>unpack</goal>
             </goals>
             <configuration>
               <artifactItems>
                 <artifactItem>
                   <groupId>artifact-groupId</groupId>
                   <artifactId>the-artifact</artifactId>
                   <version>a.b</version>
                   <type>tar</type>
                   <outputDirectory>${project.build.directory}/artifactLocation</outputDirectory>
                 </artifactItem>
               </artifactItems>
             </configuration>
           </execution>
         </executions>
       </plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM