2016-07-05 3 views
0

내 Gradle 프로젝트에서 플랫 디렉터리와 Maven 리포지토리 (로컬 Nexus 서버)의 두 가지 유형의 리포지토리를 정의해야합니다.Gradle에서 두 개의 리포지토리 유형 결합/해결

둘 다 별도로 작동 할 수는 있지만 잘 연주 할 수는 없습니다. 이상적으로, Gradle은 먼저 Maven 저장소에서 로컬 디렉토리를 살펴볼 것입니다.

현재 나는이처럼 내 build.gradle에있는 저장소를 정의

설정하십시오 libs (및 test.libs) 디렉토리에서

repositories { 
    flatDir dirs: "${rootProject.projectDir}/libs" 
    flatDir dirs: "${rootProject.projectDir}/test.libs" 

    maven { 
     credentials { 
      username nexus_username 
      password nexus_password 
     } 
     url "http://nexus-server/nexus/content/groups/public" 
    } 
} 

, jar 파일 이름 또는 (버전이있을 수도 있고 없을 수도 있습니다 그러나 flatDir 저장소를 사용하는 경우에는 그 것이 부적절하다고 생각합니다.) :

libs\activation.jar 
libs\imap.jar 
.... 
libs\<closed_source_framework>.jar 
.... 
libs\gson-2.2.4.jar 
libs\stax-utils.jar 
..... 

로컬 Nexus 서버를 사용할 수없는 이유는 <closed_source_framework>.jar입니다. libs 폴더에있는 대부분의 의존성은 해당 배포 물과 함께 제공되며 Nexus에서 버전 정보를 가져올 수는 없습니다.

이제 내 build.gradle 내 종속성을 정의 된 다른 팀 중 하나가 넥서스 서버에 자신의 항아리를 게시하고 난 넥서스에서 자신의 항아리를 당길 수 있도록하고 싶습니다, 그래서 내가 (다시)가 :

dependencies { 

    // Grab other-team jar files from Nexus server 
    compile "other-team-group:other-team-jar-1:version" 
    compile "other-team-group:other-team-jar-2:version" 
    compile "other-team-group:other-team-jar-3:version" 

    // Grab everything else from 'flatDir' 
    compile name: 'activation' 
    compile name: 'imap' 
    ... 
    compile name: 'gson-2.2.4' 
    compile name: 'stax-utils' 
    ..... 

} 

문제

은 이제 내 문제를 온다. Gradle이 build.gradle에 지정된 순서대로 repositories을 검색 할 것으로 예상 했었습니다. 즉 로컬 libs 폴더를 찾은 다음 로컬에서 찾을 수없는 경우 Nexus로 이동한다는 의미입니다. 내가보고있는 것은 Gradle이 로컬 libs 폴더에있는 jar 파일의 Nexus 서버를 찾고 있다는 것입니다. 분명히 이것은 내 빌드 속도를 늦추고 있습니다 (~ 30 개의 종속성이 정의되어 있음).

일부 정보

출력 저장소 정보를 표시하려면 gradle properties 명령 :

..... 
// Successfully find the other team jar files in Nexus, this is okay 
Download http://nexus-server/nexus/content/groups/public/other-team-group/other-team-jar-1/version/other-team-jar-1-version.pom 
Download http://nexus-server/nexus/content/groups/public/other-team-group/other-team-jar-2/version/other-team-jar-2-version.pom 
Download http://nexus-server/nexus/content/groups/public/other-team-group/other-team-jar-3/version/other-team-jar-3-version.pom 
..... 
// Continues looking in Nexus for jar files that should be found in local libs folder 
Resource missing. [HTTP GET: http://nexus-server/nexus/content/groups/public//activation//activation-.pom] 
Resource missing. [HTTP HEAD: http://nexus-server/nexus/content/groups/public//activation//activation-.jar] 
Resource missing. [HTTP GET: http://nexus-server/nexus/content/groups/public///imap//imap-.pom] 
Resource missing. [HTTP HEAD: http://nexus-server/nexus/content/groups/public//imap//imap-.jar] 
..... 
: Gradle을 넥서스에 조회를하고있는 것을 보여주기 위해

..... 
repositories: [org.gradle.api.internal.ar[email protected]18814b1b, org.gradle.api.internal.[email protected]6dff028] 
..... 

출력 gradle --info compileJava에서를,

하단 내용

Gradle이 로컬에서만 찾을 수있는 jar 파일의 Maven 저장소를 보는 것을 멈추게하려면 어떻게해야합니까?

답변

1

또한이 질문은 Gradle forums에 게시했습니다. 아래에 솔루션을 복사/붙여 넣었습니다.


Gradle을이없는 유물 통해 POM/담쟁이 기술자와 이슈를 선호합니다.이것이 왜 gradle이 후에 flatDir 저장소에서 일치하는 것을 찾는 지 계속 찾는 이유라고 생각합니다. 이 문제는 문제를 해결할 수도 있고 해결하지 못할 수도 있지만 대신 ModuleDependency 대신 FileCollectionDependency을 사용할 수 있습니다.

예 :

ext { 
    libs = "${rootProject.projectDir}/libs" 
    testLibs = "${rootProject.projectDir}/test.libs" 
} 
dependencies { 
    compile files("${libs}/activation.jar", "${libs}/imap.jar") 
    compile files("${testLibs}/gson-2.2.4.jar") 
    ... 
} 
관련 문제