2012-07-20 1 views
1

Maven + m2eclipse와 함께 SpringSource Tool Suite (STS)를 사용합니다. 최신 프로젝트에서 SVN에서 STS로 정확하게 기존 Maven 프로젝트를 가져 오는 문제에 직면하고 있습니다. 내가 import -> Maven -> 'existing Maven project'를 사용하는 경우, 프로젝트가 가져옵니다하지만 다음과 같은 문제가됩니다왜 STS/m2eclipse가 내 Maven 종속성을 추적하지 않습니까?

  • src/main/javasrc/test/java 소스 폴더로 포착되지 않습니다. STS는 src을 원본 폴더로 구성하고 main/test가 패키지 이름에 추가됩니다.
  • Maven 종속성 라이브러리가 Java 빌드 경로에 추가되지 않습니다.

나는 수동으로 소스 폴더를 수정할 수 있지만 추가하려고 할 때 나는 '메이븐 의존성 해상도를 구성하는 Maven을 사용하여 프로젝트 설정'는 메시지가 빌드 경로에 라이브러리 'Maven은 의존성 관리'를하고 라이브러리입니다 추가되지 않았습니다. 내가 설정할 수있는 유일한 Maven 프로젝트 설정은 활성 프로파일과 '작업 공간 프로젝트의 종속성 해결'(확인 됨)이며, 어느 것도 차이가없는 것으로 보입니다. 내가 명령 줄에서 mvn install을 실행하면

Add Maven Managed Dependencies Maven Project Settings

프로젝트를 성공적으로 구축합니다. mvn eclipse:eclipse을 실행 한 후 STS로 가져 오면 예상대로 작동하지만, pom을 업데이트 할 때마다이 작업을 다시 실행해야합니다. 이는 바람직하지 않습니다.

나는 mvn eclipse:eclipse를 실행 한 후 수동으로 M2_REPO 의존성이 eclipse:eclipse 추가 제거 .classpath를 업데이트하고 m2eclipse에 종속 항목을 추가하여 해결할 :

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> 
    <attributes> 
    <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> 
    </attributes> 
</classpathentry> 

그럼 난 기존 수입 Maven 프로젝트를 예상대로 일했다 . 그러나 이것은 해킹이며 m2eclipse로 작업 할 때 eclipse:ecplise이 실행되는 다른 결과가 무엇인지 확신 할 수 없습니다.

다른 maven 프로젝트에서 작업했으며 제대로 가져 오는 데 문제가 없었습니다.

아마 관련 정보 :

  • 이것은 웹 애플리케이션 프로젝트입니다.
  • subversion repo에는 pom.xmlsrc 폴더 만 포함됩니다.
  • 외부 메이븐 설치를 사용하며 버전 3.0입니다.다음 Maven 프로젝트를
  • 가져 오기 프로젝트를 기존의 가져 오기를 사용하여 STS에 가져

    • 다운로드 SVN에서 로컬 디스크 :
    • 3 우리는 내가 시도 것들 유물 다운로드

    에 대한 현장 Artifactory의 REPO를 사용 SVN에서 STS로 설정 -> Maven 속성 사용

  • 실행 mvn eclipse:eclipse 다음 가져 오기 (작동하지만 m2e에 대한 수동 클래스 경로 편집 필요)
  • Search stackoverflow, this question은 매우 비슷하지만 답변이 내 문제를 해결하지 못하는 것 같습니다.

의 pom.xml :

  1. 가 m2eclipse에 가져 오기가 제대로 작동하도록 :

    <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.company.group</groupId> 
        <artifactId>artifact</artifactId> 
        <version>1.0.1-SNAPSHOT</version> 
        <packaging>war</packaging> 
        <name>My Project</name> 
        <description>My Project</description> 
    
        <properties> 
         <java-version>1.6</java-version> 
         <org.springframework-version>3.1.0.RELEASE</org.springframework-version> 
         <!-- Lots of other versions omitted --> 
        </properties> 
    
        <repositories> 
         <repository> 
          <id>repoId</id> 
          <name>repoName</name> 
          <url>http://fake.company.com/artifactory/repo</url> 
          <layout>default</layout> 
         </repository> 
        </repositories> 
    
        <pluginRepositories> 
         <pluginRepository> 
          <id>repoId</id> 
          <name>repoName</name> 
          <url>http://fake.company.com/artifactory/repo</url> 
         </pluginRepository> 
        </pluginRepositories> 
    
        <!-- Configurations required for deploy plugin. Artifacts are deployed to 
         artifactory --> 
        <distributionManagement> 
         <repository> 
          <id>repoId</id> 
          <name>repoName-releases</name> 
          <url>http://fake.company.com/artifactory/apps-releases-local</url> 
         </repository> 
         <snapshotRepository> 
          <id>repoId</id> 
          <name>repoName-snapshots</name> 
          <url>http://fake.company.com/artifactory/apps-snapshots-local</url> 
         </snapshotRepository> 
        </distributionManagement> 
    
        <scm> 
         <connection>scm:svn:https://fake.company.com/svn/fake-repo/trunk</connection> 
         <developerConnection>scm:svn:https://fake.company.com/svn/fake-repo/trunk</developerConnection> 
         <url>https://fake.company.com/svn/fake-repo/trunk</url> 
        </scm> 
    
        <dependencies> 
         <dependency> 
          <groupId>org.springframework</groupId> 
          <artifactId>spring-web</artifactId> 
          <version>${org.springframework-version}</version> 
         </dependency> 
         <!-- Lots of other dependencies omitted --> 
        </dependencies> 
        <build> 
         <plugins> 
          <plugin> 
           <groupId>org.apache.maven.plugins</groupId> 
           <artifactId>maven-surefire-plugin</artifactId> 
           <configuration> 
            <excludes> 
             <exclude>**/TestUtil.java</exclude> 
            </excludes> 
           </configuration> 
          </plugin> 
          <plugin> 
           <groupId>org.apache.maven.plugins</groupId> 
           <artifactId>maven-compiler-plugin</artifactId> 
           <version>2.3.2</version> 
           <configuration> 
            <verbose>true</verbose> 
            <source>${java-version}</source> 
            <target>${java-version}</target> 
            <compilerVersion>${java-version}</compilerVersion> 
           </configuration> 
          </plugin> 
          <plugin> 
           <groupId>org.apache.maven.plugins</groupId> 
           <artifactId>maven-war-plugin</artifactId> 
           <configuration> 
            <warName>war-name</warName> 
           </configuration> 
          </plugin> 
          <plugin> 
           <groupId>org.apache.maven.plugins</groupId> 
           <artifactId>maven-dependency-plugin</artifactId> 
           <executions> 
            <execution> 
             <id>install</id> 
             <phase>install</phase> 
             <goals> 
              <goal>sources</goal> 
             </goals> 
            </execution> 
           </executions> 
          </plugin> 
          <plugin> 
           <groupId>org.codehaus.mojo</groupId> 
           <artifactId>cobertura-maven-plugin</artifactId> 
           <version>2.5.1</version> 
           <configuration> 
            <formats> 
             <format>html</format> 
            </formats> 
            <instrumentation> 
             <ignores> 
              <ignore>path/**/*Test.class</ignore> 
             </ignores> 
             <excludes> 
              <exclude>path/Constants.class</exclude> 
              <exclude>path/*.class</exclude> 
             </excludes> 
            </instrumentation> 
            <check> 
             <haltOnFailure>false</haltOnFailure> 
             <totalBranchRate>25</totalBranchRate> 
             <totalLineRate>41</totalLineRate> 
             <packageLineRate>25</packageLineRate> 
             <packageBranchRate>15</packageBranchRate> 
            </check> 
           </configuration> 
           <executions> 
            <execution> 
             <phase>package</phase> 
             <goals> 
              <goal>cobertura</goal> 
              <goal>check</goal> 
             </goals> 
            </execution> 
           </executions> 
          </plugin> 
          <plugin> 
           <groupId>org.apache.cxf</groupId> 
           <artifactId>cxf-codegen-plugin</artifactId> 
           <version>${org.apache.cxf-version}</version> 
           <executions> 
            <execution> 
             <id>generate-sources</id> 
             <phase>generate-sources</phase> 
             <configuration> 
              <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> 
              <wsdlOptions> 
               <wsdlOption> 
                <wsdl>${basedir}/src/main/resources/wsdl/automation.wsdl</wsdl> 
               </wsdlOption> 
              </wsdlOptions> 
             </configuration> 
             <goals> 
              <goal>wsdl2java</goal> 
             </goals> 
            </execution> 
           </executions> 
          </plugin> 
          <plugin> 
           <groupId>org.codehaus.mojo</groupId> 
           <artifactId>build-helper-maven-plugin</artifactId> 
           <version>1.7</version> 
           <executions> 
            <execution> 
             <phase>generate-sources</phase> 
             <goals> 
              <goal>add-source</goal> 
             </goals> 
             <configuration> 
              <sources> 
               <source>target/generated/cxf</source> 
              </sources> 
             </configuration> 
            </execution> 
           </executions> 
          </plugin> 
          <plugin> 
           <groupId>org.apache.maven.plugins</groupId> 
           <artifactId>maven-eclipse-plugin</artifactId> 
           <version>2.9</version> 
           <configuration> 
            <additionalProjectnatures> 
             <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
             <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> 
            </additionalProjectnatures> 
            <additionalBuildcommands> 
             <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
            </additionalBuildcommands> 
           </configuration> 
          </plugin> 
         </plugins> 
         <pluginManagement> 
          <plugins> 
           <!--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.apache.cxf</groupId> 
                 <artifactId> 
                  cxf-codegen-plugin 
                 </artifactId> 
                 <versionRange> 
                  [${org.apache.cxf-version},) 
                 </versionRange> 
                 <goals> 
                  <goal>wsdl2java</goal> 
                 </goals> 
                </pluginExecutionFilter> 
                <action> 
                 <ignore /> 
                </action> 
               </pluginExecution> 
               <pluginExecution> 
                <pluginExecutionFilter> 
                 <groupId>org.apache.maven.plugins</groupId> 
                 <artifactId>maven-compiler-plugin</artifactId> 
                 <versionRange>[2.3.2,)</versionRange> 
                 <goals> 
                  <goal>compile</goal> 
                  <goal>testCompile</goal> 
                 </goals> 
                </pluginExecutionFilter> 
                <action> 
                 <ignore /> 
                </action> 
               </pluginExecution> 
              </pluginExecutions> 
             </lifecycleMappingMetadata> 
            </configuration> 
           </plugin> 
          </plugins> 
         </pluginManagement> 
        </build> 
        <profiles> 
         <!-- Deployment profiles omitted --> 
        </profiles> 
    </project> 
    

    사람이하는 방법에 대한 아이디어가 있습니까? OR

  2. 프로젝트 생성/변환 후 빌드 경로에 관리 대상 종속성을 추가 할 수 있도록 STS를 구성 하시겠습니까?

답변

1

다음 절 :

      <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId>org.apache.maven.plugins</groupId> 
            <artifactId>maven-compiler-plugin</artifactId> 
            <versionRange>[2.3.2,)</versionRange> 
            <goals> 
             <goal>compile</goal> 
             <goal>testCompile</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <ignore /> 
           </action> 
          </pluginExecution> 

은 빌드에서 자바 컴파일러를 사용하지 불행한 결과가있다. 그것을 제거하면 나는 그 것들이 효과가 있다고 상상할 것입니다.

나는이를 참조하십시오

    <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> 

이는 끝내 프로젝트인가? 그렇다면 gmaven이나 groovy-eclipse-compiler를 사용하고 있습니까?

+0

프로젝트에는 그루비 코드가 있지만 주로 자바입니다. groovy-eclipse-compiler를 사용하고 있습니다. – Marquee

+0

나는 pom 빌드 플러그인 섹션에서 볼 수 있지만 다른 컴파일러에 대한 참조는 볼 수 없을 것으로 예상됩니다. (이것은 원래의 질문 범위를 벗어나므로 중요하지 않을 수 있습니다.) –

+0

마침내 오늘 이것을 시험해 볼 수있는 기회가 있었고, 당신은 정확하게 맞습니다. pom에서 해당 부분을 제거하면 원하는대로 가져올 수있었습니다. 감사!! – Marquee

0

저는 지금이 문제를 몇 번이나 해답을 Andrew의 대답의 정신에 나타낼 것입니다 : maven이 수락하지만 m2eclipse barfs가있는 pom의 일부 섹션이 있습니다.

그래서 프로젝트를 성공적으로 만들 수있을 때까지 1의 부분을 제거하는 것이 좋습니다. 각 pom 편집이 끝날 때까지 maven -> update configuration을 계속 실행하십시오. 대부분의 경우 의심스럽고 (즉, 가장 복잡한) 시작하여 한 번에 하나씩 플러그인 구성 태그 블록을 제거하는 것으로 시작합니다.

일단 심복을하면 되돌릴 수 있고 예상대로 작동해야합니다.

실행 한 후에 문제가되는 구성을 조사하여 '적절한'수정 사항 (m2eclipse에 따라, 어쨌든)을 파악하려고합니다.

임시 해결책은 일시적으로 작동하지만 부작용은 전혀 발견하지 못했습니다.하지만이 솔루션은 해킹을 덜 느끼며 영구적으로 문제를 격리하고 해결하는 데 도움이됩니다.

관련 문제