如何在 Maven 中解压工件?

joh*_*ran 2 tar maven

如何解压工件以用于编译我的源代码?

我需要在解压之前复制 tar 文件吗?

我有类似下面的东西...

    <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>
Run Code Online (Sandbox Code Playgroud)

Rag*_*ram 7

您可以untar通过使用dependency:unpack目标maven dependency plugin. 这是示例的修改版本。

      <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>
Run Code Online (Sandbox Code Playgroud)