2010-09-09 58 views
1

是否有可能将任务添加到pom.xml文件将创建一个tar.gz/.zip文件。
为eample:的pom.xml - 焦油任务

<tar type="tar.gz" source="resources/sql" tofile="target/sql.tar.gz"/> 

感谢

+0

这大概需要被标记为 “Maven的” – Ither 2010-09-09 14:05:23

回答

3

使用maven-assembly-plugin

创建一个src /主/组装/截至http://maven.apache.org/plugin-developers/cookbook/generate-assembly.html详细bin.xml和http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#bin

把你的资源,SQL文件在includes并给予output格式为tar.gz的

接下来,在你的pom.xml把参考这个插件

<project> 
    [...] 
    <build> 
    [...] 
    <plugins> 
     <plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <version>2.2-beta-5</version> 
     <configuration> 
      <descriptors> 
      <descriptor>src/main/assembly/bin.xml</descriptor> 
      </descriptors> 
     </configuration> 
     <executions> 
      <execution> 
      <phase>package</phase> 
       <goals> 
       <goal>single</goal> 
       </goals> 
      </phase>    
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

末,把这种用

mvn package 
+0

我得到:无法识别的标签:'程序集'。 BTW,我该如何设定目标(DEST/name.tar.gz) – fatnjazzy 2010-09-09 14:20:16

+0

@fatnjazzy:在更新 – JoseK 2010-09-09 17:05:22

+0

不知道为什么,这已经downvoted运行它MVN包,它不值得-1分。所以这里是我的+1。 – 2010-09-10 15:03:00