From b8579fe531763e96a6289e02de7425348f277c2d Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Thu, 3 Sep 2015 15:01:30 -0600 Subject: [PATCH] [Infer][Gradle plugin] Fixing issue where files are captured twice Summary: When you run "gradle build", it builds both the debug and the release configurations for an app. This causes capture to run twice for some files and tricks the incremental analysis into marking the double-captured files as unchanged. This diff fixes the issue by only doing capture once on a set of commands that are identical up to the "debug/release" configuration. --- infer/lib/capture/gradle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/infer/lib/capture/gradle.py b/infer/lib/capture/gradle.py index 835dd10a9..9f8bf8720 100644 --- a/infer/lib/capture/gradle.py +++ b/infer/lib/capture/gradle.py @@ -45,9 +45,17 @@ class GradleCapture: def get_inferJ_commands(self, verbose_output): argument_start_pattern = ' Compiler arguments: ' calls = [] + seen_build_cmds = set([]) for line in verbose_output: if argument_start_pattern in line: content = line.partition(argument_start_pattern)[2].strip() + # if we're building both the debug and release configuration + # and the build commands are identical up to "release/debug", + # only do capture for one set of commands + build_agnostic_cmd = content.replace('release', 'debug') + if build_agnostic_cmd in seen_build_cmds: + continue + seen_build_cmds.add(build_agnostic_cmd) javac_arguments = content.split(' ') java_files = [] java_args = []