Fábio Carballo
Fábio Carballo

Reputation: 3275

Run GreenDao generator automatically everytime I build project with gradle

I'm developing an Android app and I'm using greendao to model my database. I wanted to run the daogenerator everytime I rebuild a project but it is on another module.

How can I do this using gradle?

This is, how can I run the application in a module before building another module.

Thank you.

Upvotes: 2

Views: 628

Answers (2)

Carlos
Carlos

Reputation: 147

Not being able to comment: qmar answer is the way to go. You just saved my day ! Perfectly works when your greendao implementation is a separate module inside your project.

Upvotes: 0

Marcin Kunert
Marcin Kunert

Reputation: 6285

Sure you can do that!

  1. Create a task that runs your generation. For my case the module with greendao is next to the app module. It is an java module.

    task generateDao(type: GradleBuild) { dir = "../greendaogenerator" tasks = ["run"] }

  2. Configure that this task will run before every compile task

    tasks.whenTaskAdded { task -> if (task.name.startsWith('compile')) { task.dependsOn generateDao task.mustRunAfter generateDao } }

Upvotes: 1

Related Questions