2016-05-24 72 views
0

我有這個庫我想用,我可以安裝一個版本,但是開發者發佈了最近的SNAPSHOT版本,我該如何編譯它?我試過compile 'com.(...):1.4.0-SNAPSHOT沒有結果?Gradle:編譯SNAPSHOT庫

回答

4

由於SNAPSHOT是一個Maven概念,因此它在存儲庫中不被視爲任何特殊的東西。

告訴Gradle檢查依賴項的更新版本的最好方法是將依賴項標記爲更改。然後Gradle會每24小時檢查一次更新,這可以使用分辨率策略 DSL進行配置。

覆蓋默認模塊中的緩存搖籃:

configurations.all { 
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds' 
} 

然後,latest.integration將與每個快照工作:

dependencies { 
    compile ('projGroup:projName:latest.integration') { changing = true } 
} 

例如,在你的情況,projGroupcom.prolificinteractiveprojName is material-calendarview

dependencies { 
    compile('com.prolificinteractive:material-calendarview:1.4.0-SNAPSHOT') { changing = true } 
} 

編輯:

另一個問題是,把上定義的中央庫的最新版本,這個倉庫實際上是不包含快照庫,其中-SNAPSHOT所在地。所以你應該在你的gradle repositories部分添加倉庫URL,以允許下載上傳的SNAPSHOT版本。

repositories { 
    mavenCentral() 
    mavenLocal() 
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } 
} 
+0

此'編譯 'projGroup:com.prolificinteractive:材料calendarview:1.3.0:latest.integration''給出了這樣的錯誤:'錯誤:(37,0)提供的字符串模塊符號' projGroup:COM。 prolificinteractive:material-calendarview:1.3.0:latest.integration'無效。示例符號:'org.gradle:gradle-core:2.2','org.mockito:mockito-core:1.9.5:javadoc'.' –

+0

使用'compile'c​​om.prolificinteractive:material-calendarview:latest.integration'' –

+0

它現在正在編譯,但仍不是最新版本,有些方法缺失 –