Commit d95b3aba authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Add host_jar_path vs device_jar_path to build logic

Fixes desugared .jar files incorrectly being used in java_binary() /
junit_binary().

Bug: 1078484
Change-Id: Ia49a10d3e907844ed75ee658604e8eeaa2993fb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241865
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778433}
parent 278601b1
...@@ -356,7 +356,6 @@ group("gn_all") { ...@@ -356,7 +356,6 @@ group("gn_all") {
"//tools/android:push_apps_to_background", "//tools/android:push_apps_to_background",
"//tools/android/audio_focus_grabber:audio_focus_grabber_apk", "//tools/android/audio_focus_grabber:audio_focus_grabber_apk",
"//tools/android/customtabs_benchmark:customtabs_benchmark_apk", "//tools/android/customtabs_benchmark:customtabs_benchmark_apk",
"//tools/android/errorprone_plugin:errorprone_plugin_java",
"//tools/android/kerberos/SpnegoAuthenticator:spnego_authenticator_apk", "//tools/android/kerberos/SpnegoAuthenticator:spnego_authenticator_apk",
"//ui/android:ui_junit_tests", "//ui/android:ui_junit_tests",
"//weblayer/public/java:client_aar", "//weblayer/public/java:client_aar",
......
...@@ -17,5 +17,4 @@ java_binary("bytecode_processor") { ...@@ -17,5 +17,4 @@ java_binary("bytecode_processor") {
] ]
wrapper_script_name = "helper/bytecode_processor" wrapper_script_name = "helper/bytecode_processor"
enable_bytecode_checks = false enable_bytecode_checks = false
enable_desugar = false
} }
...@@ -20,6 +20,12 @@ also have a default `jar_excluded_patterns` set (more on that later): ...@@ -20,6 +20,12 @@ also have a default `jar_excluded_patterns` set (more on that later):
All target names must end with "_java" so that the build system can distinguish All target names must end with "_java" so that the build system can distinguish
them from non-java targets (or [other variations](https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?rcl=ec2c17d7b4e424e060c3c7972842af87343526a1&l=20)). them from non-java targets (or [other variations](https://cs.chromium.org/chromium/src/build/config/android/internal_rules.gni?rcl=ec2c17d7b4e424e060c3c7972842af87343526a1&l=20)).
Most targets produce two separate `.jar` files:
* Device `.jar`: Used to produce `.dex.jar`, which is used on-device.
* Host `.jar`: For use on the host machine (`junit_binary` / `java_binary`).
* Host `.jar` files live in `lib.java/` so that they are archived in
builder/tester bots (which do not archive `obj/`).
## From Source to Final Dex ## From Source to Final Dex
### Step 1: Create interface .jar with turbine or ijar ### Step 1: Create interface .jar with turbine or ijar
...@@ -72,15 +78,24 @@ This step can be disabled via GN arg: `use_errorprone_java_compiler = false` ...@@ -72,15 +78,24 @@ This step can be disabled via GN arg: `use_errorprone_java_compiler = false`
[ErrorProne]: https://errorprone.info/ [ErrorProne]: https://errorprone.info/
[ep_plugins]: /tools/android/errorprone_plugin/ [ep_plugins]: /tools/android/errorprone_plugin/
### Step 3: Desugaring ### Step 3: Desugaring (Device .jar Only)
This step happens only when targets have `supports_android = true`. This step happens only when targets have `supports_android = true`. It is not
applied to `.jar` files used by `junit_binary`.
* `//third_party/bazel/desugar` converts certain Java 8 constructs, such as * `//third_party/bazel/desugar` converts certain Java 8 constructs, such as
lambdas and default interface methods, into constructs that are compatible lambdas and default interface methods, into constructs that are compatible
with Java 7. with Java 7.
### Step 4: Filtering ### Step 4: Instrumenting (Device .jar Only)
This step happens only when this GN arg is set: `use_jacoco_coverage = true`
* [Jacoco] adds instrumentation hooks to methods.
[Jacoco]: https://www.eclemma.org/jacoco/
### Step 5: Filtering
This step happens only when targets that have `jar_excluded_patterns` or This step happens only when targets that have `jar_excluded_patterns` or
`jar_included_patterns` set (e.g. all `android_` targets). `jar_included_patterns` set (e.g. all `android_` targets).
...@@ -97,27 +112,12 @@ This step happens only when targets that have `jar_excluded_patterns` or ...@@ -97,27 +112,12 @@ This step happens only when targets that have `jar_excluded_patterns` or
[Android Resources]: life_of_a_resource.md [Android Resources]: life_of_a_resource.md
[apphooks]: /chrome/android/java/src/org/chromium/chrome/browser/AppHooksImpl.java [apphooks]: /chrome/android/java/src/org/chromium/chrome/browser/AppHooksImpl.java
### Step 5: Instrumentation ### Step 6: Per-Library Dexing
This step happens only when this GN arg is set: `use_jacoco_coverage = true`
* [Jacoco] adds instrumentation hooks to methods.
[Jacoco]: https://www.eclemma.org/jacoco/
### Step 6: Copy to lib.java
* The `.jar` is copied into `$root_build_dir/lib.java` (under target-specific
subdirectories) so that it will be included by bot archive steps.
* These `.jar` files are the ones used when running `java_binary` and
`junit_binary` targets.
### Step 7: Per-Library Dexing
This step happens only when targets have `supports_android = true`. This step happens only when targets have `supports_android = true`.
* [d8] converts `.jar` files containing `.class` files into `.dex.jar` files * [d8] converts `.jar` files containing `.class` files into `.dex.jar` files
containing `.dex` files. containing `classes.dex` files.
* Dexing is incremental - it will reuse dex'ed classes from a previous build if * Dexing is incremental - it will reuse dex'ed classes from a previous build if
the corresponding `.class` file is unchanged. the corresponding `.class` file is unchanged.
* These per-library `.dex.jar` files are used directly by [incremental install], * These per-library `.dex.jar` files are used directly by [incremental install],
...@@ -128,7 +128,7 @@ This step happens only when targets have `supports_android = true`. ...@@ -128,7 +128,7 @@ This step happens only when targets have `supports_android = true`.
[d8]: https://developer.android.com/studio/command-line/d8 [d8]: https://developer.android.com/studio/command-line/d8
[incremental install]: /build/android/incremental_install/README.md [incremental install]: /build/android/incremental_install/README.md
### Step 8: Apk / Bundle Module Compile ### Step 7: Apk / Bundle Module Compile
* Each `android_apk` and `android_bundle_module` template has a nested * Each `android_apk` and `android_bundle_module` template has a nested
`java_library` target. The nested library includes final copies of files `java_library` target. The nested library includes final copies of files
...@@ -139,7 +139,7 @@ This step happens only when targets have `supports_android = true`. ...@@ -139,7 +139,7 @@ This step happens only when targets have `supports_android = true`.
[JNI glue]: /base/android/jni_generator/README.md [JNI glue]: /base/android/jni_generator/README.md
### Step 9: Final Dexing ### Step 8: Final Dexing
This step is skipped when building using [Incremental Install]. This step is skipped when building using [Incremental Install].
...@@ -149,19 +149,11 @@ When `is_java_debug = true`: ...@@ -149,19 +149,11 @@ When `is_java_debug = true`:
When `is_java_debug = false`: When `is_java_debug = false`:
* [R8] performs whole-program optimization on all library `lib.java` `.jar` * [R8] performs whole-program optimization on all library `lib.java` `.jar`
files and outputs a final `.r8dex.jar`. files and outputs a final `.r8dex.jar`.
* For App Bundles, R8 creates a single `.r8dex.jar` with the code from all * For App Bundles, R8 creates a `.r8dex.jar` for each module.
modules.
[Incremental Install]: /build/android/incremental_install/README.md [Incremental Install]: /build/android/incremental_install/README.md
[R8]: https://r8.googlesource.com/r8 [R8]: https://r8.googlesource.com/r8
### Step 10: Bundle Module Dex Splitting
This step happens only when `is_java_debug = false`.
* [dexsplitter.py] splits the single `*dex.jar` into per-module `*dex.jar`
files.
## Test APKs with apk_under_test ## Test APKs with apk_under_test
Test APKs are normal APKs that contain an `<instrumentation>` tag within their Test APKs are normal APKs that contain an `<instrumentation>` tag within their
......
...@@ -14,7 +14,7 @@ import sys ...@@ -14,7 +14,7 @@ import sys
import tempfile import tempfile
import zipfile import zipfile
from filter_zip import CreatePathTransform import filter_zip
from util import build_utils from util import build_utils
...@@ -117,8 +117,8 @@ def main(args): ...@@ -117,8 +117,8 @@ def main(args):
build_utils.AddToZipHermetic( build_utils.AddToZipHermetic(
z, 'AndroidManifest.xml', src_path=options.android_manifest) z, 'AndroidManifest.xml', src_path=options.android_manifest)
path_transform = CreatePathTransform(options.jar_excluded_globs, path_transform = filter_zip.CreatePathTransform(
options.jar_included_globs, []) options.jar_excluded_globs, options.jar_included_globs, [])
with tempfile.NamedTemporaryFile() as jar_file: with tempfile.NamedTemporaryFile() as jar_file:
build_utils.MergeZips( build_utils.MergeZips(
jar_file.name, options.jars, path_transform=path_transform) jar_file.name, options.jars, path_transform=path_transform)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import argparse import argparse
import shutil
import sys import sys
from util import build_utils from util import build_utils
...@@ -20,6 +21,21 @@ _RESOURCE_CLASSES = [ ...@@ -20,6 +21,21 @@ _RESOURCE_CLASSES = [
def CreatePathTransform(exclude_globs, include_globs, def CreatePathTransform(exclude_globs, include_globs,
strip_resource_classes_for): strip_resource_classes_for):
"""Returns a function to strip paths for the given patterns.
Args:
exclude_globs: List of globs that if matched should be excluded.
include_globs: List of globs that if not matched should be excluded.
strip_resource_classes_for: List of Java packages for which to strip
R.java classes from.
Returns:
* None if no filters are needed.
* A function "(path) -> path" that returns None when |path| should be
stripped, or |path| otherwise.
"""
if not (exclude_globs or include_globs or strip_resource_classes_for):
return None
exclude_globs = list(exclude_globs or []) exclude_globs = list(exclude_globs or [])
if strip_resource_classes_for: if strip_resource_classes_for:
exclude_globs.extend(p.replace('.', '/') + '/' + f exclude_globs.extend(p.replace('.', '/') + '/' + f
...@@ -52,19 +68,18 @@ def main(): ...@@ -52,19 +68,18 @@ def main():
argv = build_utils.ExpandFileArgs(sys.argv[1:]) argv = build_utils.ExpandFileArgs(sys.argv[1:])
args = parser.parse_args(argv) args = parser.parse_args(argv)
if args.exclude_globs: args.exclude_globs = build_utils.ParseGnList(args.exclude_globs)
args.exclude_globs = build_utils.ParseGnList(args.exclude_globs) args.include_globs = build_utils.ParseGnList(args.include_globs)
if args.include_globs: args.strip_resource_classes_for = build_utils.ParseGnList(
args.include_globs= build_utils.ParseGnList(args.include_globs) args.strip_resource_classes_for)
if args.strip_resource_classes_for:
args.strip_resource_classes_for = build_utils.ParseGnList(
args.strip_resource_classes_for)
path_transform = CreatePathTransform(args.exclude_globs, args.include_globs, path_transform = CreatePathTransform(args.exclude_globs, args.include_globs,
args.strip_resource_classes_for) args.strip_resource_classes_for)
with build_utils.AtomicOutput(args.output) as f: with build_utils.AtomicOutput(args.output) as f:
build_utils.MergeZips( if path_transform:
f.name, [args.input], path_transform=path_transform) build_utils.MergeZips(f.name, [args.input], path_transform=path_transform)
else:
shutil.copy(args.input, f.name)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -242,18 +242,22 @@ through Proguard or other tools. For most targets this is generated ...@@ -242,18 +242,22 @@ through Proguard or other tools. For most targets this is generated
from sources, with a name like `$target_name.javac.jar`. However, when using from sources, with a name like `$target_name.javac.jar`. However, when using
a prebuilt jar, this will point to the source archive directly. a prebuilt jar, this will point to the source archive directly.
* `deps_info['jar_path']`: * `deps_info['device_jar_path']`:
Path to a file that is the result of processing Path to a file that is the result of processing
`deps_info['unprocessed_jar_path']` with various tools. `deps_info['unprocessed_jar_path']` with various tools (ready to be dexed).
* `deps_info['host_jar_path']`:
Path to a file that is the result of processing
`deps_info['unprocessed_jar_path']` with various tools (use by java_binary).
* `deps_info['interface_jar_path']: * `deps_info['interface_jar_path']:
Path to the interface jar generated for this library. This corresponds to Path to the interface jar generated for this library. This corresponds to
a jar file that only contains declarations. Generated by running the `ijar` on a jar file that only contains declarations. Generated by running the `ijar` on
`deps_info['jar_path']` or the `turbine` tool on source files. `deps_info['unprocessed_jar_path']` or the `turbine` tool on source files.
* `deps_info['dex_path']`: * `deps_info['dex_path']`:
Path to the `.dex` file generated for this target, from `deps_info['jar_path']` Path to the `.dex` file generated for this target, from
unless this comes from a prebuilt `.aar` archive. `deps_info['device_jar_path']` unless this comes from a prebuilt `.aar` archive.
* `deps_info['is_prebuilt']`: * `deps_info['is_prebuilt']`:
True to indicate that this target corresponds to a prebuilt `.jar` file. True to indicate that this target corresponds to a prebuilt `.jar` file.
...@@ -323,10 +327,10 @@ all entries from the `java_library` type, and adds: ...@@ -323,10 +327,10 @@ all entries from the `java_library` type, and adds:
* `deps_info['main_class']`: * `deps_info['main_class']`:
Name of the main Java class that serves as an entry point for the binary. Name of the main Java class that serves as an entry point for the binary.
* `deps_info['java_runtime_classpath']`: * `deps_info['device_classpath']`:
The classpath used when running a Java or Android binary. Essentially the The classpath used when running a Java or Android binary. Essentially the
collection of all `deps_info['jar_path']` entries for the target and all its collection of all `deps_info['device_jar_path']` entries for the target and all
dependencies. its dependencies.
## <a name="target_junit_binary">Target type `junit_binary`</a>: ## <a name="target_junit_binary">Target type `junit_binary`</a>:
...@@ -885,7 +889,8 @@ def main(argv): ...@@ -885,7 +889,8 @@ def main(argv):
help='Consider the assets as locale paks in BuildConfig.java') help='Consider the assets as locale paks in BuildConfig.java')
# java library options # java library options
parser.add_option('--jar-path', help='Path to target\'s jar output.') parser.add_option('--device-jar-path', help='Path to .jar for dexing.')
parser.add_option('--host-jar-path', help='Path to .jar for java_binary.')
parser.add_option('--unprocessed-jar-path', parser.add_option('--unprocessed-jar-path',
help='Path to the .jar to use for javac classpath purposes.') help='Path to the .jar to use for javac classpath purposes.')
parser.add_option( parser.add_option(
...@@ -1048,11 +1053,13 @@ def main(argv): ...@@ -1048,11 +1053,13 @@ def main(argv):
if options.fail: if options.fail:
parser.error('\n'.join(build_utils.ParseGnList(options.fail))) parser.error('\n'.join(build_utils.ParseGnList(options.fail)))
jar_path_options = ['jar_path', 'unprocessed_jar_path', 'interface_jar_path'] lib_options = ['unprocessed_jar_path', 'interface_jar_path']
device_lib_options = ['device_jar_path', 'dex_path']
required_options_map = { required_options_map = {
'android_apk': ['build_config', 'dex_path'] + jar_path_options, 'android_apk': ['build_config'] + lib_options + device_lib_options,
'android_app_bundle_module': ['build_config', 'dex_path', 'android_app_bundle_module':
'final_dex_path', 'res_size_info'] + jar_path_options, ['build_config', 'final_dex_path', 'res_size_info'] + lib_options +
device_lib_options,
'android_assets': ['build_config'], 'android_assets': ['build_config'],
'android_resources': ['build_config', 'resources_zip'], 'android_resources': ['build_config', 'resources_zip'],
'dist_aar': ['build_config'], 'dist_aar': ['build_config'],
...@@ -1060,9 +1067,9 @@ def main(argv): ...@@ -1060,9 +1067,9 @@ def main(argv):
'group': ['build_config'], 'group': ['build_config'],
'java_annotation_processor': ['build_config', 'main_class'], 'java_annotation_processor': ['build_config', 'main_class'],
'java_binary': ['build_config'], 'java_binary': ['build_config'],
'java_library': ['build_config'] + jar_path_options, 'java_library': ['build_config', 'host_jar_path'] + lib_options,
'junit_binary': ['build_config'], 'junit_binary': ['build_config'],
'system_java_library': ['build_config'], 'system_java_library': ['build_config', 'unprocessed_jar_path'],
'android_app_bundle': ['build_config', 'module_build_configs'], 'android_app_bundle': ['build_config', 'module_build_configs'],
} }
required_options = required_options_map.get(options.type) required_options = required_options_map.get(options.type)
...@@ -1102,10 +1109,10 @@ def main(argv): ...@@ -1102,10 +1109,10 @@ def main(argv):
'--library-renames can only be used with --type=android_apk or ' '--library-renames can only be used with --type=android_apk or '
'--type=android_app_bundle_module') '--type=android_app_bundle_module')
if options.jar_path and options.supports_android and not options.dex_path: if options.device_jar_path and not options.dex_path:
raise Exception('java_library that supports Android requires a dex path.') raise Exception('java_library that supports Android requires a dex path.')
if any(getattr(options, x) for x in jar_path_options): if any(getattr(options, x) for x in lib_options):
for attr in jar_path_options: for attr in lib_options:
if not getattr(options, attr): if not getattr(options, attr):
raise('Expected %s to be set.' % attr) raise('Expected %s to be set.' % attr)
...@@ -1270,10 +1277,13 @@ def main(argv): ...@@ -1270,10 +1277,13 @@ def main(argv):
if is_java_target: if is_java_target:
# Classpath values filled in below (after applying tested_apk_config). # Classpath values filled in below (after applying tested_apk_config).
config['javac'] = {} config['javac'] = {}
if options.jar_path: if options.unprocessed_jar_path:
deps_info['jar_path'] = options.jar_path
deps_info['unprocessed_jar_path'] = options.unprocessed_jar_path deps_info['unprocessed_jar_path'] = options.unprocessed_jar_path
deps_info['interface_jar_path'] = options.interface_jar_path deps_info['interface_jar_path'] = options.interface_jar_path
if options.device_jar_path:
deps_info['device_jar_path'] = options.device_jar_path
if options.host_jar_path:
deps_info['host_jar_path'] = options.host_jar_path
if options.enable_jetify: if options.enable_jetify:
deps_info['jetified_jar_path'] = options.jetified_jar_path deps_info['jetified_jar_path'] = options.jetified_jar_path
else: else:
...@@ -1469,15 +1479,24 @@ def main(argv): ...@@ -1469,15 +1479,24 @@ def main(argv):
if is_java_target or options.type == 'android_app_bundle': if is_java_target or options.type == 'android_app_bundle':
# The classpath to use to run this target (or as an input to ProGuard). # The classpath to use to run this target (or as an input to ProGuard).
java_full_classpath = [] device_classpath = []
if is_java_target and options.jar_path: if is_java_target and options.device_jar_path:
java_full_classpath.append(options.jar_path) device_classpath.append(options.device_jar_path)
java_full_classpath.extend(c['jar_path'] for c in all_library_deps) device_classpath.extend(
c.get('device_jar_path') for c in all_library_deps
if c.get('device_jar_path'))
if options.type == 'android_app_bundle': if options.type == 'android_app_bundle':
for d in deps.Direct('android_app_bundle_module'): for d in deps.Direct('android_app_bundle_module'):
java_full_classpath.extend( device_classpath.extend(c for c in d.get('device_classpath', [])
c for c in d.get('java_runtime_classpath', []) if c not in device_classpath)
if c not in java_full_classpath)
if options.type in ('dist_jar', 'java_binary', 'junit_binary'):
# The classpath to use to run this target.
host_classpath = []
if options.host_jar_path:
host_classpath.append(options.host_jar_path)
host_classpath.extend(c['host_jar_path'] for c in all_library_deps)
deps_info['host_classpath'] = host_classpath
all_configs = build_utils.ParseGnList(options.proguard_configs) all_configs = build_utils.ParseGnList(options.proguard_configs)
deps_info['proguard_configs'] = list(all_configs) deps_info['proguard_configs'] = list(all_configs)
...@@ -1573,7 +1592,7 @@ def main(argv): ...@@ -1573,7 +1592,7 @@ def main(argv):
if dep_config['type'] == 'android_app_bundle': if dep_config['type'] == 'android_app_bundle':
base_config = GetDepConfig(dep_config['base_module_config']) base_config = GetDepConfig(dep_config['base_module_config'])
extra_main_r_text_files.append(base_config['r_text_path']) extra_main_r_text_files.append(base_config['r_text_path'])
static_lib_jar_paths[config_path] = base_config['jar_path'] static_lib_jar_paths[config_path] = base_config['device_jar_path']
all_configs.extend(dep_config['proguard_all_configs']) all_configs.extend(dep_config['proguard_all_configs'])
extra_proguard_classpath_jars.extend( extra_proguard_classpath_jars.extend(
dep_config['proguard_classpath_jars']) dep_config['proguard_classpath_jars'])
...@@ -1588,19 +1607,19 @@ def main(argv): ...@@ -1588,19 +1607,19 @@ def main(argv):
for package in base_config['extra_package_names']: for package in base_config['extra_package_names']:
if package not in extra_package_names: if package not in extra_package_names:
extra_package_names.append(package) extra_package_names.append(package)
for cp_entry in dep_config['java_runtime_classpath']: for cp_entry in dep_config['device_classpath']:
configs_by_classpath_entry[cp_entry].append(config_path) configs_by_classpath_entry[cp_entry].append(config_path)
for cp_entry in java_full_classpath: for cp_entry in device_classpath:
configs_by_classpath_entry[cp_entry].append(options.build_config) configs_by_classpath_entry[cp_entry].append(options.build_config)
for cp_entry, candidate_configs in configs_by_classpath_entry.iteritems(): for cp_entry, candidate_configs in configs_by_classpath_entry.iteritems():
config_path = (candidate_configs[0] config_path = (candidate_configs[0]
if len(candidate_configs) == 1 else options.build_config) if len(candidate_configs) == 1 else options.build_config)
classpath_entries_by_owning_config[config_path].append(cp_entry) classpath_entries_by_owning_config[config_path].append(cp_entry)
java_full_classpath.append(cp_entry) device_classpath.append(cp_entry)
java_full_classpath = sorted(set(java_full_classpath)) device_classpath = sorted(set(device_classpath))
deps_info['static_library_proguard_mapping_output_paths'] = sorted([ deps_info['static_library_proguard_mapping_output_paths'] = sorted([
d['proguard_mapping_path'] d['proguard_mapping_path']
...@@ -1645,7 +1664,7 @@ def main(argv): ...@@ -1645,7 +1664,7 @@ def main(argv):
deps_proguard_enabled = [] deps_proguard_enabled = []
deps_proguard_disabled = [] deps_proguard_disabled = []
for d in deps.Direct('android_app_bundle_module'): for d in deps.Direct('android_app_bundle_module'):
if not d['java_runtime_classpath']: if not d['device_classpath']:
# We don't care about modules that have no Java code for proguarding. # We don't care about modules that have no Java code for proguarding.
continue continue
if d['proguard_enabled']: if d['proguard_enabled']:
...@@ -1695,10 +1714,10 @@ def main(argv): ...@@ -1695,10 +1714,10 @@ def main(argv):
# Add all tested classes to the test's classpath to ensure that the test's # Add all tested classes to the test's classpath to ensure that the test's
# java code is a superset of the tested apk's java code # java code is a superset of the tested apk's java code
java_full_classpath_extended = list(java_full_classpath) device_classpath_extended = list(device_classpath)
java_full_classpath_extended.extend( device_classpath_extended.extend(
p for p in tested_apk_config['java_runtime_classpath'] p for p in tested_apk_config['device_classpath']
if p not in java_full_classpath) if p not in device_classpath)
# Include in the classpath classes that are added directly to the apk under # Include in the classpath classes that are added directly to the apk under
# test (those that are not a part of a java_library). # test (those that are not a part of a java_library).
javac_classpath.append(tested_apk_config['unprocessed_jar_path']) javac_classpath.append(tested_apk_config['unprocessed_jar_path'])
...@@ -1721,9 +1740,9 @@ def main(argv): ...@@ -1721,9 +1740,9 @@ def main(argv):
tested_apk_library_deps = tested_apk_deps.All('java_library') tested_apk_library_deps = tested_apk_deps.All('java_library')
tested_apk_dex_files = {c['dex_path'] for c in tested_apk_library_deps} tested_apk_dex_files = {c['dex_path'] for c in tested_apk_library_deps}
all_dex_files = [p for p in all_dex_files if p not in tested_apk_dex_files] all_dex_files = [p for p in all_dex_files if p not in tested_apk_dex_files]
tested_apk_jar_files = set(tested_apk_config['java_runtime_classpath']) tested_apk_jar_files = set(tested_apk_config['device_classpath'])
java_full_classpath = [ device_classpath = [
p for p in java_full_classpath if p not in tested_apk_jar_files p for p in device_classpath if p not in tested_apk_jar_files
] ]
if options.type in ('android_apk', 'dist_aar', 'dist_jar', if options.type in ('android_apk', 'dist_aar', 'dist_jar',
...@@ -1744,10 +1763,16 @@ def main(argv): ...@@ -1744,10 +1763,16 @@ def main(argv):
if is_java_target: if is_java_target:
config['javac']['classpath'] = javac_classpath config['javac']['classpath'] = javac_classpath
config['javac']['interface_classpath'] = javac_interface_classpath config['javac']['interface_classpath'] = javac_interface_classpath
# Direct() will be of type 'java_annotation_processor'. # Direct() will be of type 'java_annotation_processor', and so not included
# in All('java_library').
# Annotation processors run as part of the build, so need host_jar_path.
config['javac']['processor_classpath'] = [ config['javac']['processor_classpath'] = [
c['jar_path'] for c in processor_deps.Direct() if c.get('jar_path')] + [ c['host_jar_path'] for c in processor_deps.Direct()
c['jar_path'] for c in processor_deps.All('java_library')] if c.get('host_jar_path')
]
config['javac']['processor_classpath'] += [
c['host_jar_path'] for c in processor_deps.All('java_library')
]
config['javac']['processor_classes'] = [ config['javac']['processor_classes'] = [
c['main_class'] for c in processor_deps.Direct()] c['main_class'] for c in processor_deps.Direct()]
deps_info['javac_full_classpath'] = javac_full_classpath deps_info['javac_full_classpath'] = javac_full_classpath
...@@ -1758,19 +1783,18 @@ def main(argv): ...@@ -1758,19 +1783,18 @@ def main(argv):
javac_full_classpath = set() javac_full_classpath = set()
for d in deps.Direct('android_app_bundle_module'): for d in deps.Direct('android_app_bundle_module'):
javac_full_classpath.update(p for p in d['javac_full_classpath']) javac_full_classpath.update(p for p in d['javac_full_classpath'])
javac_full_classpath.add(d['jar_path']) javac_full_classpath.add(d['unprocessed_jar_path'])
deps_info['javac_full_classpath'] = sorted(javac_full_classpath) deps_info['javac_full_classpath'] = sorted(javac_full_classpath)
if options.type in ('android_apk', 'dist_jar', 'java_binary', 'junit_binary', if options.type in ('android_apk', 'dist_jar', 'android_app_bundle_module',
'android_app_bundle_module', 'android_app_bundle'): 'android_app_bundle'):
deps_info['java_runtime_classpath'] = java_full_classpath deps_info['device_classpath'] = device_classpath
if options.tested_apk_config: if options.tested_apk_config:
deps_info['java_runtime_classpath_extended'] = ( deps_info['java_runtime_classpath_extended'] = (device_classpath_extended)
java_full_classpath_extended)
if options.type in ('android_apk', 'dist_jar'): if options.type in ('android_apk', 'dist_jar'):
all_interface_jars = [] all_interface_jars = []
if options.jar_path: if options.interface_jar_path:
all_interface_jars.append(options.interface_jar_path) all_interface_jars.append(options.interface_jar_path)
all_interface_jars.extend(c['interface_jar_path'] for c in all_library_deps) all_interface_jars.extend(c['interface_jar_path'] for c in all_library_deps)
...@@ -1862,7 +1886,7 @@ def main(argv): ...@@ -1862,7 +1886,7 @@ def main(argv):
# are not duplicated on the feature module. # are not duplicated on the feature module.
if base_module_build_config: if base_module_build_config:
base = base_module_build_config base = base_module_build_config
RemoveObjDups(config, base, 'deps_info', 'java_runtime_classpath') RemoveObjDups(config, base, 'deps_info', 'device_classpath')
RemoveObjDups(config, base, 'deps_info', 'javac_full_classpath') RemoveObjDups(config, base, 'deps_info', 'javac_full_classpath')
RemoveObjDups(config, base, 'deps_info', 'javac_full_interface_classpath') RemoveObjDups(config, base, 'deps_info', 'javac_full_interface_classpath')
RemoveObjDups(config, base, 'deps_info', 'jetified_full_jar_classpath') RemoveObjDups(config, base, 'deps_info', 'jetified_full_jar_classpath')
......
...@@ -28,6 +28,7 @@ template("copy_ex") { ...@@ -28,6 +28,7 @@ template("copy_ex") {
[ [
"data", "data",
"deps", "deps",
"public_deps",
"testonly", "testonly",
"visibility", "visibility",
]) ])
......
...@@ -78,6 +78,7 @@ _java_target_patterns = _java_library_patterns + _java_resource_patterns ...@@ -78,6 +78,7 @@ _java_target_patterns = _java_library_patterns + _java_resource_patterns
_r8_path = "//third_party/r8/lib/r8.jar" _r8_path = "//third_party/r8/lib/r8.jar"
_desugar_jdk_libs_json = "//third_party/r8/desugar_jdk_libs.json" _desugar_jdk_libs_json = "//third_party/r8/desugar_jdk_libs.json"
_desugar_jdk_libs_jar = "//third_party/android_deps/libs/com_android_tools_desugar_jdk_libs/desugar_jdk_libs-1.0.5.jar" _desugar_jdk_libs_jar = "//third_party/android_deps/libs/com_android_tools_desugar_jdk_libs/desugar_jdk_libs-1.0.5.jar"
_desugar_runtime_jar = "$root_build_dir/obj/third_party/bazel/desugar/Desugar_runtime.processed.jar"
_dexdump_path = "$android_sdk_build_tools/dexdump" _dexdump_path = "$android_sdk_build_tools/dexdump"
_dexlayout_path = "//third_party/android_build_tools/art/dexlayout" _dexlayout_path = "//third_party/android_build_tools/art/dexlayout"
...@@ -219,10 +220,16 @@ template("write_build_config") { ...@@ -219,10 +220,16 @@ template("write_build_config") {
args += [ "--non-chromium-code" ] args += [ "--non-chromium-code" ]
} }
if (defined(invoker.jar_path)) { if (defined(invoker.device_jar_path)) {
args += [ args += [
"--jar-path", "--device-jar-path",
rebase_path(invoker.jar_path, root_build_dir), rebase_path(invoker.device_jar_path, root_build_dir),
]
}
if (defined(invoker.host_jar_path)) {
args += [
"--host-jar-path",
rebase_path(invoker.host_jar_path, root_build_dir),
] ]
} }
if (defined(invoker.unprocessed_jar_path)) { if (defined(invoker.unprocessed_jar_path)) {
...@@ -1098,7 +1105,7 @@ if (enable_java_templates) { ...@@ -1098,7 +1105,7 @@ if (enable_java_templates) {
_args += [ _args += [
"--feature-name=${_feature_module.name}", "--feature-name=${_feature_module.name}",
"--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)", "--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)",
"--feature-jars=@FileArg($_rebased_module_build_config:deps_info:java_runtime_classpath)", "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:device_classpath)",
] ]
_deps += [ _feature_module.build_config_target ] _deps += [ _feature_module.build_config_target ]
} }
...@@ -1263,7 +1270,9 @@ if (enable_java_templates) { ...@@ -1263,7 +1270,9 @@ if (enable_java_templates) {
"--main-class", "--main-class",
_main_class, _main_class,
] ]
args += [ "--classpath=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ] args += [
"--classpath=@FileArg($_rebased_build_config:deps_info:host_classpath)",
]
if (use_jacoco_coverage) { if (use_jacoco_coverage) {
args += [ args += [
...@@ -1373,12 +1382,15 @@ if (enable_java_templates) { ...@@ -1373,12 +1382,15 @@ if (enable_java_templates) {
if (defined(invoker.has_apk_under_test) && invoker.has_apk_under_test) { if (defined(invoker.has_apk_under_test) && invoker.has_apk_under_test) {
args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath_extended)" ] args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath_extended)" ]
} else { } else {
args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ] args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:device_classpath)" ]
} }
if (enable_bazel_desugar) { if (enable_bazel_desugar) {
deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ] deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
inputs += [ "$root_build_dir/lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ] inputs += [ _desugar_runtime_jar ]
args += [ "--input-paths=lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ] args += [
"--input-paths",
rebase_path(_desugar_runtime_jar, root_build_dir),
]
} }
if (defined(invoker.proguard_args)) { if (defined(invoker.proguard_args)) {
args += invoker.proguard_args args += invoker.proguard_args
...@@ -1433,7 +1445,7 @@ if (enable_java_templates) { ...@@ -1433,7 +1445,7 @@ if (enable_java_templates) {
# It would be more efficient to use the pre-dex'ed copy of the runtime, # It would be more efficient to use the pre-dex'ed copy of the runtime,
# but it's easier to add it in this way. # but it's easier to add it in this way.
_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ] _deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
_input_class_jars += [ "$root_build_dir/lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ] _input_class_jars += [ _desugar_runtime_jar ]
} }
if (_input_class_jars != []) { if (_input_class_jars != []) {
_rebased_input_class_jars = _rebased_input_class_jars =
...@@ -1704,59 +1716,57 @@ if (enable_java_templates) { ...@@ -1704,59 +1716,57 @@ if (enable_java_templates) {
} }
} }
# TODO(digit): Document this! template("filter_jar") {
# action_with_pydeps(target_name) {
# Variables: script = "//build/android/gyp/filter_zip.py"
# testonly: forward_variables_from(invoker,
# build_config: [
# enable_jetify: A boolean to enable jetifying. "deps",
# input_jar_path: "testonly",
# output_jar_path: ])
# supports_android: inputs = [ invoker.input_jar ]
# jacoco_instrument: Use Jacoco-instrumented classes to generate Java if (defined(invoker.inputs)) {
# coverage data. inputs += invoker.inputs
# jar_excluded_patterns: Optional list of .class file patterns to exclude }
# from the final .jar file. outputs = [ invoker.output_jar ]
# jar_included_patterns: Optional list of .class file patterns to include
# in the final .jar file. jar_excluded_patterns take precedence over this. _jar_excluded_patterns = []
# strip_resource_classes: if (defined(invoker.jar_excluded_patterns)) {
# deps: _jar_excluded_patterns = invoker.jar_excluded_patterns
# java_files: }
# java_sources_file: _jar_included_patterns = []
# inputs: if (defined(invoker.jar_included_patterns)) {
# data_deps: _jar_included_patterns = invoker.jar_included_patterns
# visibility: }
# _strip_resource_classes = defined(invoker.strip_resource_classes) &&
invoker.strip_resource_classes
args = [
"--input",
rebase_path(invoker.input_jar, root_build_dir),
"--output",
rebase_path(invoker.output_jar, root_build_dir),
"--exclude-globs=${_jar_excluded_patterns}",
"--include-globs=${_jar_included_patterns}",
]
if (_strip_resource_classes) {
inputs += [ invoker.build_config ]
_rebased_build_config =
rebase_path(invoker.build_config, root_build_dir)
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
}
}
template("process_java_prebuilt") { template("process_java_prebuilt") {
set_sources_assignment_filter([])
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker, [ "testonly" ])
assert(invoker.build_config != "") _rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
_build_config = invoker.build_config not_needed([ "_rebased_build_config" ])
_rebased_build_config = rebase_path(_build_config, root_build_dir) not_needed(invoker, [ "build_config_dep" ])
assert(_rebased_build_config != "" || true) # Mark used.
_input_jar_path = invoker.input_jar_path
_output_jar_path = invoker.output_jar_path
_jacoco_instrument = invoker.jacoco_instrument
_enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify _enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
_deps = invoker.jar_deps
_jar_excluded_patterns = [] _previous_output_jar = invoker.input_jar_path
if (defined(invoker.jar_excluded_patterns)) {
_jar_excluded_patterns = invoker.jar_excluded_patterns
}
_jar_included_patterns = []
if (defined(invoker.jar_included_patterns)) {
_jar_included_patterns = invoker.jar_included_patterns
}
_strip_resource_classes = defined(invoker.strip_resource_classes) &&
invoker.strip_resource_classes
_filter_jar = _jar_excluded_patterns != [] ||
_jar_included_patterns != [] || _strip_resource_classes
_deps = []
_previous_output_jar = _input_jar_path
if (_enable_jetify) { if (_enable_jetify) {
_jetify_target = "${target_name}__jetify" _jetify_target = "${target_name}__jetify"
...@@ -1766,9 +1776,6 @@ if (enable_java_templates) { ...@@ -1766,9 +1776,6 @@ if (enable_java_templates) {
action_with_pydeps(_jetify_target) { action_with_pydeps(_jetify_target) {
script = "//build/android/gyp/jetify_jar.py" script = "//build/android/gyp/jetify_jar.py"
deps = _deps deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
}
_jetify_jar_path = _jetify_jar_path =
"//third_party/jetifier_standalone/bin/jetifier-standalone" "//third_party/jetifier_standalone/bin/jetifier-standalone"
_jetify_config_path = _jetify_config_path =
...@@ -1796,132 +1803,113 @@ if (enable_java_templates) { ...@@ -1796,132 +1803,113 @@ if (enable_java_templates) {
_previous_output_jar = _jetify_output_jar _previous_output_jar = _jetify_output_jar
} }
if (invoker.enable_desugar) { # Create the .jar in lib.java for use by java_binary.
_desugar_target = "${target_name}__desugar" if (defined(invoker.host_jar_path)) {
_desugar_input_jar = _previous_output_jar filter_jar("${target_name}_host") {
_desugar_output_jar = "$target_out_dir/$target_name.desugar.jar" forward_variables_from(invoker,
[
action_with_pydeps(_desugar_target) { "jar_excluded_patterns",
script = "//build/android/gyp/desugar.py" "jar_included_patterns",
"strip_resource_classes",
])
deps = _deps deps = _deps
depfile = "$target_gen_dir/$target_name.d" input_jar = _previous_output_jar
if (defined(invoker.deps)) { output_jar = invoker.host_jar_path
deps += invoker.deps inputs = []
if (defined(strip_resource_classes) && strip_resource_classes) {
inputs += [ invoker.build_config ]
deps += [ invoker.build_config_dep ]
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
if (defined(invoker.inputs)) {
inputs += invoker.inputs
deps += invoker.input_deps
} }
_desugar_jar = "//third_party/bazel/desugar/Desugar.jar"
inputs = [
_build_config,
_desugar_input_jar,
_desugar_jar,
]
outputs = [ _desugar_output_jar ]
args = [
"--desugar-jar",
rebase_path(_desugar_jar, root_build_dir),
"--input-jar",
rebase_path(_desugar_input_jar, root_build_dir),
"--output-jar",
rebase_path(_desugar_output_jar, root_build_dir),
# Temporarily using java_full_interface_classpath until classpath validation of targets
# is implemented, see http://crbug.com/885273
"--classpath=@FileArg($_rebased_build_config:deps_info:jetified_full_jar_classpath)",
"--bootclasspath=@FileArg($_rebased_build_config:android:sdk_interface_jars)",
"--depfile",
rebase_path(depfile, root_build_dir),
]
} }
_deps = []
_deps = [ ":$_desugar_target" ]
_previous_output_jar = _desugar_output_jar
} }
if (_filter_jar) { if (defined(invoker.device_jar_path)) {
_filter_target = "${target_name}__filter" if (invoker.enable_desugar) {
_filter_input_jar = _previous_output_jar _desugar_target = "${target_name}_device__desugar"
_filter_output_jar = "$target_out_dir/$target_name.filtered.jar" _desugar_output_jar = "$target_out_dir/$target_name.desugar.jar"
action_with_pydeps(_filter_target) { action_with_pydeps(_desugar_target) {
script = "//build/android/gyp/filter_zip.py" script = "//build/android/gyp/desugar.py"
deps = _deps deps = _deps + invoker.classpath_deps
if (defined(invoker.deps)) { depfile = "$target_gen_dir/$target_name.d"
deps += invoker.deps _desugar_jar = "//third_party/bazel/desugar/Desugar.jar"
}
inputs = [ inputs = [
_build_config, invoker.build_config,
_filter_input_jar, _previous_output_jar,
] _desugar_jar,
outputs = [ _filter_output_jar ] ]
args = [ outputs = [ _desugar_output_jar ]
"--input", args = [
rebase_path(_filter_input_jar, root_build_dir), "--desugar-jar",
"--output", rebase_path(_desugar_jar, root_build_dir),
rebase_path(_filter_output_jar, root_build_dir), "--input-jar",
"--exclude-globs=$_jar_excluded_patterns", rebase_path(_previous_output_jar, root_build_dir),
"--include-globs=$_jar_included_patterns", "--output-jar",
] rebase_path(_desugar_output_jar, root_build_dir),
if (_strip_resource_classes) {
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ] # Temporarily using java_full_interface_classpath until classpath validation of targets
# is implemented, see http://crbug.com/885273
"--classpath=@FileArg($_rebased_build_config:deps_info:jetified_full_jar_classpath)",
"--bootclasspath=@FileArg($_rebased_build_config:android:sdk_interface_jars)",
"--depfile",
rebase_path(depfile, root_build_dir),
]
} }
_deps = []
_deps = [ ":$_desugar_target" ]
_previous_output_jar = _desugar_output_jar
} }
_deps = [] if (invoker.jacoco_instrument) {
_deps = [ ":$_filter_target" ] # Jacoco must run after desugar (or else desugar sometimes fails).
_previous_output_jar = _filter_output_jar _jacoco_target = "${target_name}_device__jacoco"
} _jacoco_output_jar = "$target_out_dir/$target_name.instrumented.jar"
if (_jacoco_instrument) { jacoco_instr(_jacoco_target) {
# Jacoco must run after desugar (or else desugar sometimes fails). deps = _deps + invoker.jar_deps
_jacoco_target = "${target_name}__jacoco" forward_variables_from(invoker,
_jacoco_input_jar = _previous_output_jar [
_jacoco_output_jar = "$target_out_dir/$target_name.instrumented.jar" "java_files",
"java_sources_file",
])
jacoco_instr(_jacoco_target) { input_jar_path = _previous_output_jar
deps = _deps output_jar_path = _jacoco_output_jar
if (defined(invoker.deps)) {
deps += invoker.deps
} }
_deps = []
_deps = [ ":$_jacoco_target" ]
_previous_output_jar = _jacoco_output_jar
}
filter_jar("${target_name}_device") {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"java_files", "jar_excluded_patterns",
"java_sources_file", "jar_included_patterns",
"strip_resource_classes",
]) ])
deps = _deps
input_jar_path = _jacoco_input_jar input_jar = _previous_output_jar
output_jar_path = _jacoco_output_jar output_jar = invoker.device_jar_path
} inputs = []
if (defined(strip_resource_classes) && strip_resource_classes) {
_deps = [] inputs += [ invoker.build_config ]
_deps = [ ":$_jacoco_target" ] deps += [ invoker.build_config_dep ]
_previous_output_jar = _jacoco_output_jar args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
} }
if (!defined(invoker.host_jar_path) && defined(invoker.inputs)) {
_output_jar_target = "${target_name}__copy" inputs += invoker.inputs
deps += invoker.input_deps
# This is copy_ex rather than copy to ensure that JARs (rather than }
# possibly broken symlinks to them) get copied into the output
# directory.
copy_ex(_output_jar_target) {
forward_variables_from(invoker, [ "inputs" ])
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
} }
dest = _output_jar_path
sources = [ _previous_output_jar ]
outputs = [ _output_jar_path ]
}
group(target_name) {
forward_variables_from(invoker,
[
"data_deps",
"visibility",
])
public_deps = [ ":$_output_jar_target" ]
} }
} }
...@@ -3088,16 +3076,14 @@ if (enable_java_templates) { ...@@ -3088,16 +3076,14 @@ if (enable_java_templates) {
if (invoker.enable_errorprone) { if (invoker.enable_errorprone) {
# Our custom plugin pulls in the main errorprone dep transitively. # Our custom plugin pulls in the main errorprone dep transitively.
_errorprone_dep = _errorprone_dep = "//tools/android/errorprone_plugin:errorprone_plugin"
"//tools/android/errorprone_plugin:errorprone_plugin_java"
deps += [ _errorprone_dep ] deps += [ _errorprone_dep ]
_dep_gen_dir = get_label_info(_errorprone_dep, "target_gen_dir") _dep_gen_dir = get_label_info(_errorprone_dep, "target_gen_dir")
_dep_name = get_label_info(_errorprone_dep, "name") _dep_name = get_label_info(_errorprone_dep, "name")
_rebased_errorprone_buildconfig = _rebased_errorprone_buildconfig =
rebase_path("$_dep_gen_dir/$_dep_name.build_config", root_build_dir) rebase_path("$_dep_gen_dir/$_dep_name.build_config", root_build_dir)
args += [ args += [
"--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:jar_path)", "--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:host_classpath)",
"--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:javac_full_classpath)",
"--enable-errorprone", "--enable-errorprone",
] ]
} }
...@@ -3220,12 +3206,8 @@ if (enable_java_templates) { ...@@ -3220,12 +3206,8 @@ if (enable_java_templates) {
# java_files is empty. If not # java_files is empty. If not
# jar_path: Optional path to a prebuilt .jar file for this target. # jar_path: Optional path to a prebuilt .jar file for this target.
# Mutually exclusive with java_files and srcjar_deps. # Mutually exclusive with java_files and srcjar_deps.
# final_jar_path: Optional path to the final output .jar file (after # output_name: Optional output name for the final jar path. Used to
# processing). If not provided, the output will go under # determine the name of the final jar. Default is to use the same
# $root_build_dir/lib.java/
# output_name: Optional output name for the final jar path. Ignored if
# final_jar_path is provided. Otherwise, used to determine the name
# of the final jar. If not provided, the default is to use the same
# name as jar_path, if provided, or main_target_name. # name as jar_path, if provided, or main_target_name.
# main_class: Main Java class name for 'java_binary', 'junit_binary' and # main_class: Main Java class name for 'java_binary', 'junit_binary' and
# 'java_annotation_processor' target types. Should not be set for other # 'java_annotation_processor' target types. Should not be set for other
...@@ -3318,7 +3300,6 @@ if (enable_java_templates) { ...@@ -3318,7 +3300,6 @@ if (enable_java_templates) {
_is_annotation_processor = invoker.type == "java_annotation_processor" _is_annotation_processor = invoker.type == "java_annotation_processor"
_is_java_binary = _is_java_binary =
invoker.type == "java_binary" || invoker.type == "junit_binary" invoker.type == "java_binary" || invoker.type == "junit_binary"
_is_system_library = invoker.type == "system_java_library"
_supports_android = _supports_android =
defined(invoker.supports_android) && invoker.supports_android defined(invoker.supports_android) && invoker.supports_android
_requires_android = _requires_android =
...@@ -3379,6 +3360,8 @@ if (enable_java_templates) { ...@@ -3379,6 +3360,8 @@ if (enable_java_templates) {
"${_main_target_name}$build_config_target_suffix" "${_main_target_name}$build_config_target_suffix"
# The only target that might have no prebuilt and no sources is a java_binary. # The only target that might have no prebuilt and no sources is a java_binary.
_build_host_jar = false
_build_device_jar = false
if (_is_prebuilt || _has_sources) { if (_is_prebuilt || _has_sources) {
if (defined(invoker.output_name)) { if (defined(invoker.output_name)) {
_output_name = invoker.output_name _output_name = invoker.output_name
...@@ -3388,13 +3371,25 @@ if (enable_java_templates) { ...@@ -3388,13 +3371,25 @@ if (enable_java_templates) {
_output_name = _main_target_name _output_name = _main_target_name
} }
# Jar files can be needed at runtime (by Robolectric tests or java binaries), _build_host_jar = _is_java_binary || _is_annotation_processor ||
# so do not put them under obj/. invoker.type == "java_library"
_target_dir_name = get_label_info(":$_main_target_name", "dir") _build_device_jar =
_final_jar_path = invoker.type != "system_java_library" && _supports_android
"$root_out_dir/lib.java$_target_dir_name/$_output_name.jar" if (_build_host_jar) {
if (defined(invoker.final_jar_path)) { # Jar files can be needed at runtime (by Robolectric tests or java binaries),
_final_jar_path = invoker.final_jar_path # so do not put them under obj/.
# TODO(agrieve): I suspect it would be better to use dist_jar for java_binary
# rather than archiving unnecessary .jar files within lib.java.
_target_dir_name = get_label_info(":$_main_target_name", "dir")
_host_processed_jar_path =
"$root_out_dir/lib.java$_target_dir_name/$_output_name.jar"
}
if (_build_device_jar) {
_device_processed_jar_path =
"$target_out_dir/$_output_name.processed.jar"
_dex_path = "$target_out_dir/$_main_target_name.dex.jar"
_enable_desugar =
!defined(invoker.enable_desugar) || !invoker.enable_desugar
} }
# For static libraries, the javac jar output is created at the intermediate # For static libraries, the javac jar output is created at the intermediate
...@@ -3402,13 +3397,10 @@ if (enable_java_templates) { ...@@ -3402,13 +3397,10 @@ if (enable_java_templates) {
# spot that the .build_config knows about. Technically this should be done # spot that the .build_config knows about. Technically this should be done
# for the ijar as well, but this is only used for APK targets where # for the ijar as well, but this is only used for APK targets where
# the ijar path isn't actually used. # the ijar path isn't actually used.
_build_config_jar_path = _final_jar_path
_final_ijar_path = get_path_info(_final_jar_path, "dir") + "/" +
get_path_info(_final_jar_path, "name")
if (_has_sources) { if (_has_sources) {
_final_ijar_path += ".turbine.jar" _final_ijar_path = "$target_out_dir/$_output_name.turbine.jar"
} else { } else {
_final_ijar_path += ".ijar.jar" _final_ijar_path = "$target_out_dir/$_output_name.ijar.jar"
} }
if (_has_sources) { if (_has_sources) {
...@@ -3422,42 +3414,37 @@ if (enable_java_templates) { ...@@ -3422,42 +3414,37 @@ if (enable_java_templates) {
} else { } else {
_unprocessed_jar_path = _javac_jar_path _unprocessed_jar_path = _javac_jar_path
} }
if (_supports_android) {
_dex_path = "$target_out_dir/$_main_target_name.dex.jar"
}
} }
_java_header_deps = [] if (_is_prebuilt || _has_sources) {
_java_impl_deps = [] _java_header_deps = []
_non_java_deps = [] _java_impl_deps = []
if (defined(invoker.deps)) { _non_java_deps = []
foreach(_dep, invoker.deps) { if (defined(invoker.deps)) {
_target_label = get_label_info(_dep, "label_no_toolchain") foreach(_dep, invoker.deps) {
if (filter_exclude([ _target_label ], _java_library_patterns) == [] && _target_label = get_label_info(_dep, "label_no_toolchain")
filter_exclude([ _target_label ], _java_resource_patterns) != []) { if (filter_exclude([ _target_label ], _java_library_patterns) == [] &&
# This is a java dep, so replace it with its header. filter_exclude([ _target_label ], _java_resource_patterns) !=
_java_header_deps += [ "${_target_label}__header" ] []) {
_java_impl_deps += [ "${_target_label}__impl" ] # This is a java dep, so replace it with its header.
} else { _java_header_deps += [ "${_target_label}__header" ]
_non_java_deps += [ _dep ] _java_impl_deps += [ "${_target_label}__impl" ]
} else {
_non_java_deps += [ _dep ]
}
} }
} }
}
_extra_java_deps = [] # Don't need to depend on the apk-under-test to be packaged.
if (defined(invoker.apk_under_test)) {
# TODO(crbug.com/1078484): Don't use desugared .jar files for java binaries. _java_header_deps += [ "${invoker.apk_under_test}__java__header" ]
if (_is_java_binary && enable_bazel_desugar && _java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ]
(!defined(invoker.enable_desugar) || invoker.enable_desugar)) { }
_extra_java_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
}
if (_is_prebuilt || _has_sources) { _extra_java_deps = []
_jacoco_instrument = _jacoco_instrument =
use_jacoco_coverage && _chromium_code && _java_files != [] && use_jacoco_coverage && _chromium_code && _java_files != [] &&
!_is_java_binary && !_is_annotation_processor && _build_device_jar && (!defined(invoker.testonly) || !invoker.testonly)
(!defined(invoker.testonly) || !invoker.testonly)
if (defined(invoker.jacoco_never_instrument)) { if (defined(invoker.jacoco_never_instrument)) {
_jacoco_instrument = _jacoco_instrument =
!invoker.jacoco_never_instrument && _jacoco_instrument !invoker.jacoco_never_instrument && _jacoco_instrument
...@@ -3465,33 +3452,28 @@ if (enable_java_templates) { ...@@ -3465,33 +3452,28 @@ if (enable_java_templates) {
if (_jacoco_instrument) { if (_jacoco_instrument) {
_extra_java_deps += [ "//third_party/jacoco:jacocoagent_java" ] _extra_java_deps += [ "//third_party/jacoco:jacocoagent_java" ]
} }
}
# Don't need to depend on the apk-under-test to be packaged. _include_android_sdk = _build_device_jar
if (defined(invoker.apk_under_test)) { if (defined(invoker.include_android_sdk)) {
_java_header_deps += [ "${invoker.apk_under_test}__java__header" ] _include_android_sdk = invoker.include_android_sdk
_java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ] }
} if (_include_android_sdk) {
_sdk_java_dep = "//third_party/android_sdk:android_sdk_java"
if (defined(invoker.alternative_android_sdk_dep)) {
_sdk_java_dep = invoker.alternative_android_sdk_dep
}
_include_android_sdk = !_is_system_library && _supports_android # This is an android_system_java_prebuilt target, so no headers.
if (defined(invoker.include_android_sdk)) { _extra_java_deps += [ _sdk_java_dep ]
_include_android_sdk = invoker.include_android_sdk
}
if (_include_android_sdk) {
_sdk_java_dep = "//third_party/android_sdk:android_sdk_java"
if (defined(invoker.alternative_android_sdk_dep)) {
_sdk_java_dep = invoker.alternative_android_sdk_dep
} }
# This is an android_system_java_prebuilt target, so no headers. _classpath_deps = _java_header_deps + _non_java_deps + _extra_java_deps +
_extra_java_deps += [ _sdk_java_dep ] [ ":$_build_config_target_name" ]
_full_classpath_deps =
_java_impl_deps + _non_java_deps + _extra_java_deps +
[ ":$_build_config_target_name" ]
} }
_classpath_deps = _java_header_deps + _non_java_deps + _extra_java_deps +
[ ":$_build_config_target_name" ]
_full_classpath_deps = _java_impl_deps + _non_java_deps + _extra_java_deps +
[ ":$_build_config_target_name" ]
# Often needed, but too hard to figure out when ahead of time. # Often needed, but too hard to figure out when ahead of time.
not_needed([ not_needed([
"_classpath_deps", "_classpath_deps",
...@@ -3506,9 +3488,6 @@ if (enable_java_templates) { ...@@ -3506,9 +3488,6 @@ if (enable_java_templates) {
write_file(_java_sources_file, rebase_path(_java_files, root_build_dir)) write_file(_java_sources_file, rebase_path(_java_files, root_build_dir))
} }
_jetified_jar_path =
"$target_out_dir/${target_name}__process_prebuilt.jetified.jar"
write_build_config(_build_config_target_name) { write_build_config(_build_config_target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
...@@ -3564,10 +3543,14 @@ if (enable_java_templates) { ...@@ -3564,10 +3543,14 @@ if (enable_java_templates) {
} }
chromium_code = _chromium_code chromium_code = _chromium_code
build_config = _build_config build_config = _build_config
enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
is_prebuilt = _is_prebuilt is_prebuilt = _is_prebuilt
jetified_jar_path = _jetified_jar_path enable_jetify = defined(invoker.enable_jetify) && invoker.enable_jetify
possible_config_deps = _extra_java_deps jetified_jar_path = "$target_out_dir/${invoker.target_name}__process_prebuilt.jetified.jar"
possible_config_deps = []
if (defined(_extra_java_deps)) {
possible_config_deps = _extra_java_deps
}
if (defined(invoker.deps)) { if (defined(invoker.deps)) {
possible_config_deps += invoker.deps possible_config_deps += invoker.deps
} }
...@@ -3580,11 +3563,14 @@ if (enable_java_templates) { ...@@ -3580,11 +3563,14 @@ if (enable_java_templates) {
invoker.bypass_platform_checks invoker.bypass_platform_checks
if (_is_prebuilt || _has_sources) { if (_is_prebuilt || _has_sources) {
jar_path = _build_config_jar_path
ijar_path = _final_ijar_path ijar_path = _final_ijar_path
unprocessed_jar_path = _unprocessed_jar_path unprocessed_jar_path = _unprocessed_jar_path
} }
if (defined(_dex_path)) { if (_build_host_jar) {
host_jar_path = _host_processed_jar_path
}
if (_build_device_jar) {
device_jar_path = _device_processed_jar_path
dex_path = _dex_path dex_path = _dex_path
} }
if (_java_files != []) { if (_java_files != []) {
...@@ -3599,12 +3585,12 @@ if (enable_java_templates) { ...@@ -3599,12 +3585,12 @@ if (enable_java_templates) {
} }
if (defined(invoker.include_java_resources) && if (defined(invoker.include_java_resources) &&
invoker.include_java_resources) { invoker.include_java_resources) {
java_resources_jar = _unprocessed_jar_path
if (defined(invoker.jar_path)) { if (defined(invoker.jar_path)) {
# Use original jar_path because _jar_path points to a library without # Use original jar_path because _jar_path points to a library without
# resources. # resources.
java_resources_jar = invoker.jar_path
} else { } else {
java_resources_jar = _final_jar_path java_resources_jar = _device_processed_jar_path
} }
} }
} }
...@@ -3613,6 +3599,7 @@ if (enable_java_templates) { ...@@ -3613,6 +3599,7 @@ if (enable_java_templates) {
_header_target_name = "${target_name}__header" _header_target_name = "${target_name}__header"
} }
_public_deps = []
_analysis_public_deps = [] _analysis_public_deps = []
if (_has_sources) { if (_has_sources) {
if (defined(invoker.enable_errorprone)) { if (defined(invoker.enable_errorprone)) {
...@@ -3674,6 +3661,7 @@ if (enable_java_templates) { ...@@ -3674,6 +3661,7 @@ if (enable_java_templates) {
generated_jar_path = _generated_jar_path generated_jar_path = _generated_jar_path
deps = _annotation_processor_deps deps = _annotation_processor_deps
} }
_public_deps += [ ":$_header_target_name" ]
_compile_java_target = "${_main_target_name}__compile_java" _compile_java_target = "${_main_target_name}__compile_java"
compile_java_helper(_compile_java_target) { compile_java_helper(_compile_java_target) {
...@@ -3701,126 +3689,119 @@ if (enable_java_templates) { ...@@ -3701,126 +3689,119 @@ if (enable_java_templates) {
} }
} # _has_sources } # _has_sources
_public_deps = [] if (_is_prebuilt) {
if (_is_prebuilt || _has_sources) { generate_interface_jar(_header_target_name) {
if (_is_prebuilt) { # Always used the unfiltered .jar to create the interface jar so that
generate_interface_jar(_header_target_name) { # other targets will resolve filtered classes when depending on
# Always used the unfiltered .jar to create the interface jar so that # BuildConfig, NativeLibraries, etc.
# other targets will resolve filtered classes when depending on input_jar = _unprocessed_jar_path
# BuildConfig, NativeLibraries, etc. output_jar = _final_ijar_path
input_jar = _unprocessed_jar_path
output_jar = _final_ijar_path # ijar does not require classpath, but must declare these as deps so
# that they are transitive deps for targets that depend on this
# ijar does not require classpath, but must declare these as deps so # target. If we can change compile & desugar steps to use direct
# that they are transitive deps for targets that depend on this # interface classpath rather than full interface classpath, then this
# target. If we can change compile & desugar steps to use direct # could just be _non_java_deps.
# interface classpath rather than full interface classpath, then this deps = _classpath_deps
# could just be _non_java_deps. if (_has_sources) {
deps = _classpath_deps deps += [ ":$_compile_java_target" ]
if (_has_sources) {
deps += [ ":$_compile_java_target" ]
}
} }
} }
_public_deps += [ ":$_header_target_name" ] _public_deps += [ ":$_header_target_name" ]
}
if (_is_system_library) { if (_build_host_jar || _build_device_jar) {
# These deps are only needed for the process_java_prebuilt template. _process_prebuilt_target_name = "${target_name}_process"
not_needed([ "_java_impl_deps" ]) process_java_prebuilt(_process_prebuilt_target_name) {
forward_variables_from(invoker,
_copy_system_library_target_name = "${target_name}__copy_system_library" [
"enable_jetify",
# Use copy_ex rather than copy to ensure that we copy symlink targets "jar_excluded_patterns",
# rather than the symlink itself. "jar_included_patterns",
copy_ex(_copy_system_library_target_name) { ])
sources = [ _unprocessed_jar_path ] build_config = _build_config
dest = _final_jar_path build_config_dep = ":$_build_config_target_name"
outputs = [ _final_jar_path ] input_jar_path = _unprocessed_jar_path
jar_deps = _non_java_deps
if (_has_sources) {
jar_deps += [ ":$_compile_java_target" ]
} }
_public_deps += [ ":$_copy_system_library_target_name" ] if (_build_host_jar) {
} else { host_jar_path = _host_processed_jar_path
_enable_desugar = (!defined(invoker.enable_desugar) || }
!invoker.enable_desugar) && _supports_android if (_build_device_jar) {
_process_prebuilt_target_name = "${target_name}__process_prebuilt" device_jar_path = _device_processed_jar_path
process_java_prebuilt(_process_prebuilt_target_name) {
forward_variables_from(invoker,
[
"enable_jetify",
"jar_excluded_patterns",
"jar_included_patterns",
])
enable_desugar = _enable_desugar && enable_bazel_desugar
build_config = _build_config
input_jar_path = _unprocessed_jar_path
jacoco_instrument = _jacoco_instrument jacoco_instrument = _jacoco_instrument
if (_jacoco_instrument) { if (_jacoco_instrument) {
java_files = _java_files java_files = _java_files
java_sources_file = _java_sources_file java_sources_file = _java_sources_file
} }
output_jar_path = _final_jar_path enable_desugar = _enable_desugar && enable_bazel_desugar
if (enable_desugar) {
classpath_deps = _full_classpath_deps
}
}
# proguard_configs listed on java_library targets need to be marked
# as inputs to at least one action so that "gn analyze" will know
# about them. Although ijar doesn't use them, it's a convenient spot
# to list them.
# https://crbug.com/827197
if (defined(invoker.proguard_configs)) {
inputs = invoker.proguard_configs
input_deps = _non_java_deps + _srcjar_deps # For the aapt-generated
# proguard rules.
}
}
if (_build_host_jar) {
_public_deps += [ ":${_process_prebuilt_target_name}_host" ]
}
if (_build_device_jar) {
_public_deps += [ ":${_process_prebuilt_target_name}_device" ]
}
if (!defined(invoker.enable_bytecode_checks) ||
invoker.enable_bytecode_checks) {
_bytecode_checks_target = "${target_name}__validate_classpath"
bytecode_processor(_bytecode_checks_target) {
forward_variables_from(invoker, [ "missing_classes_allowlist" ])
deps = _full_classpath_deps deps = _full_classpath_deps
if (_has_sources) { if (_has_sources) {
deps += [ ":$_compile_java_target" ] deps += [ ":$_compile_java_target" ]
} }
requires_android = _requires_android
# proguard_configs listed on java_library targets need to be marked target_label =
# as inputs to at least one action so that "gn analyze" will know get_label_info(":${invoker.target_name}", "label_no_toolchain")
# about them. Although ijar doesn't use them, it's a convenient spot input_jar = _unprocessed_jar_path
# to list them. build_config = _build_config
# https://crbug.com/827197 is_prebuilt = _is_prebuilt
if (defined(invoker.proguard_configs)) {
inputs = invoker.proguard_configs
if (!defined(deps)) {
deps = []
}
deps += _srcjar_deps # For the aapt-generated proguard rules.
}
} }
_public_deps += [ ":$_process_prebuilt_target_name" ] _analysis_public_deps += [ ":$_bytecode_checks_target" ]
}
if (defined(_dex_path)) { }
dex("${target_name}__dex") {
input_class_jars = [ _final_jar_path ]
enable_desugar = _enable_desugar
# There's no value in per-class dexing prebuilts since they never if (_build_device_jar) {
# change just one class at a time. dex("${target_name}__dex") {
disable_incremental = _is_prebuilt input_class_jars = [ _device_processed_jar_path ]
output = _dex_path enable_desugar = _enable_desugar
deps = [ ":$_process_prebuilt_target_name" ]
if (enable_desugar && !enable_bazel_desugar) { # There's no value in per-class dexing prebuilts since they never
# Desugaring with D8 requires full classpath. # change just one class at a time.
build_config = _build_config disable_incremental = _is_prebuilt
final_ijar_path = _final_ijar_path output = _dex_path
deps += _classpath_deps + [ ":$_header_target_name" ] deps = [ ":${_process_prebuilt_target_name}_device" ]
}
enable_multidex = false if (enable_desugar && !enable_bazel_desugar) {
is_library = true # Desugaring with D8 requires full classpath.
} build_config = _build_config
_public_deps += [ ":${target_name}__dex" ] final_ijar_path = _final_ijar_path
} deps += _classpath_deps + [ ":$_header_target_name" ]
if (!defined(invoker.enable_bytecode_checks) ||
invoker.enable_bytecode_checks) {
_bytecode_checks_target = "${target_name}__validate_classpath"
bytecode_processor(_bytecode_checks_target) {
forward_variables_from(invoker, [ "missing_classes_allowlist" ])
deps = _full_classpath_deps
if (_has_sources) {
deps += [ ":$_compile_java_target" ]
}
requires_android = _requires_android
target_label =
get_label_info(":${invoker.target_name}", "label_no_toolchain")
input_jar = _unprocessed_jar_path
build_config = _build_config
is_prebuilt = _is_prebuilt
}
_analysis_public_deps += [ ":$_bytecode_checks_target" ]
} }
enable_multidex = false
is_library = true
} }
_public_deps += [ ":${target_name}__dex" ]
} }
if (_is_java_binary) { if (_is_java_binary) {
...@@ -4098,7 +4079,7 @@ template("dexsplitter") { ...@@ -4098,7 +4079,7 @@ template("dexsplitter") {
"--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)", "--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)",
] ]
if (!defined(invoker.feature_jars_args)) { if (!defined(invoker.feature_jars_args)) {
args += [ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:java_runtime_classpath)" ] args += [ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:device_classpath)" ]
} }
deps += [ _feature_module.build_config_target ] deps += [ _feature_module.build_config_target ]
} }
......
...@@ -1624,7 +1624,7 @@ if (enable_java_templates) { ...@@ -1624,7 +1624,7 @@ if (enable_java_templates) {
} else if (_use_unprocessed_jars) { } else if (_use_unprocessed_jars) {
args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)" ] args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)" ]
} else { } else {
args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ] args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:device_classpath)" ]
} }
} }
_excludes = [] _excludes = []
...@@ -2139,8 +2139,7 @@ if (enable_java_templates) { ...@@ -2139,8 +2139,7 @@ if (enable_java_templates) {
template("android_apk_or_module") { template("android_apk_or_module") {
forward_variables_from(invoker, [ "testonly" ]) forward_variables_from(invoker, [ "testonly" ])
assert(defined(invoker.android_manifest)) assert(defined(invoker.android_manifest))
_out_dir = "$target_out_dir/$target_name" _base_path = "$target_out_dir/$target_name/$target_name"
_base_path = "$_out_dir/$target_name"
_build_config = "$target_gen_dir/$target_name.build_config" _build_config = "$target_gen_dir/$target_name.build_config"
_build_config_target = "$target_name$build_config_target_suffix" _build_config_target = "$target_name$build_config_target_suffix"
...@@ -2153,9 +2152,6 @@ if (enable_java_templates) { ...@@ -2153,9 +2152,6 @@ if (enable_java_templates) {
_target_sdk_version = invoker.target_sdk_version _target_sdk_version = invoker.target_sdk_version
} }
# JUnit tests use resource zip files. These must not be put in gen/
# directory or they will not be available to tester bots.
_jar_path = "$_base_path.jar"
_template_name = target_name _template_name = target_name
_is_bundle_module = _is_bundle_module =
...@@ -2352,8 +2348,7 @@ if (enable_java_templates) { ...@@ -2352,8 +2348,7 @@ if (enable_java_templates) {
_is_static_library_provider = _is_static_library_provider =
defined(invoker.static_library_dependent_targets) && _proguard_enabled defined(invoker.static_library_dependent_targets) && _proguard_enabled
if (_is_static_library_provider) { if (_is_static_library_provider) {
_static_library_sync_dex_path = _static_library_sync_dex_path = "$_base_path.synchronized.r8dex.jar"
"$_out_dir/static_library_synchronized_proguard.r8dex.jar"
_resource_ids_provider_deps = [] _resource_ids_provider_deps = []
foreach(_target, invoker.static_library_dependent_targets) { foreach(_target, invoker.static_library_dependent_targets) {
if (_target.is_resource_ids_provider) { if (_target.is_resource_ids_provider) {
...@@ -2800,7 +2795,6 @@ if (enable_java_templates) { ...@@ -2800,7 +2795,6 @@ if (enable_java_templates) {
supports_android = true supports_android = true
requires_android = true requires_android = true
srcjar_deps = _srcjar_deps srcjar_deps = _srcjar_deps
final_jar_path = _jar_path
if (defined(_final_dex_path)) { if (defined(_final_dex_path)) {
final_dex_path = _final_dex_path final_dex_path = _final_dex_path
} }
...@@ -2932,7 +2926,8 @@ if (enable_java_templates) { ...@@ -2932,7 +2926,8 @@ if (enable_java_templates) {
main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath_extended)" main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath_extended)"
} }
} else { } else {
input_classes_filearg = "@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" input_classes_filearg =
"@FileArg($_rebased_build_config:deps_info:device_classpath)"
} }
if (_is_static_library_provider) { if (_is_static_library_provider) {
......
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
java_library("errorprone_plugin_java") { java_binary("errorprone_plugin") {
# main_class and wrapper script are not actually used.
# This target is referenced directly from java_library_impl().
main_class = "<ignore>"
wrapper_script_name = "bin/helper/errorprone_plugin"
sources = [ sources = [
# Turned off because of existing code which fails the check # Turned off because of existing code which fails the check
# "src/org/chromium/tools/errorprone/plugin/NoContextGetApplicationContext.java", # "src/org/chromium/tools/errorprone/plugin/NoContextGetApplicationContext.java",
...@@ -21,9 +25,6 @@ java_library("errorprone_plugin_java") { ...@@ -21,9 +25,6 @@ java_library("errorprone_plugin_java") {
enable_errorprone = false enable_errorprone = false
enable_bytecode_checks = false enable_bytecode_checks = false
# So that we don't need to inject jacoco runtime into the compiler's classpath.
jacoco_never_instrument = true
annotation_processor_deps = annotation_processor_deps =
[ "//third_party/android_deps:auto_service_processor" ] [ "//third_party/android_deps:auto_service_processor" ]
deps = [ deps = [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment