tags:

views:

55

answers:

1

Hi Is it possible to add a task to the pom.xml file that will create a tar.gz / .zip file.
for eample:

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

Thanks

A: 

Use the maven-assembly-plugin

Create a src/main/assembly/bin.xml as detailed at http://maven.apache.org/plugin-developers/cookbook/generate-assembly.html and http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#bin

Put your resources sql files in the includes and give the format of output as tar.gz

Next, in your pom.xml put the reference to this plugin

<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>
    </execution>
  </executions>
   </project>

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

Last, call this using

mvn package
JoseK
I am getting: Unrecognised tag: 'assembly'. BTW, how do i set the target (dest/name.tar.gz)
fatnjazzy
@fatnjazzy: run it as mvn package in the update
JoseK
Not sure why this has been downvoted, it doesn't deserve a score of -1. So here is my +1.
Pascal Thivent