diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 9e76c5b11..5606c4139 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -877,6 +877,10 @@ int dummy; def generate_single_java_compile(self, src, target, compiler, outfile): deps = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets] + generated_sources = self.get_target_generated_sources(target) + for rel_src, gensrc in generated_sources.items(): + if rel_src.endswith('.java'): + deps.append(rel_src) args = [] args += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target)) args += self.build.get_global_args(compiler, target.is_cross) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index f45f91bf1..2a6f750b4 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -803,8 +803,8 @@ class Environment: p, out, err = Popen_safe(exelist + ['-version']) except OSError: raise EnvironmentException('Could not execute Java compiler "%s"' % ' '.join(exelist)) - version = search_version(err) if 'javac' in out or 'javac' in err: + version = search_version(err if 'javac' in err else out) return JavaCompiler(exelist, version) raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') diff --git a/test cases/java/8 codegen custom target/com/mesonbuild/meson.build b/test cases/java/8 codegen custom target/com/mesonbuild/meson.build index 67b98a4cd..030994154 100644 --- a/test cases/java/8 codegen custom target/com/mesonbuild/meson.build +++ b/test cases/java/8 codegen custom target/com/mesonbuild/meson.build @@ -4,5 +4,5 @@ config_file = custom_target('confgen', input : 'Config.java.in', output : 'Config.java', command : [python, '-c', - 'import shutil; import sys; shutil.copy(sys.argv[1], sys.argv[2])', + 'import shutil, sys, time; time.sleep(1); shutil.copy(sys.argv[1], sys.argv[2])', '@INPUT@', '@OUTPUT@'])