summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@opera.com>2017-12-05 13:30:14 +0100
committerJoel Klinghed <the_jk@opera.com>2017-12-05 13:30:14 +0100
commit38167e774934b643338f94201b16a922d80bc448 (patch)
treee11c6cbbfc2893f1636e538a6264bfc7824a0a3f
parent26bcc8b2e79d655bffe17b323b845cb4f32cc220 (diff)
Stop hardcoding generateDebugSources
Instead we write a list of generate tasks to output of flycheckAndroidJava task and let the pyhton script run them Reason to do it like this is that when the FlycheckAndroidJava task is created it's to early to get the list of buildtypes or flavors from the extensions.
-rw-r--r--bin/flycheck-android-java.py24
-rw-r--r--src/main/groovy/FlycheckAndroidJavaTask.groovy9
2 files changed, 28 insertions, 5 deletions
diff --git a/bin/flycheck-android-java.py b/bin/flycheck-android-java.py
index ae52fe7..d4a54ca 100644
--- a/bin/flycheck-android-java.py
+++ b/bin/flycheck-android-java.py
@@ -147,8 +147,8 @@ def figure_out_java_compilation(sessiondir, sourcefile, tempfile, checkstyle,
outdir = None
if not output:
- cmd.extend(['-q', 'flycheckAndroidJava'])
- output = subprocess.check_output(cmd, universal_newlines=True)
+ flycheck_cmd = cmd + ['-q', 'flycheckAndroidJava']
+ output = subprocess.check_output(flycheck_cmd, universal_newlines=True)
if sessiondir != None:
try:
with open(cachefile, 'w') as f:
@@ -157,12 +157,28 @@ def figure_out_java_compilation(sessiondir, sourcefile, tempfile, checkstyle,
pass
output = output.split('\n')
+
+ generate = None
+ all_generate = []
+
+ for line in output:
+ if line == '***' or line == '!!!':
+ if generate:
+ all_generate.extend(generate)
+
+ generate = [] if line == '!!!' else None
+ elif generate != None:
+ generate.append(line)
+
+ if all_generate:
+ subprocess.call(cmd + ['-q'] + all_generate)
+
data = None
first = None
ret = 0
compiled = False
for line in output:
- if line == '***':
+ if line == '***' or line == '!!!':
if data:
if not first:
first = data
@@ -174,7 +190,7 @@ def figure_out_java_compilation(sessiondir, sourcefile, tempfile, checkstyle,
data['args'], tempfile, outdir)
compiled = True
break
- data = {}
+ data = {} if line == '***' else None
elif data != None:
if line.startswith('args='):
data['args'] = line[6:-1].split(', ')
diff --git a/src/main/groovy/FlycheckAndroidJavaTask.groovy b/src/main/groovy/FlycheckAndroidJavaTask.groovy
index d7ce2da..633c445 100644
--- a/src/main/groovy/FlycheckAndroidJavaTask.groovy
+++ b/src/main/groovy/FlycheckAndroidJavaTask.groovy
@@ -6,7 +6,6 @@ import org.gradle.api.tasks.compile.JavaCompile
class FlycheckAndroidJavaTask extends DefaultTask {
FlycheckAndroidJavaTask() {
- dependsOn 'generateDebugSources'
}
@TaskAction
@@ -50,5 +49,13 @@ class FlycheckAndroidJavaTask extends DefaultTask {
println 'output=' + compile.destinationDir
}
}
+
+ def name = 'generate'
+ name += variants.first().capitalize() + 'Sources'
+ def generate = project.tasks.findByName(name)
+ if (generate != null) {
+ println '!!!'
+ println generate.path
+ }
}
}