I am blocked by a file reading in Gradle.
I try to set files readable this way in gradle:
task readAccess(type: Exec, description: 'set the google-services.json readable.') {
//--> check can read? --> can't read
if (new File('src/google-services.json').canRead()){
println 'readAccess > can read'
} else {
println 'readAccess > cant read'
}
//--> set readable. --> can't set readable
if (new File('src/google-services.json').setReadable(true,false)) {
println 'readAccess > access read modified'
} else {
println 'readAccess > access read not modified'
}
//--> check can read? --> can't read
if (new File('src/google-services.json').canRead()){
println 'readAccess > can read'
} else {
println 'readAccess > cant read'
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn gcmReadAccess
}
PS: the file access is set to read & write by everyone, in the file system.
find my solution to my real problem: how to copy a file with gradle? . I was going in the wrong way.
copy {
from 'src/'
include '*.json'
into '..'
}
You can find more details in enter link description here
This answer , even if it's not too related to my question, but helped me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.