2017-04-10 11 views
0

패키지를 기반으로 두 개의 jar 파일을 생성 한 하나의 pom 파일이 있지만 넥서스 저장소에 jar 파일을 모두 업로드하려고합니다. 내가 볼 수 있듯이 하나의 항아리 만이 넥서스 저장소에 복사하는 것이지 다른 하나의 항아리를 복사하는 것이 아닙니다.하나의 pom에 의해 생성 된 여러 개의 jar 파일을 넥서스 저장소에 업로드하는 방법

의 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

문제를 해결하는 다른 프로젝트가 있다는 것을 의미하는 코드를 분리하십시오 ... 왜 BTW :' ... '를 사용하여 defautl 폴더 레이아웃을 변경합니까? 여기에 어떤 문제가 있습니까? – khmarbaise

답변

0

당신은 추가 아티팩트를 배포 할 deploy:deploy-file 목표를 사용할 수 있습니다. 그러나 한 프로젝트에서 두 개의 jar를 빌드하는 것이 Maven 표준에 위배된다는 것을 알고 있어야합니다. 귀하의 경우, 서로 다른 패키지를 포함하는 두 개의 모듈을 프로젝트에서 정의하는 것이 좋습니다.