Andrii Abramov
Andrii Abramov

Reputation: 10751

Gradle copy task, relative path

I have two gradle modules(A and B). Module B depends on module A.

Module A contains Copy task from relative path:

task copyStrings(type: Copy){
    from '../path/'
    into 'folder'
}

tasks.preBuild.dependsOn('copyStrings')

When I execute ./gradlew assemble from module A it works perfectly.

But when I am assembling module B, gradle can't found such directory, because relative path is made from module B directory.

Is there any way to set working directory for Copy task?

Upvotes: 1

Views: 2380

Answers (1)

Opal
Opal

Reputation: 84786

Could you please try:

from project.file('../path/')

Also, there's no need for <<:

task copyStrings(type: Copy) { 
   from '../path/' into 'folder' 
}

is all you need. Here you can find a little demo.

Upvotes: 1

Related Questions