maven-2 - 如何在全新安装时将多个 jar 文件发布到 maven

标签 maven-2 maven-assembly-plugin

我已经使用 maven assembly 插件从一个 jar 创建多个 jar 现在问题是我必须将这些 jar 发布到本地 repo,就像其他 maven jar 在构建时由它们自己发布 maven clean install 我将如何能够做到这一点

这是我的 pom 文件

<project>
 <parent>
  <groupId>parent.common.bundles</groupId>
  <version>1.0</version>
  <artifactId>child-bundle</artifactId>
 </parent>
 <modelVersion>4.0.0</modelVersion>
 <groupId>common.dataobject</groupId>
 <artifactId>common-dataobject</artifactId>
 <packaging>jar</packaging>
 <name>common-dataobject</name>
 <version>1.0</version>
 <dependencies>
      </dependencies>
 <build>
  <plugins>
   <plugin>
    <groupId>org.jibx</groupId>
    <artifactId>maven-jibx-plugin</artifactId>
    <version>1.2.1</version>
    <configuration>
     <directory>src/main/resources/jibx_mapping</directory>
     <includes>
      <includes>binding.xml</includes>
     </includes>
     <verbose>false</verbose>
    </configuration>
    <executions>
     <execution>
      <goals>
       <goal>bind</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
     <execution>
      <id>make-business-assembly</id>
      <phase>package</phase>
      <goals>
       <goal>single</goal>
      </goals>
      <configuration>
       <appendAssemblyId>false</appendAssemblyId>
       <finalName>flight-dto</finalName>
       <descriptors>
        <descriptor>src/main/assembly/car-assembly.xml</descriptor>
       </descriptors>
       <attach>true</attach>
      </configuration>
     </execution>
     <execution>
      <id>make-gui-assembly</id>
      <phase>package</phase>
      <goals>
       <goal>single</goal>
      </goals>
      <configuration>
       <appendAssemblyId>false</appendAssemblyId>
       <finalName>app_gui</finalName>
       <descriptors>
        <descriptor>src/main/assembly/bike-assembly.xml</descriptor>
       </descriptors>
       <attach>true</attach>
      </configuration>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>

  </project>

这是我的程序集文件
<assembly>
  <id>app_business</id>
  <formats>
    <format>jar</format>
  </formats>
  <baseDirectory>target</baseDirectory>
  <includeBaseDirectory>false</includeBaseDirectory>

  <fileSets>
    <fileSet>
      <directory>${project.build.outputDirectory}</directory>
      <outputDirectory></outputDirectory> 
      <includes>
        <include>com/dataobjects/**</include>
      </includes>
    </fileSet>    
  </fileSets>
</assembly>

最佳答案

Build Helper Maven Plugin有一个 build-helper:attach-artifact 允许附加要安装和部署的其他工件。它通常像这样使用(来自 Usage 页面):

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <!-- add configuration for antrun or another plugin here -->
      </plugin>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>some file</file>
                  <type>extension of your file </type>
                  <classifier>optional</classifier>
                </artifact>
                ...
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

关于maven-2 - 如何在全新安装时将多个 jar 文件发布到 maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2789671/

相关文章:

java - 如何排除 Maven 程序集中的资源文件?

java - 找不到 "org.eclipse.persistence"Maven 依赖项

java - hibernate3 maven 插件 :make hbm2java generate hibernate annotations instead of ejb3 annotations

maven-2 - 确定使用 makefile 和 ant 脚本的构建过程中的所有文件依赖项

eclipse - 将 m2eclipse 的 War-Plugin 集成到 Eclipse 项目中

maven - 如何在通过 maven 创建 zip 文件时排除某些文件夹

java - Maven 程序集中是否有程序集 id 属性?

java - 获取包含依赖项的 jar 文件名作为变量

maven-2 - Maven 校验和 pom 设置?

java - Maven 程序集 : add different version of the same artifact