I have a very simple build.gradle
file with the following content:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.1'
}
}
apply plugin: 'android'
android {
buildToolsVersion "17.0.0"
compileSdkVersion 17
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
task generateSources {
doFirst {
def script = "python GenerateSources.py".execute()
script.in.eachLine {line -> println line}
script.err.eachLine {line -> println "ERROR: " + line}
script.waitFor()
}
}
What I want is to run generateSources
task before java compilation is started. I found several solutions how to do that, like compileJava.dependsOn("generateSources")
, but unfortunately they give an error:
A problem occurred evaluating root project 'Android'.
> Could not find property 'compileJava' on root project 'Android'.
I don't know Gradle and can't understand what's wrong with this code. So I would like to know how I can fix this error.
question from:https://stackoverflow.com/questions/16853130/run-task-before-compilation-using-android-gradle-plugin