2017-08-04 1 views
0

Gradleの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閉鎖はコピータスクを使用する必要があります。 あなたのコードは、コピー先になる必要があるコピータスクです。

あなたのコードはより次のようにする必要があります:https://docs.gradle.org/3.3/dsl/org.gradle.api.tasks.Copy.html

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を参照してください。