You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jeffrey Ricks <je...@gmail.com> on 2009/12/30 14:41:09 UTC

Assembly Plugin: Unpack Dependency Set Without Paths?

Hi,

I have a multi-module project (test-project) and I'm using a "assembler
module" (testB) to build an output bundle as described in the docs.  One of
my modules produces a jar file of resources (testA).  The assembler module
needs to extract some of the files from that zip into a destination file
structure.  For example, in the jar from testA is:

env/bin/test.sh

and I want the file test.sh to end up in a zip archive, in a directory
called bin like this:

bin/test.sh

but it ends up being put in bin/env/bin/test.sh

instead because the unpacker is unpacking the existing structure into the
new structure.  I haven't found a way to tell the unpacker to ignore the
source directory structure when adding the file to the destination archive.
Is there an easy or alternative way to do this?  I have included the
projects that reproduces the "problem".  If you run mvn package on the
test-project pom, the resulting testB-1.0-test-bundle-B.zip will have the
contents I described.

Thanks in advance,

Jeff

Assembly Plugin: Unpack Dependency Set Without Paths?

Posted by Jeffrey Ricks <je...@gmail.com>.
Hi,

I have a multi-module project (test-project) and I'm using a "assembler
module" (testB) to build an output bundle as described in the docs.  One of
my modules produces a jar file of resources (testA).  The assembler module
needs to extract some of the files from that zip into a destination file
structure.  For example, in the jar from testA is:

env/bin/test.sh

and I want the file test.sh to end up in a zip archive, in a directory
called bin like this:

bin/test.sh

but it ends up being put in bin/env/bin/test.sh

instead because the unpacker is unpacking the existing structure into the
new structure.  I haven't found a way to tell the unpacker to ignore the
source directory structure when adding the file to the destination archive.
Is there an easy or alternative way to do this?  I have included the poms
below that reproduce the "problem".  If you run mvn package on the
test-project pom, the resulting testB-1.0-test-bundle-B.zip will have the
contents I described.

Thanks in advance,

Jeff


pom.xml for test-project
-----------------

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>test-group</groupId>
  <artifactId>test-project</artifactId>
  <packaging>pom</packaging>
  <version>1.0</version>
  <name>test-project</name>
  <url>http://maven.apache.org</url>
  <modules>
    <module>testA</module>
    <module>testB</module>
  </modules>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.0.2</version>
          <configuration>
            <source>1.6</source>
            <target>1.6</target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project>


pom.xml for testB
-----------------

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>test-group</groupId>
  <artifactId>testA</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <name>testA</name>
  <url>http://maven.apache.org</url>

  <parent>
    <groupId>test-group</groupId>
    <artifactId>test-project</artifactId>
    <version>1.0</version>
  </parent>

</project>


pom.xml for testB
-----------------

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>test-group</groupId>
  <artifactId>testB</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <name>testB</name>
  <url>http://maven.apache.org</url>

  <parent>
    <groupId>test-group</groupId>
    <artifactId>test-project</artifactId>
    <version>1.0</version>
  </parent>

  <dependencies>
    <dependency>
      <groupId>test-group</groupId>
      <artifactId>testA</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <executions>
          <execution>
            <id>test-execution</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>test-assembly.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>


test-assembly.xml
------------------

<assembly>
  <id>test-bundle-B</id>
  <includeBaseDirectory>false</includeBaseDirectory>
  <formats>
    <format>zip</format>
  </formats>
  <dependencySets>
    <dependencySet>
      <outputDirectory>/bin</outputDirectory>
      <fileMode>0755</fileMode>
      <includes>
        <include>test-group:testA:jar</include>
      </includes>
      <unpack>true</unpack>
      <unpackOptions>
        <includes>
          <include>env/bin/test.sh</include>
        </includes>
      </unpackOptions>
    </dependencySet>
  </dependencySets>
</assembly>