2012-03-12 5 views
1

나는 프로젝트 종속성 관리자로 gradle을 사용하고 있지만 netbeans를 더 좋아하고 maven과의 기본 통합을 찾을 수 없기 때문에 pom.xml로 gradle에 의해 생성 된 기본 pom을 복사합니다. 하지만 어떻게 소스와 타겟 레벨을 설정합니까?컴파일러 레벨 설정 gradle 생성을 위해

내 build.gradle 내가

gradle install 

를 실행하고 디폴트로 소스 나 목표 수준을 구성하지 빌드/리딩/치어-default.xml에를 확인 후

apply plugin: 'eclipse' 
apply plugin: 'maven' 
apply plugin: 'java' 

targetCompatibility=1.6 
sourceCompatibility=1.6 

처럼 보인다 ~ 1.3

내가 부족한 것은 maven 컴파일러 플러그인 구성입니다.

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <encoding>UTF-8</encoding> 
      </configuration> 
     </plugin> 

및 pom의 특정 부분을 구성하는 방법을 찾을 수 없었습니다. 라이센스, 개발자 등을 구성하는 모든 예제를 찾았지만 특정 플러그인은 찾지 못했습니다.

답변

1

"라이센스 및 개발자 용"의 예제와 동일한 방식으로 섹션을 추가 할 수 있습니다.

+0

자식 허브를 확인하지 않고는 말한다 : 클래스 _SCRIPT_CLASS_NAME_을 : org.apache.maven.model.Model'을 내가 프로젝트'에'build.plugins.plugin'를 추가 할 때 '. – BigDong

2

은 알아 내기 위해 잠시 시간이 걸렸습니다. 위에서 말한 베드로처럼 그 부분을 추가 할 수 있습니다. 적어도 나보다 더 쉽게했다.

다행히도 봄은 gradle을 사용하므로 실제로 많은 예제가 있습니다. >`그런 속성을 내가 시도

install { 
    repositories.mavenInstaller { 
     customizePom(pom, project) 
    } 
} 

def customizePom(pom, gradleProject) { 
    pom.whenConfigured { generatedPom -> 
     // respect 'optional' and 'provided' dependencies 
     gradleProject.optionalDeps.each { dep -> 
      generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true 
     } 
     gradleProject.providedDeps.each { dep -> 
      generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided' 
     } 

     // eliminate test-scoped dependencies (no need in maven central poms) 
     generatedPom.dependencies.removeAll { dep -> 
      dep.scope == 'test' 
     } 

     // add all items necessary for maven central publication 
     generatedPom.project { 
      name = gradleProject.description 
      description = gradleProject.description 
      organization { 
       name = 'bajoneando' 
      } 
      build { 
       plugins { 
        plugin { 
         groupId = 'org.apache.maven.plugins' 
         artifactId = 'maven-compiler-plugin' 
         configuration { 
          source = '1.6' 
          target = '1.6' 
         } 
        } 
        plugin { 
         groupId = 'org.apache.maven.plugins' 
         artifactId = 'maven-surefire-plugin' 
         configuration { 
          includes { 
           include = '**/*Tests.java' 
          } 
          excludes { 
           exclude = '**/*Abstract*.java' 
          } 
         } 
        } 
       } 
       resources { 
        resource { 
         directory = 'src/main/java' 
         includes = ['**/*'] 
         excludes = ['**/*.java'] 
        } 
        resource { 
         directory = 'src/main/resources' 
         includes = ['**/*'] 
        } 
       } 
       testResources { 
        testResource { 
         directory = 'src/test/java' 
         includes = ['**/*'] 
         excludes = ['**/*.java'] 
        } 
        testResource { 
         directory = 'src/test/resources' 
         includes = ['**/*'] 
        } 
       } 
      } 
      developers { 
       developer { 
        id = 'lnramirez' 
        name = 'Luis Ramirez Monterosa' 
        email = '*****@gmail.com' 
       } 
      } 
     } 
    } 
} 
관련 문제