Cola
Cola

Reputation: 2257

Copy task in gradle

I am trying to do a simple file copy from one folder into another using gradle.

task copyTask(type: Copy) {

    from 'src/main/AndroidManifest.xml'
    into 'libs/x86'

}

This works, but

task copyTask(type: Copy) {

    from 'src/main/AndroidManifest.xml'
    into 'libs'

}

This doesn't. Neither does this :

task copyTask(type: Copy) {

    from 'src/main/AndroidManifest.xml'
    into '../val'

}

I tried substituting with absolute paths but that didn't work either. I checked a few examples on working with files and the relative path structure that i am using seems to be ok.

Why does only one relative path format work? Also if I try copying *.jar files instead of AndroidManifest.xml, that does not work either. What is wrong with my copy task?

Upvotes: 0

Views: 1378

Answers (1)

Jared Burrows
Jared Burrows

Reputation: 55555

See this example(from https://stackoverflow.com/a/10002455/950427):

This does what you want but copies *.wars.

task myCopy(type: Copy) {
    from('source')   // <-- folder
    into('target')   // <-- folder
    include('*.war') // <-- file(s)
}

You said in the comments you wanted to copy *.jars:

task myCopy(type: Copy) {
    from('source')   // <-- folder
    into('target')   // <-- folder
    include('*.jar') // <-- file(s)
}

Upvotes: 1

Related Questions