我怎样才能解开maven中的神器?

时间:2012-07-16 22:08:24

标签: maven tar

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

在解开之前我是否需要复制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>

1 个答案:

答案 0 :(得分:4)

您可以使用untar目标dependency:unpackmaven dependency plugin工件。以下是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>