2013-04-24 7 views
3

maven 다중 모듈 빌드로 이동 중입니다. 다음과 같이Eclipse와 Maven 다중 모듈 빌드

내 프로젝트 구조는 같습니다

MyProject 
|-->MyProject-Core 
| |->pom.xml (packaging jar) 
|-->MyProject-Assets 
| |->pom.xml (packaging jar) 
|-->MyProject-Libs 
| |->pom.xml (packaging jar) 
|-->pom.xml (packaging pom, aggregator) 

MyProject

는 메이븐 이클립스 프로젝트와 M2E에 의해 만들어집니다.

Eclipse 원본 폴더로 MyProject-Core/src/main/java를 추가했지만 부모 pom의 종속성 섹션을 dependencyManagement로 변경했기 때문에 Eclipse에서 빌드 오류가 발생했습니다. 수동으로 mvn package을 호출해도 정상적으로 작동합니다.

어떻게 핵심 pom의 종속성을 올바르게 해결할 수있는 Eclipse를 구성 할 수 있습니까?

여전히 부모 pom에 종속성을 scope : provide로 추가 할 수 있지만 이것이 최선의 해결책입니까?

학부모 응원단 :

<?xml version="1.0" encoding="UTF-8"?> 
<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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.example</groupId> 
    <artifactId>MyProject</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.16</version> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>findbugs-maven-plugin</artifactId> 
      <version>2.3.3</version> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.9</version> 
     </plugin> 
     <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence 
      on the Maven build itself. --> 
     <plugin> 
      <groupId>org.eclipse.m2e</groupId> 
      <artifactId>lifecycle-mapping</artifactId> 
      <version>1.0.0</version> 
      <configuration> 
      <lifecycleMappingMetadata> 
       <pluginExecutions> 
       <pluginExecution> 
        <pluginExecutionFilter> 
        <groupId> 
         org.codehaus.mojo 
        </groupId> 
        <artifactId> 
         exec-maven-plugin 
        </artifactId> 
        <versionRange> 
         [1.2,) 
        </versionRange> 
        <goals> 
         <goal>java</goal> 
        </goals> 
        </pluginExecutionFilter> 
        <action> 
        <ignore /> 
        </action> 
       </pluginExecution> 
       </pluginExecutions> 
      </lifecycleMappingMetadata> 
      </configuration> 
     </plugin> 
     </plugins> 
    </pluginManagement> 
    <plugins> 
     <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> 
      <encoding>UTF-8</encoding> 
     </configuration> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-jar-plugin</artifactId> 
     <version>2.3.1</version> 
     <configuration> 
      <archive> 
      <index>true</index> 
      <addMavenDescriptor>false</addMavenDescriptor> 
      <manifest> 
       <packageName>com.example</packageName> 
       <addDefaultImplementationEntries>true 
       </addDefaultImplementationEntries> 
       <addDefaultSpecificationEntries>true 
       </addDefaultSpecificationEntries> 
      </manifest> 
      <manifestEntries> 
       <SVN-Revision>${workingCopyDirectory.revision}</SVN-Revision> 
      </manifestEntries> 
      <compress>false</compress> 
      </archive> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
    <modules> 
    <module>MyProject-core</module> 
    </modules> 
</project> 

코어-응원단 :

<?xml version="1.0"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
    <groupId>com.example</groupId> 
    <artifactId>MyProject</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 
    <groupId>com.example</groupId> 
    <artifactId>MyProject-Core</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <dependencies> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
    </dependency> 
    </dependencies> 

    <build> 
    <sourceDirectory>src/main/java</sourceDirectory> 
    <testSourceDirectory>src/test/java</testSourceDirectory> 
    </build> 
</project> 
+0

예를 들어 pom (뿌리)과 코어의 pom을 게시하십시오. – khmarbaise

+0

좋아, 나는 poms의 단순화 된 버전을 추가했다. – Stephan

+0

프로젝트를 제거한 다음 다시 가져 오려고 했습니까? – cahen

답변

0

나는 구성을 많이 시도했지만 M2E는 하위 모듈에서 자신의 프로젝트 또는 변경으로 하위 모듈을 인식하지 못합니다했다 상위 모듈 프로젝트에서는 인식되지 않습니다.

이제 각 Maven 프로젝트마다 하나씩 여러 Eclipse 프로젝트를 만들었습니다.

+1

이 답변을 이해할 수 없습니다. 다중 프로젝트 빌드를 가져올 때 각 모듈에 대해 하나씩 여러 Eclipse 프로젝트를 이미 얻었습니다. –

+2

예, 맞습니다. 그러나 여러 Maven 프로젝트를 하나의 Eclipse 프로젝트로 사용하려고 시도했지만 작동하지 않습니다. Maven 프로젝트 당 하나의 Eclipse 프로젝트를 만들어야하는데 정상적으로 작동합니다. – Stephan

관련 문제