开发者

Maven Assembly Plugin - install the created assembly

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 artifa开发者_Python百科ct, 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


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>


I think assemblies are supposed to be automatically attached to the build, but if that doesn't work, the Maven Build Helper "attach-artifact" goal attaches a specified file to be installed in the repository. I've used this plugin for installing files created by an external process like Ant or NSIS.


I don't know wether this could be usefull for you, but as a JAR file is basically a ZIP file plus the META-INF information, you could create your project as a jar without sources and add the xip countents in src/main/resources without needing any plugin configuration.

If you want your content to be in a different location, you can always do something like:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.myzip</groupId>
  <artifactId>myzip-artifact-id</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <build>
    <resources>
      <resource>
        <targetPath>.</targetPath>
        <filtering>false</filtering>
        <directory>${basedir}/zipcontent</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
    </resources>
  </build>
</project>

I f you want your artifact to be installed and being accessible in a repository you will need to set it up for the deploy phase:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜