2014-07-24 1 views
1

게시하십시오. src/integTests 디렉토리에서 프로젝트에 대한 테스트를 작성 했으므로 이제 통합 테스트에서 생성 된 jar 파일 만 빌드하고 게시해야합니다. 내가 from components.java이있을 때 유물-ID에 지정된대로,이 이름을 가진 제품의 항아리를 게시, 위의에서종속성이있는 테스트 jar 파일을

apply plugin: 'java' 
apply plugin: 'maven-publish' 

sourceSets { 
    integTest { 
     java.srcDir file('src/integTest/java') 
     resources.srcDir file('src/integTest/resources') 
     compileClasspath += main.output + test.output 
     runtimeClasspath += main.output + test.output 
    } 
} 

configurations { 
    integTestCompile.extendsFrom testCompile 
    integTestRuntime.extendsFrom testRuntime 
} 
task integTestJar (type:Jar) { 
    from sourceSets.integTest.output 
     appendix = 'integ-tests' 
    } 
    publishing { 
     publications { 
      myPublicationName(MavenPublication) { 
       artifactId "client-security-internal-integ-tests" 
       from components.java 

      } 
     } 
     repositories { 
      maven { 
       url ="${artifactory_contextUrl}" 
       credentials { 
        username = "${artifactory_user}" 
        password = "${artifactory_password}" 
       } 
      } 
     } 
    } 

: 여기 내 코드입니다. 대신 artifact integTestJar.archivePath을 사용하면 올바른 jar를 게시하지만 pom 파일의 종속성 정보는 포함하지 않습니다. Could not find property 'integTest' on SoftwareComponentInternal set

이 어떻게 POM 파일에 포함 된 모든 종속성과 INTEG 테스트 항아리를 게시 할

나는 from components.integTest을 시도하지만 오류와 함께 실패?

답변

1

다음은 작동하는 해결책입니다!

 pom.withXml { 
      def dependencies = asNode().appendNode('dependencies') 
      configurations.integTestRuntime.getResolvedConfiguration().getFirstLevelModuleDependencies().each { 
       def dependency = dependencies.appendNode('dependency') 
       dependency.appendNode('groupId', it.moduleGroup) 
       dependency.appendNode('artifactId', it.moduleName) 
       dependency.appendNode('version', it.moduleVersion) 
      } 
     }