2014-02-05 40 views
3

我有一個android gradle構建,它在四個不同的服務器上查找依賴關係。如何加快我的gradle構建並忽略失敗的依賴查找?

現在構建需要花費兩分鐘的時間,因爲每個構建都會檢查這些依賴關係。 也許會發生這種情況,因爲其中一個存儲庫會爲大多數依賴項返回錯誤。

,我有以下來源的gradle我的文件:

repositories { 
    maven { url 'http://jenkins.local:8081/nexus/content/groups/public/' } 
    mavenCentral() 
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/'} 
    maven {url "https://repo.commonsware.com.s3.amazonaws.com"} 
} 

的第一項是第一次請求之後應該緩存所有文物的代理。 這是依賴列表中的一部分:

編譯「com.android.support:support-v4:19.+」

compile 'com.squareup.picasso:picasso:2.2.+' 
compile 'com.commonsware.cwac:merge:1.0.1' 
compile files('libs/crittercism_v4_3_0_sdkonly.jar') 
testCompile 'junit:junit:4.10' 
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' 
testCompile 'com.squareup:fest-android:1.0.+' 
testCompile 'org.mockito:mockito-all:1.9.5' 
instrumentTestCompile 'junit:junit:4.10' 
instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' 
instrumentTestCompile 'com.squareup:fest-android:1.0.+' 
instrumentTestCompile 'org.mockito:mockito-all:1.9.5' 

現在在運行gradle這個我得到下面的輸出(同樣的快照):

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/de/greenrobot/greendao/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/appcompat-v7/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/appcompat-v7/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/mediarouter-v7/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/mediarouter-v7/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/fasterxml/jackson/core/jackson-databind/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/fasterxml/jackson/core/jackson-databind/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/fasterxml/jackson/core/jackson-core/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/fasterxml/jackson/core/jackson-core/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/fasterxml/jackson/core/jackson-annotations/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/fasterxml/jackson/core/jackson-annotations/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/okhttp/okhttp/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/okhttp/okhttp/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/retrofit/retrofit/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/retrofit/retrofit/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/de/greenrobot/greendao/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/de/greenrobot/greendao/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/squareup/picasso/picasso/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/appcompat-v7/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/appcompat-v7/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/mediarouter-v7/maven-metadata.xml] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/mediarouter-v7/] 
Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://repo.commonsware.com.s3.amazonaws.com/com/android/support/support-v4/maven-metadata.xml] 

如何可以強制構建每天做這個查詢只有一次或跳過失敗上次查找或採取被發現的第一神器並跳過所有其他回購對於那些文物已經可用?

+1

」也許會發生這種情況,因爲其中一個存儲庫會爲大多數依賴項返回錯誤信息「 - 我的存儲庫已在Amazon S3上運行,因此您將得到403而不是404找不到的文件。這應該不會影響性能,但顯然它會影響詳細的日誌記錄(或從您的問題獲取日誌行的任何地方)。 – CommonsWare

+1

顯然它根本找不到一些依賴關係。它會在第一個包含匹配模塊的回購之後停止,並且它只會在24小時後嘗試重新解析快照和動態版本(這是默認設置)。 (PS:如果你有一個代理,通常最好是在那裏聲明所有的外部回購,而不是在構建腳本中。) –

+0

@PeterNiederwieser代理現在只能在其中一個辦公室工作,所以我們需要一種方法來避免在其他位置使用代理。 – Janusz

回答

1

這個故事的寓意:確保你的Maven存儲庫爲任何實際上不存在的東西返回404。

在Amazon S3上託管存儲庫的特定情況下,使用Amazon S3管理器爲「每個人」授予「列表」權限,或者按照this StackOverflow answer中的說明操作。 「

+1

這將是很好的強制gradle使某些文物只在某些回購修復這構建文件。對於回購所有者不那麼敏感的情況。再次感謝。 – Janusz

相關問題