Maven 2 Maven程序集插件-安装创建的程序集

Maven 2 Maven程序集插件-安装创建的程序集,maven-2,maven-assembly-plugin,Maven 2,Maven Assembly Plugin,我有一个项目,只是由文件组成。我想将这些文件打包成一个zip文件,并将它们存储在maven存储库中。我已经配置了组装插件来构建zip文件,这部分工作正常,但我似乎不知道如何安装zip文件 另外,如果我想在另一个工件中使用这个程序集,我该如何做呢?我打算调用dependency:unpack,但我在存储库中没有要解包的工件 如何将zip文件放在我的存储库中,以便在另一个工件中重复使用它 母体聚甲醛 <build> <plugins>

我有一个项目,只是由文件组成。我想将这些文件打包成一个zip文件,并将它们存储在maven存储库中。我已经配置了组装插件来构建zip文件,这部分工作正常,但我似乎不知道如何安装zip文件

另外,如果我想在另一个工件中使用这个程序集,我该如何做呢?我打算调用dependency:unpack,但我在存储库中没有要解包的工件

如何将zip文件放在我的存储库中,以便在另一个工件中重复使用它

母体聚甲醛

<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>

maven汇编插件
2.2-β-5
../packaging.xml
儿童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>

com。虚拟主机
聚甲醛
0.0.1
../pom.xml
虚拟主机-***
com。虚拟主机
***
0.0.1
聚甲醛
我把名字过滤掉了。这个POM正确吗?我只想将特定虚拟主机的文件捆绑在一起

谢谢

沃尔特

我已经配置了组装插件来构建zip文件,这部分工作正常,但我似乎不知道如何安装zip文件

那么,创建的程序集应该自动附加到项目中,然后按照
安装
部署
目标上传到存储库中。你能展示一下你的pom吗

更新:根据您当前的配置,我认为程序集不会作为构建的一部分创建。您需要将
单个
目标绑定到生命周期阶段,通常是

  <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>

我不知道这是否对您有用,但由于JAR文件基本上是一个ZIP文件加上META-INF信息,您可以创建一个没有源代码的JAR项目,并在
src/main/resources
中添加xip元素,而无需任何插件配置

如果您希望您的内容位于不同的位置,您可以随时执行以下操作:

<?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>

4.0.0
com.mycompany.myzip

我认为程序集应该自动附加到构建,但如果不起作用,则会附加一个指定的文件以安装到存储库中。我使用这个插件来安装由外部进程(如Ant或NSIS)创建的文件

<?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>