Reputation: 1104
I have a gradle build which generates war file. I want to copy war file to my application servers' dropins directory which is somewhere outside of project directory. I have following copy task to do this.
task copyWarToDropins(type: Copy,dependsOn:[war]) {
from './build/libs/bds-service-token-1.0-SNAPSHOT.war'
into file('/apps/dropins') // want to copy to 'C:/apps/dropins' directory
rename { fileName -> 'bds-service-token.war' }
}
build.dependsOn copyWarToDropin
It evaluates /apps/dropins relative project directory and does copy there. I have tried many ways I can think of but could not make it copy to C:/apps/dropins directory.
Can someone please help?
Upvotes: 0
Views: 1478
Reputation: 14493
First, please note that using into file(...)
is redundant, as each call to into(...)
will be evaluated via Project.file(...)
anyhow.
As you can read in the documentation , file(...)
handles strings in the following way:
- A CharSequence, including String or GString. Interpreted relative to the project directory. A string that starts with
file:
is treated as a file URL.
So, one way to solve your problem could be using an absolute file URL.
However, if you continue to read the documentation, you will see that Java File
objects are supported. So you could simply create such an object:
into new File('C:/your/absolute/path')
Upvotes: 2