2015-02-24 12 views
0

我正在創建一個腳本插件來引用持有我的orgs gradle插件的ivy存儲庫。我的代碼現在的問題是:無法在腳本插件中引用gradle.properties

repository.gradle

repositories { 
    ivy { 
     credentials { 
      username = artifactory_user 
      password = artifactory_password 
     } 
     url 'https://ourUrl/artifactory/repoName' 
     layout "pattern", { 
      ivy '[organization]/[module]/[revision]/ivy-[revision].xml' 
      artifact '[organisation]/[module]/[revision]/[artifact]-[revision].[ext]' 
     } 
    } 
} 

然後,在文件的build.gradle,

的build.gradle

buildscript { 
    apply from: https://ourUrl/assets/repository.gradle, to: buildscript 
    dependencies { classpath group: 'ourGrp', name: 'artifactName', version: '1.0.0' } 
} 

在我的gradle產出.properties文件:

gradle.properties

artifactory_user=username 
artifactory_password=password 

該錯誤消息我收到的是:

What went wrong: 
A problem occurred evaluating script. 
Could not find property 'artifactory_user' on Credentials [username: null]. 

對我怎樣才能解決這個有什麼建議?如果可能,我想避免對build.gradle文件造成任何進一步的影響。

+1

能不能請你參考'artifactory_user'用'項目。 artifactory_user'? – Opal 2015-02-24 17:17:15

+0

** gradle.properties **文件位於我的Gradle用戶主目錄中,而不是項目主目錄。我已經確認,gradle用戶主頁正在使用--info在構建中正確拾取。 – JimmyMac 2015-02-24 17:28:20

+0

好的,只是試圖改變,我得到的消息: 無法找到屬性'項目'憑證[用戶名:空]。 – JimmyMac 2015-02-24 17:31:51

回答

1

This exact question was asked in the gradle forums。我會粘貼工作的解決方法,所以它不會得到重新鏈接什麼的過程中丟失:

repository.gradle:

repositories { 
    ivy { 
     credentials { 
      username = artifactory_user 
      password = artifactory_password 
     } 
     url 'https://ourUrl/artifactory/repoName' 
     layout "pattern", { 
      ivy '[organization]/[module]/[revision]/ivy-[revision].xml' 
      artifact '[organisation]/[module]/[revision]/[artifact]-[revision].[ext]' 
     } 
    } 
} 
ext.extRepo = repositories 

build.gradle:

buildscript {scriptHandler-> 
    apply from: 'https://ourUrl/assets/repository.gradle' 
    repositories.addAll(extRepo)