2017-08-04 23 views
0

摇篮copySpec包括关闭不工作:gradle这个副本包括关闭不工作

def fileList = ["hello/world.xml"] 

task foo(type: Copy) { 
    from (zipTree("/path/a.zip")) { 
    include { elem -> 
     fileList.contains(elem.path) 
    } 
    } 

} 

的a.zip包含 “你好/ world.xml”。

消息:需要用复制任务使用

Skipping task 'foo' as it has no source files and no previous output files. 

回答

0

copySpec闭合。 您的代码只是复制任务,需要复制目的地。

你的代码应该是更多这样的:

def fileList = ["hello/world.xml"] 

def filesToCopy = copySpec { 
    from (zipTree("/path/a.zip")) { 
     include { elem -> 
      fileList.contains(elem.path) 
     } 
    } 
} 

task foo(type: Copy) { 
    into 'build/target/docs' 

    with filesToCopy 
} 

见API的更多详细信息:https://docs.gradle.org/3.3/dsl/org.gradle.api.tasks.Copy.html