2017-11-18 3 views
0

나는 coreclient을 포함하는 다중 모듈 gradle 프로젝트를 가지고 있습니다. client는 다음과 같이 선언 core에 따라 달라집니다다중 프로젝트 gradle 빌드에서 종속 버전 번호 변경

dependencies { 
    compile project(':core') 
} 

나는 아이비에 coreclient을 게시하거나 core-client에서 종속성을 받는다는 경우 현재 core (예를 들어, 1.0.0)에 대해 정의 된 정확한 버전을 사용합니다.

변경할 방법이 있습니까? core이 부 릴리스 사이의 호환이 보장된다고 가정 해 봅시다. 그래서 1.0.0 대신 종속성을 1.+으로 지정하고 싶습니다. 내가 도우미 함수를 생성 생성 된 pom.xml 파일의 버전을 대체하기 위해

+1

HTTPS를 : //docs.gradle.org/current/userguide/publishing_maven.html#sec : modifying_the_generated_pom –

+0

그런 다음 답을 주저하지 마십시오. –

+0

왜 여러 모듈간에 긴밀하게 결합되어 있는지 궁금합니다. – chenrui

답변

0

:

이 기능은 다음 버전 번호 대체하기 위해 출판 사용할 수 있습니다
// helper function to replace dependency version in maven pom.xml 
def replaceDependencyVersion(root, groupId, artifactId, version) { 
    // replace version 
    root.dependencies.dependency.findAll() { node -> 
     node.groupId.text() == groupId && node.artifactId.text() == artifactId 
    }.each() { node -> 
     node.version*.value = version 
    } 
} 

:

// publishing 
publishing { 
    publications { 
     mavenJava(MavenPublication) { 
      from components.java 

      pom.withXml { 
       replaceDependencyVersion(asNode(), 'com.test', 'core', '1.+') 
      } 
     } 
    } 
} 
관련 문제