Reputation: 3720
I am currently exporting a zip distribution from my gradle
project and trying to add some more files in it but unable to place them in the desired location.
here is the structure of my project
TestProj/source
/export_dir / A1
/ B1
/ C1 / data / results.txt
/resources/temp.txt
/build.gradle
I was using the gradle Zip
task to export the export_dir as .zip file like below.
task exportZIP(type: Zip) {
from 'export_dir'
}
and it exports the export_dir
in TestProj-v1.zip but now i want to export temp.txt within the export_dir directory. so the resultant zip file should look like this
/export_dir / A1
/ B1
/ C1 / data / results.txt
/ temp.txt
I have tried the task below to do this but it is copying the temp.txt in the root of the zip not inside the desired place in the zip.
task exportZIP(type: Zip) {
from 'export_dir'
from 'resources/temp.txt'
into('export_dir/C1/data') {
}
}
any help or suggestion on how can i achieve this.
Thanks in anticipation!
Upvotes: 2
Views: 707
Reputation: 3720
Instead of copying temp.txt
in export_dir/C1/data/
inside the zip, I took a different approach as a fix.
I wrote the gradle task to copy the temp.txt in export_dir/C1/data/
inside the TestProj
directory so that when i export the zip of export_dir
it should have temp.txt already present at the right place.
Here is what i used
task copyTempToExpo(type: Copy) {
from 'resources/temp.txt'
}
and then export the zip of only export_dir
task exportZIP(type: Zip) {
from 'export_dir'
}
and then delete the temp.txt from resources
directory.
task clearTemp(type: Delete) {
delete "resources/temp.txt";
}
But i m still interested in knowing if there is some other way (like what i asked in question itself) to do this job.
Upvotes: 1