Maven Assembly Plugin - install the created assembly

Walter White picture Walter White · Apr 14, 2010 · Viewed 17.3k times · Source

I have a project that simply consists of files. I want to package those files into a zip and store them in a maven repository. I have the assembly plugin configured to build the zip file and that part works just fine, but I cannot seem to figure out how to install the zip file?

Also, if I want to use this assembly in another artifact, how would I do that? I am intending on calling dependency:unpack, but I don't have an artifact in the repository to unpack.

How can I get a zip file to be in my repository so that I may re-use it in another artifact?

parent pom

<build>
        <plugins>
            <plugin>
                <!--<groupId>org.apache.maven.plugins</groupId>-->
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
                <configuration>
                    <filters>
                        <filter></filter>
                    </filters>
                    <descriptors>
                        <descriptor>../packaging.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>

Child POM

<parent>
    <groupId>com. ... .virtualHost</groupId>
    <artifactId>pom</artifactId>
    <version>0.0.1</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<name>Virtual Host - ***</name>
<groupId>com. ... .virtualHost</groupId>
<artifactId>***</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>

I filtered the name out. Is this POM correct? I just want to bundle files for a particular virtual host together.

Thanks,

Walter

Answer

Pascal Thivent picture Pascal Thivent · Apr 14, 2010

I have the assembly plugin configured to build the zip file and that part works just fine, but I cannot seem to figure out how to install the zip file?

Well, the created assembly should get automatically attached to the project and then uploaded into the repository on an install and deploy goal. Can you show your pom?

Update: With your current configuration, I don't think that the assembly gets created as part of your build. You need to bind the single goal to a lifecycle phase, typically package:

  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-5</version>
    <configuration>
      <descriptors>
        <descriptor>../packaging.xml</descriptor>
      </descriptors>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id> <!-- this is used for inheritance merges -->
        <phase>package</phase> <!-- append to the packaging phase. -->
        <goals>
          <goal>single</goal> <!-- goals == mojos -->
        </goals>
      </execution>
    </executions>
  </plugin>

And now it should get installed/deployed properly.

Also, if I want to use this assembly in another artifact, how would I do that? I am intending on calling dependency:unpack, but I don't have an artifact in the repository to unpack.

You can declare a dependency on an assembly (using the right classifier and type in your case) but since dependency are resolved through the repository, you'll need to solve the first step first. Then, declare something like this (where the classifier is the assembly's id):

<dependency>
  <groupId>com. ... .virtualHost</groupId>
  <artifactId>***</artifactId>
  <version>0.0.1</version>
  <classifier>...</classifier>
  <type>zip</type>
</dependency>