문제

나는 Maven2가 저와 협력하기 위해 고군분투하고 있었고, 누군가 가이 일을하는 방법에 대한 아이디어가 있는지 궁금해하고있었습니다 .... 나는 플래시 프로젝트에서 일하고 있으며, 우리는 하이브리드 Flex4/에서 전환하는 것을 고려하고 있습니다. Flashcs4에 순수한 Flex4 용액에. Maven2 빌드 시스템을 사용하여 개발자가 시스템에서 Flex4를 수동으로 다운로드, 설치 및 구성 할 필요가 없습니다.

Flex4를 사용하여 Maven2를 사용하여 단일 모듈 프로젝트를 만들었습니다 (Sonatype Flexmojos 플러그인과 Maven2 저장소를 사용하고 있습니다. http://repository.sonatype.org/content/groups/flexgroup/). 이 멀티 모듈을 만드는 데있어 정말로 문제가 발생하기 시작합니다 ....

우리 프로젝트는 다음과 같이 구성됩니다.

 |- bin
 |  |- moduleX.swf
 |  |- moduleY.swf
 |  |- ...
 |- lib
 |  |- moduleA.swc
 |  |- moduleB.swc
 |  |- ...
 |- src
 |  |- moduleA
 |  |- moduleB
 |  |- ...
 |- test
 |  |- moduleA
 |  |- moduleB
 |  |- ...
 |- share
 |  |- asset1
 |  |- asset2
 |  |- ...
 |- ...

기본적으로 각 모듈에는 "SRC/에 소스가 있습니다.u003Cmodulename> /"테스트 소스"테스트/u003Cmodulename> /", 생성 된 SWF 파일이"bin "에 배치되고"lib "에 SWC 파일이 배치되어 있습니다. 우리의 자산 ("@embed "또는[embed] 태그를 사용하여 참조 할 수있는 것들. ) "공유"아래에 살고 있습니다. 프로젝트 상속 및 집계에 대한 참조를 살펴 보았지만 기존 프로젝트 디렉토리 구조를 유지할 수있는 것을 찾을 수없는 것 같습니다. , 그리고 가능한 한, 그리고 가능한 한, 비 끊임없는. 누군가가 우리의 현재 인프라를 유지할 수있는 "pom.xml"파일을 만드는 방법을 알아낼 수 있다면 정말 감사하겠습니다.

도움이 되었습니까?

해결책

Maven 2로 이동하는 것이 확실하다면, 프로젝트 구조를 수정하기 위해 많은 고통을 절약 할 수 있으므로 각 모듈에는 자체 소스와 테스트가 포함되어 있으며 Maven 컨벤션을 따릅니다.

실제로 그렇게 할 수 없다면 병렬 모듈 계층을 만들고 기존 구조로 돌아가는 상대 경로로 각 모듈을 구성 할 수 있습니다. 구조는 다음과 같은 것을 보게 될 수 있습니다.

|- Maven Root
|   |- pom.xml
|   |- ModuleA 
|   |  |- pom.xml
|   |- ModuleB
|   |  |- pom.xml
|   |- ModuleX
|   |  |- pom.xml
|   |- ModuleY
|   |  |- pom.xml
|   |- asset1
|   |  |- pom.xml
|   |-...
|
|- Existing-Root
    |- bin
    |  |- moduleX.swf
    |  |- moduleY.swf
    |  |- ...
    |- lib
    |  |- moduleA.swc
    |  |- moduleB.swc
    |  |- ...
    |- src
    |  |- moduleA
    |  |- moduleB
    |-...

관련 세트를 구축 할 수 있도록 임시 폼을 추가 할 수도 있습니다 (예 : share 모든 공유 모듈을 포함하는 POM).

당신은 다음과 같이 할 수 있습니다 :

  • 적절한 상대 경로로 각 POM을 구성하여 소스를 구축 할 수 있습니다.
  • Maven-Dependency-Plugin을 포장 풀도록 구성하십시오 Embed 목표/Flex/Resources 로의 리소스
  • 사용 빌드 헬퍼-매번-플러그 인 Target/Flex/Resources를 리소스 위치로 설정하려면 (참고 플러그인이 임베드 리소스가 SRC/Main/Resources에있을 것으로 기대하기 때문에 실제로 작동하지 않을 수 있음).
  • 모듈간에 적절한 종속성을 정의하십시오.
  • 사용 Maven-Antrun-Plugin 최종 아티팩트를 기존 빈 디렉토리에 복사하려면 (Project.Build.OutPutDirectory를 설정하여 동일한 출력 디렉토리를 사용하려고 시도하지만 하나의 모듈을 청소하면 다른 빌드가 클로브됩니다).

다음은 POMS 중 하나에 대한 단계를 달성하기위한 예제 구성입니다.

<build>
  <!--configure the source and test sources to point to the existing structure-->
  <sourceDirectory>
    ${baseDir}/../../Existing-Root/test/${project.artifactId}
  </sourceDirectory>
  <testSourceDirectory>
    ${baseDir}/../../Existing-Root/src/${project.artifactId}
  </testSourceDirectory>
  <plugins>
    <plugin>
     <groupId>org.sonatype.flexmojos</groupId>
     <artifactId>flexmojos-maven-plugin</artifactId>
     <version>3.2.0</version>
     <extensions>true</extensions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack</id>
          <phase>generate-resources</phase>
          <goals>
            <goal>unpack</goal>
          </goals>
          <configuration>
            <artifactItems>
              <!--unpack asset1 to target/flex/resources, 
                define any additional artifacts for other shares-->
              <artifactItem>
                <groupId>my.group.id</groupId>
                <artifactId>asset1</artifactId>
                <version>1.0.0</version>
                <type>swf</type>
              </artifactItem>
            </artifactItems>
            <outputDirectory>
              ${project.build.directory}/flex/resources
            </outputDirectory>
            <overWriteReleases>false</overWriteReleases>
            <overWriteSnapshots>true</overWriteSnapshots>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <!--add target/flex/resources as a resource location-->
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.3</version>
      <executions>
        <execution>
          <id>add-resource</id>
          <phase>generate-resources</phase>
          <goals>
            <goal>add-resources</goal>
          </goals>
          <configuration>
            <resources>
              <resource>
                <directory>
                  ${project.build.directory}/flex/resources
                </directory>
              </resource>
            </resources>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <execution>
          <phase>pre-integration-test</phase>
          <configuration>
            <tasks>
              <!--copy the final artifact to the module's bin directory-->
              <copy 
                file="${project.artifactId}-${project.version}.${project.packaging}"
                todir="${baseDir}/../../Existing-Root/bin/${project.artifactId}"/>
            </tasks>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
  ...
 </build>

다른 팁

멀티 모듈 프로젝트는 다음과 같아야합니다

Root
 |- Module a
 |  |- src
 |- Module b
 |  |- src
 |- Module c
 |  |- src

단일 아티팩트를 구축 할 계획이라면 단일 프로젝트에 여러 소스를 갖는 것은 괜찮지 만 단일 프로젝트에서 여러 소스에서 여러 아티팩트를 구축하려는 경우 Maven이 협력하지 않습니다.

소스 트리를 움직일 수 없다면; 현재 구조에서 다중 모듈 POM 계층 구조를 만들고 새 어린이 폴트를 편집하여 SRC 및 테스트 디렉토리를 현재 소스 계층 SRC 및 테스트 디렉토리에 가리키십시오.

출력 폴더가 모두 동일한 폴더를 가리킬 수 있습니다.

root
 |- ModuleA
 |  |- pom.xml, src points to root/src/moduleA
 |- ModuleB
 |  |- pom.xml, src points to root/src/moduleB
 |- src
 |  |- moduleA
 |  |- moduleB
 |  |- ...
 |- test
 |  |- moduleA
 |  |- moduleB
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top