【问题标题】:android: gradle: how to copy a file? Issue to set a file readable, or to read itandroid:gradle:如何复制文件?设置文件可读或读取文件的问题
【发布时间】:2015-08-07 18:07:27
【问题描述】:

我被 Gradle 中的文件读取阻止。

我尝试在 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:在文件系统中,文件访问权限设置为每个人都可以读写。

【问题讨论】:

    标签: android gradle android-gradle-plugin build.gradle chmod


    【解决方案1】:

    找到解决我真正问题的方法:如何使用 gradle 复制文件?。我走错路了。

    copy {
      from 'src/'
                include '*.json'
                into '..'
    } 
    

    您可以在enter link description here找到更多详细信息

    这个answer,即使它与我的问题不太相关,但对我有帮助。

    【讨论】:

      猜你喜欢
      • 2016-07-06
      • 1970-01-01
      • 1970-01-01
      • 2013-11-20
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多