Gradle. How to generate source code before compilation in android app

前端 未结 1 1168
盖世英雄少女心
盖世英雄少女心 2020-12-16 01:50

In my android application I need to generate source code and use it in the app.
For that I created task genSources (using tutorials) for source generati

相关标签:
1条回答
  • 2020-12-16 02:35

    With gradle 2.2+ this should work:

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn genSources
    }
    

    If you also want it to happen when you evaluate (e.g. when syncing your project with gradle in android studio) you can do it like this:

    gradle.projectsEvaluated {
        preBuild.dependsOn genSources
    }
    
    0 讨论(0)
提交回复
热议问题