2017-04-10 101 views
0

我有一个pom文件,我已经根据这个包生成了两个jar文件,但是我想上传这两个jar在nexus repo中。正如我所看到的,只有一个jar拷贝到nexus repo,而不是另一个。如何将一个pom生成的多个jar上传到nexus库

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>com.my</groupId> 
<artifactId>Shared</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 
<url>http://maven.apache.org</url> 

<properties> 
    <project.build.directory>.</project.build.directory> 
    <localRepo>C:/Users/myuser/.m2/repository1</localRepo> 
</properties> 



<build> 
    <!--source directory pick the resources to be build. --> 
    <sourceDirectory>source</sourceDirectory> 

    <plugins> 
     <!--maven compiler plugin --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 

     <!--this plugin is to generate the manifest file --> 
     <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> 
      <version>2.4</version> <configuration> <archive> <manifest> 
      <addClasspath>true</addClasspath> </manifest> <manifestEntries> <Built-By>my-org</Built-By> 
      </manifestEntries> </archive> </configuration> </plugin> --> 
     <!-- this plugin to create the multiple jars with inclusion or exclusion 
      of the files --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.4</version> 
      <executions> 
       <execution> 
        <id>default-jar</id> 
        <phase>none</phase> 
       </execution> 
       <execution> 
        <id>build-Castor-jar</id> 
        <goals> 
         <goal>jar</goal> 
        </goals> 
        <phase>prepare-package</phase> 
        <configuration> 
         <archive> 
          <manifest> 

           <addClasspath>true</addClasspath> 
          </manifest> 
          <manifestEntries> 
           <Built-By>my-org</Built-By> 
          </manifestEntries> 
         </archive> 
         <includes> 
          <include>com/my/domain/BigDecimalHandler.class</include> 
          <include>com/my/domain/CalendarFieldHandler.class</include> 

          <include>com/my/domain/TimeZoneFieldHandler.class</include> 

         </includes> 
         <finalName>Castor-${version}</finalName> 
         <!-- <outputDirectory>${localRepo}/com/my/Castor/${version}/</outputDirectory> --> 
        </configuration> 
       </execution> 
       <execution> 
        <id>build-Shared-jar</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>jar</goal> 
        </goals> 
        <configuration> 
         <archive> 
          <manifest> 

           <addClasspath>true</addClasspath> 
          </manifest> 
          <manifestEntries> 
           <Built-By>my-org</Built-By> 
          </manifestEntries> 
         </archive> 
         <excludes> 
          <exclude>com/my/domain/BigDecimalHandler.class</exclude> 
          <exclude>com/my/domain/CalendarFieldHandler.class</exclude> 

          <exclude>com/my/domain/TimeZoneFieldHandler.class</exclude> 

         </excludes> 
         <finalName>Shared-${version}</finalName> 

        </configuration> 
       </execution> 
      </executions> 
     </plugin> 



    </plugins> 
</build> 
    <repositories> 
     <repository> 
      <id>central</id> 
      <name>Maven Plugin Repository</name> 
      <url>http://nxrepository/nexus/content/groups/public</url> 
     </repository> 

+0

分离你的代码,这意味着有不同的项目,解决问题...顺便说一句:为什么你使用' ...'更改defautl文件夹布局?这里有什么问题? – khmarbaise

回答

0

您可以使用deploy:deploy-file目标部署额外的假象。但是你应该知道,从一个项目中构建两个罐子是违反Maven标准的。在你的情况下,你最好在你的项目中定义两个包含不同包的模块。

相关问题