How to publish multiple jar files to maven on a clean install

匿名 (未验证) 提交于 2019-12-03 07:47:04

问题:

I have a used the maven assembly plugin to create multiple jar from one jar now the problem is that I have to publish these jar to the local repo, just like other maven jars publish by them self when they are built maven clean install how will I be able to do this

here is my pom file

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

Here is my assembly file

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

回答1:

The Build Helper Maven Plugin has a build-helper:attach-artifact allowing to attach additional artifacts to be installed and deployed. It's typically used like this (from the Usage page):

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


回答2:

Thanks a lot Pascal, This thing really works. Here is a the configuration that i have added too make it work..

    <plugin>         <groupId>org.codehaus.mojo</groupId>         <artifactId>build-helper-maven-plugin</artifactId>         <version>1.5</version>         <executions>           <execution>             <id>abc</id>             <phase>package</phase>             <goals>               <goal>attach-artifact</goal>             </goals>             <configuration>               <artifacts>                 <artifact>                   <file>src/main/assembly/flight-assembly.xml</file>                   <type>xml</type>                   <classifier>flight</classifier>                 </artifact>               </artifacts>             </configuration>           </execution>         </executions>   </plugin> 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!