2015-11-06 162 views
2

我在這裏做錯了什麼?最終目標是從URL下載* .properties。Gradle - 不能實例化常春藤類

【我知道解析器是不需要的,只是試着看看是否有類名問題。 ]

錯誤:

build file '/home/awm/t/build.gradle': 13: unable to resolve class org.apache.ivy.plugins.resolver.URLResolver 
    @ line 13, column 20. 
     def resolver = new org.apache.ivy.plugins.resolver.URLResolver() 
         ^

    build file '/home/awm/t/build.gradle': 14: unable to resolve class org.apache.ivy.util.url.ApacheURLLister 
    @ line 14, column 21. 
     def urlLister = new org.apache.ivy.util.url.ApacheURLLister() 
         ^

代碼:

plugins { 
    id "de.undercouch.download" version "2.0.0" 
} 

import de.undercouch.gradle.tasks.download.Download 
import org.apache.ivy.util.url.* 

task downloadDirectory { 
    def dir = 'http://127.0.0.1:8081/artifactory/gradle-local/props/' 
    def resolver = new org.apache.ivy.plugins.resolver.URLResolver() 
    def urlLister = new org.apache.ivy.util.url.ApacheURLLister() 
    def files = urlLister.listFiles(new URL(dir)) 
    download { 
     src files 
     dest "lib" 
    } 
} 

defaultTasks 'downloadDirectory' 

回答

0

從搖籃2.0你需要在爲了使這個配方工作構建腳本依賴於Apache的常青藤。將以下權利放在構建腳本的開頭。

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'org.apache.ivy:ivy:2.3.0' 
    } 
} 

例如:https://github.com/michel-kraemer/gradle-download-task/blob/ddb384d3ee86f038c61ec4e77f21b814b1557a1a/examples/directory.gradle

下載任務的另一種使用情況:https://www.michel-kraemer.com/recipes-for-gradle-download/