How to run copy task with android studio into assets folder

后端 未结 7 962
温柔的废话
温柔的废话 2020-12-01 11:53

So far I have added the following to the end of my \"build.gradle\"

task copyFiles(type: Copy)

copyFiles {
    description = \'Copies html5 files from the c         


        
相关标签:
7条回答
  • 2020-12-01 12:57

    Here is the module's build.gradle that I am using which successfully copies the files that I wanted as a pre-build task. The "into" is modelled after the File class in Java, so it should be familiar on how to use it. The two lines at the end is optional - it will run the copyFiles task when invoking gradle clean:

    android {
    .....
    }
    
    task copyFiles(type: Copy) {
        description = 'copying some file(s)....'
        from 'src/main'
        into project(':Path:To:ModuleFrom:Settings.gradle').file('./res')
        include 'file1.suffix'
        include '**/*.html'
    }
    
    project.afterEvaluate {
        preBuild.dependsOn copyFiles
    }
    
    clean.dependsOn copyFiles
    clean.mustRunAfter copyFiles
    
    0 讨论(0)
提交回复
热议问题