2017-01-09 39 views
0

我想爲我的模塊的.aar文件定義gradle依賴關係,該文件已經上傳到nexus存儲庫中。現在我正在試圖爲我的android應用程序的gradle文件聲明相同的.aar文件的依賴關係,但無法從Nexus存儲庫中獲取.aar文件。如何將Nexus存儲庫文件讀取到Android應用程序中

我使用下面的Android應用的build.gradle文件中的條目:

buildscript { 
    repositories { 
     jcenter() 
     maven { 
      url 'https://MY_COMPANY_DOMAIN/nexus/content/repositories/MY_PROJECT-Releases/' 
     } 
    } 
} 

dependencies { 
    compile 'GROUP_NAME:FILE_NAME:VERSION_NUMBER' 
} 

建設我的項目後,我收到以下錯誤:

"Error:Could not find GROUP_NAME:FILE_NAME:VERSION_NUMBER. 
Required by: 
    PROJECT_NAME:app:unspecified 
<a>Search in build.gradle files</a>" 

注:在我的情況的Nexus庫是安全的,我們需要使用憑據來訪問該回購。我想,我們需要在gradle文件中的某處指定身份驗證數據。 請給我建議,我們如何定義gradle中的認證部分來從Nexus倉庫中獲取.aar/.jar文件。

謝謝, Sumeet。

回答

1

您需要添加身份驗證信息才能正確同步。創建~/.gradle/gradle.properties文件,如果不存在的話,並添加像這樣的憑據:

nexusUrl=mycompanydomain 
nexusUsername=myusername 
nexusPassword=mypassword 

然後將這些憑據你的資料庫declataration:

repositories { 
    maven { 
     url nexusUrl + 'nexus/content/repositories/MY_PROJECT-Releases/' 
     credentials(PasswordCredentials) { 
      username nexusUsername 
      password nexusPassword 
     } 
    } 
} 
+1

感謝ditn,您的寶貴迴應。 – sumeet

相關問題