2017-02-02 1 views
0

몇 가지 종속성에 따라 로컬 artifactory에 의존하는 프로젝트가 있습니다. Gradle을이 프로젝트에 구축Gradle : 다중 프로젝트 구조로 이동 - 저장소를 확인할 수 없습니다.

는 저장소에 적절한 설정으로, 잘 작동 :

buildscript { 
    repositories { 
     maven { 
      url "${artifactoryUrl}/libs-release" 
     } 
    } 
    dependencies { 
     classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10' 
    } 
} 

repositories { 
    maven { 
     url "${artifactoryUrl}/repo" 
    } 
} 

artifactory { 
    contextUrl = "${artifactoryUrl}" 
    publish { 
     repository { 
      repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to 
      username = "${artifactoryUser}" // The publisher user name 
      password = "${artifactoryPassword}" // The publisher password 
     } 
     defaults { 
      // Reference to Gradle publications defined in the build script. 
      // This is how we tell the Artifactory Plugin which artifacts should be 
      // published to Artifactory. 
      publications('mavenJava') 
      publishArtifacts = true 
      // Properties to be attached to the published artifacts. 
      properties = ['qa.level': 'basic', 'dev.team' : 'core'] 
     } 
    } 
    resolve { 
     repoKey = 'repo' 
    } 
} 

나는 멀티 프로젝트 구조에 Gradle을 튜토리얼을 따라 갔다. "저장소"섹션을 루트 gradle.build 파일로 이동할 수있는 것 같습니다. 내가 artifactory에서 모든 종속성에 Gradle을 내가 갖는 빌드 및 오류를 실행할 때, :

외부 의존성을

주를 확인할 수 없습니다 : 나는 또한 포함하는 루트 디렉토리에있는 gradle.properties 파일을 추가 모든 변수 (artifactoryUrl 등).

그래서 서브 프로젝트는 루트 gradle.build 파일에 정의 된 저장소를 "볼"수없는 것으로 보입니다. 어떤 제안?

UPDATE 루트 디렉토리에 내 build.gradle

이 지금과 같습니다

allprojects { 
} 

subprojects { 
    buildscript { 
     repositories { 
      maven { 
       url "${artifactoryUrl}/libs-release" 
      } 
     } 
     dependencies { 
      classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10' 
     } 
    } 

    repositories { 
     maven { 
      url "${artifactoryUrl}/repo" 
     } 
    } 

    artifactory { 
     contextUrl = "${artifactoryUrl}" 
     publish { 
      repository { 
       repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to 
       username = "${artifactoryUser}" // The publisher user name 
       password = "${artifactoryPassword}" // The publisher password 
      } 
      defaults { 
       // Reference to Gradle publications defined in the build script. 
       // This is how we tell the Artifactory Plugin which artifacts should be 
       // published to Artifactory. 
       publications('mavenJava') 
       publishArtifacts = true 
       // Properties to be attached to the published artifacts. 
       properties = ['qa.level': 'basic', 'dev.team' : 'core'] 
      } 
     } 
     resolve { 
      repoKey = 'repo' 
     } 
    } 
} 
+0

'-i' 또는'-d' 플래그를 사용하여 실행하면 어떤 이점이 있습니까? 어딘가에 리드가 있어야합니다. –

+0

'id '와 관련된 메시지 만 "설정 파일의 로컬 저장소가 없습니다. 기본 경로 사용 : /home/elad/.m2/repository" –

+0

'apply plugin :'이 없습니다. 업데이트 된 답변 –

답변

0

당신은 subprojects 또는 allprojects 블록에서 repository (및 artifactory) 블록 (들)을 넣어해야합니다. 예를 들면 :

subprojects { 
    repositories { 
    maven { 
     url "${artifactoryUrl}/repo" 
    } 
    } 
    ... 
} 

이 구성이 사용자의 하위 프로젝트의 모든 구성에 루트 build.gradle에 의해 아래로 밀려되어 있는지 확인합니다. artifactory에 대한 또한

모든 하위 프로젝트에 artifactory 플러그인을 적용하는 것을 잊지 마세요 :

subprojects { 
    apply plugin: "com.jfrog.artifactory" 

    ... 
} 
+0

나는 해냈다. 질문을 풀 루트 build.gradle 파일로 업데이트했습니다. 검토하시기 바랍니다. –

+0

플러그인을 추가 한 것과 같은 결과 ... –

0

그래서 몇 가지 예를보고 후, 나는 buildscript 섹션은 subprojects 섹션 외부해야한다는 실현, 그리고 내부. 서브 프로젝트 섹션에도 apply plugin: 'com.jfrog.artifactory'을 추가해야합니다.

buildscript { 
    repositories { 
     maven { 
      url "${artifactoryUrl}/libs-release" 
     } 
    } 
    dependencies { 
     classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10' 
    } 
} 

subprojects { 
    repositories { 
     maven { 
      url "${artifactoryUrl}/repo" 
     } 
    } 

    artifactory { 
     contextUrl = "${artifactoryUrl}" 
     publish { 
      repository { 
       repoKey = 'libs-snapshot-local' // The Artifactory repository key to publish to 
       username = "${artifactoryUser}" // The publisher user name 
       password = "${artifactoryPassword}" // The publisher password 
      } 
     defaults { 
       // Reference to Gradle publications defined in the build script. 
       // This is how we tell the Artifactory Plugin which artifacts should be 
       // published to Artifactory. 
       publications('mavenJava') 
       publishArtifacts = true 
       // Properties to be attached to the published artifacts. 
       properties = ['qa.level': 'basic', 'dev.team' : 'core'] 
      } 
     } 
     resolve { 
      repoKey = 'repo' 
     } 
    } 
} 
관련 문제