2012-08-01 2 views
2

내 제품에는 하나의 pom 모듈이 결합 된 여러 Java 프로젝트 (jar 패키지)가 있습니다. 각 프로젝트는 서로 다른 종속성을 가지며 결합 된 종속성은 상위 pom에 정의됩니다. 나는 생산을위한 출력을 준비하려면 다음을 수행하십시오Maven에서 프로덕션을위한 jar 배포

  1. 배포 (복사)
  2. 다른 하나의 폴더
  3. 사본에 모든 프로젝트에서 제 3 자 항아리를 복사 한 위치에 내 모든 항아리 모든 프로젝트에서 세 번째 폴더에 이르는 구성 파일 (src/main/resources 아래에 있음)

누구나 모든 프로젝트에 대해 위의 각각을 수동으로 복사하지 않고도 할 수있는 방법을 알고 있습니까? 또한 향후 프로젝트가 너무 열심히하고 구체적으로 작업하지 않고도이 배포 절차를 지원하기를 바랍니다.

답변

0

요약 할 것입니다. 안드레이 보리 소프 (Andrey Borisov) 답변 외에도 어셈블리 XML (내 모든 문제에 답변)에서 수행 한 작업을 요약합니다.

  1. 배포 (복사)
  2. [은 "dependencySets"요소를 사용] 다른 모든 프로젝트에서 제 3 자 항아리를 복사 [ "moduleset"요소가 사용] 단일 위치 내 모든 항아리
  3. 모든 프로젝트의 구성 파일 (src/main/resources 아래에 있음)을 세 번째 폴더에 복사하십시오. [사용 된 "세트"요소]

    http://maven.apache.org/xsd/assembly-1.1.2.xsd "> DIR 빈 거짓

    <moduleSets> 
        <moduleSet> 
         <useAllReactorProjects>true</useAllReactorProjects> 
         <binaries> 
          <outputDirectory>modules</outputDirectory> 
          <unpack>false</unpack> 
         </binaries> 
        </moduleSet> 
    </moduleSets> 
    
    
    <dependencySets> 
        <dependencySet> 
         <useProjectArtifact>false</useProjectArtifact> 
         <outputDirectory>lib</outputDirectory> 
        </dependencySet> 
    </dependencySets> 
    
    <fileSets> 
        <fileSet> 
         <directory>my DIR 1</directory> 
         <excludes> 
          <exclude>*log4j*</exclude> 
         </excludes> 
         <outputDirectory>resources</outputDirectory> 
        </fileSet> 
        <fileSet> 
         <directory>my DIR 2</directory> 
         <outputDirectory>resources</outputDirectory> 
        </fileSet> 
    </fileSets> 
    

2

당신은이에 대한 메이븐 어셈블리 플러그인을 사용합니다 - 여기에 (그냥 압축 해제 한 후 필요 생산에) 분배를 압축하는의 예는 다음과 같습니다

<plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
        <configuration> 
         <descriptors> 
          <descriptor>${project.basedir}/src/main/assembly/assembly.xml</descriptor> 
         </descriptors> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

및 조립 XML

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> 
<id>${env}</id> 
<formats> 
    <format>zip</format> 
</formats> 
<includeBaseDirectory>false</includeBaseDirectory> 

<dependencySets> 
    <dependencySet> 
     <useProjectArtifact>false</useProjectArtifact> 
     <includes> 
      <include>com.mycompany:ear-project</include> 
      <include>com.mycompany:jnlp-project</include> 
     </includes> 
     <outputDirectory>libs</outputDirectory> 
    </dependencySet> 
</dependencySets> 

<fileSets> 
    <fileSet> 
     <directory>src/main/resources</directory> 
     <outputDirectory>/</outputDirectory> 
    </fileSet> 
    <fileSet> 
     <directory>target/docbook/pdf</directory> 
     <includes> 
      <include>index.pdf</include> 
     </includes> 
     <outputDirectory>/</outputDirectory> 
    </fileSet> 
</fileSets> 

두 프로젝트 (EAR, JNLP)에 대해서는 outputDirectory 구성을 통해 종속성을 지정할 수 있습니다.

+0

중요한 문제는 리소스 폴더로 남아 있습니다. "filesets"요소를 사용하려면 다음을 지정해야합니다. 복사 할 정확한 리소스 폴더. 디렉토리 및/또는 파일 이름을 수동으로 지정하지 않고 프로젝트의 모든 하위 모듈의 모든 컨텐츠를 자동으로 복사하려고합니다. – Omri

+0

젠킨스를 사용합니까? – Tomer

+0

예. 나는 젠킨스를 사용한다. – Omri

0

나는 내 프로젝트에서 동일한 요구 사항을 가지고있다.

ClearCase와 SVN을 함께 사용하는 경우에는 Jenkins를 사용하는 것과 차이가 있습니다. SVN을 사용하는 경우 프로젝트를 주 프로젝트로 체크 아웃해야하고 같은 디렉터리에있는 것처럼 작업해야합니다.

내 자식 프로젝트를 체크 아웃 한 후 해당 프로젝트에서 작업 할 수 있습니다. 예를 들어 core.xml과 scheduler가 자식 프로젝트 인 assembly.xml의 일부를 볼 수 있습니다.

</fileSet> 
<fileSet> 
    <directory>./core/src/main/resources/</directory> 
    <outputDirectory>./examples</outputDirectory> 
    <includes> 
    <include>*</include> 
    </includes> 
</fileSet> 
<fileSet> 
    <directory>./scheduler/src/main/resources/</directory> 
    <outputDirectory>./examples</outputDirectory> 
    <includes> 
    <include>*</include> 
    </includes> 
</fileSet> 

기본적으로 자원 폴더 내용이 기본 프로젝트 예제 프로젝트에 복사됩니다.

모든 프로젝트가 동일한 vob에 있고 사용 가능한 경우 여기에서 동일한 작업을 수행 할 수 있습니다. 모든 리소스를 복사 할 상대 위치를 지정해야합니다. 예를 들어 : 기본 치어를 실행할 때

</fileSet> 
<fileSet> 
    <directory>../../../your_sub_project1/src/main/resources/</directory> 
    <outputDirectory>./examples</outputDirectory> 
    <includes> 
    <include>*</include> 
    </includes> 
</fileSet> 
<fileSet> 
    <directory>../../../your_sub_project2/src/main/resources/</directory> 
    <outputDirectory>./examples</outputDirectory> 
    <includes> 
    <include>*</include> 
    </includes> 
</fileSet> 

이 방법, 당신은 특정 폴더에 하위 프로젝트의 콘텐츠에 액세스하고 자원을 복사 할 수 있습니다. 희망이 ..

관련 문제