aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/build_java_with_error_prone.py
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
committeralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
commitbf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch)
tree1d1df72c0541a59a81439842f46d95396d3e7189 /build/scripts/build_java_with_error_prone.py
parent8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff)
downloadydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz
add ymake export to ydb
Diffstat (limited to 'build/scripts/build_java_with_error_prone.py')
-rw-r--r--build/scripts/build_java_with_error_prone.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/build/scripts/build_java_with_error_prone.py b/build/scripts/build_java_with_error_prone.py
new file mode 100644
index 0000000000..910443552e
--- /dev/null
+++ b/build/scripts/build_java_with_error_prone.py
@@ -0,0 +1,36 @@
+import sys
+import os
+
+ERROR_PRONE_FLAGS = [
+ '-Xep:FunctionalInterfaceMethodChanged:WARN',
+ '-Xep:ReturnValueIgnored:WARN',
+]
+
+JAVA10_EXPORTS = [
+ '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
+ '--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED'
+]
+
+
+def just_do_it(argv):
+ java, error_prone_tool, javac_cmd = argv[0], argv[1], argv[2:]
+ if java.endswith('javac') or java.endswith('javac.exe'):
+ for f in javac_cmd:
+ if f.startswith('-Xep'):
+ ERROR_PRONE_FLAGS.append(f)
+ for f in ERROR_PRONE_FLAGS:
+ if f in javac_cmd:
+ javac_cmd.remove(f)
+ os.execv(java, [java] + JAVA10_EXPORTS + ['-processorpath', error_prone_tool, '-XDcompilePolicy=byfile'] + [(' '.join(['-Xplugin:ErrorProne'] + ERROR_PRONE_FLAGS))] + javac_cmd)
+ else:
+ os.execv(java, [java, '-Xbootclasspath/p:' + error_prone_tool, 'com.google.errorprone.ErrorProneCompiler'] + ERROR_PRONE_FLAGS + javac_cmd)
+
+
+if __name__ == '__main__':
+ just_do_it(sys.argv[1:])