summaryrefslogtreecommitdiff
path: root/java/java.go
AgeCommit message (Collapse)Author
2024-01-30Support mechanism to select a specific version of module sdk prebuilt Spandan Das
This CL is the java_(test_)_import equivalent of aosp/2928483. With trunk stable, we will have multiple prebuilts of the prebuilt java .jars in prebuilts/module_sdk/art/<v>/test-exports/, and this CL introduces a mechanism to use apex_contributions to select a specific versioned prebuilt when building. Implementation details: Create a new source_module_name property to identify the root module. rdeps referring to the root module will get redirected if necessary. This property also becomes the stem, if `stem` is not set explicitly. Bug: 322175508 Test: Added a unit test Change-Id: I2dff38acdf2002355586dbb2be8c1f98af4741f7
2024-01-26Merge "Fix the args used to dexpreopt system server jars in prebuilt apexes" ↵ Treehugger Robot
into main
2024-01-26Fix the args used to dexpreopt system server jars in prebuilt apexes Spandan Das
For prebuilts, java.dexpreopt gets called twice 1. in the context of the top-level prebuilt apex 2. in the context of the java_library shim Only the artifacts of (1) get installed. The artifacts generated by 2) are unused. However the args used to generate the artifacts of (1) are incorrect. It uses moduleName(ctx) to do special-handling of apex system server jars. This special-handling does not happen in (1), so although dexpreopt artficats get generated, they get generated with the wrong args. To fix this, add an additional parameter in java.dexpreopt to pass the libraryName explicitly. Details - Delete moduleName function. This was used to determine the java library name, which is no longer safe - Add a libraryName parameter to java.dexpreopt - Most module types will use j.Name() as libraryName - prebuilt_apex and apex_set will iterate over its `contents` and use each element as libraryName when invoking java.dexpreopt With the correct args passed from (1), we can drop j.dexpreopt from (2) completely. Dropping (2) also breaks profile guided dexpreopt tests. These currently operate on (2). They will be moved to (1) in the next CL of this stack. Test: presubmits Test: lunch cf_x86_64_auto-trunk_staging-userdebug && m nothing (this was a postsubmit failure with aosp/2923733) Test: art_standalone_dexpreopt_tests on next https://android-build.corp.google.com/builds/abtd/run/L86000030001579256 Test: art-gtest on git_master-art-host https://android-build.corp.google.com/builds/abtd/run/L07800030001550262 Bug: 308790457 Bug: 322255144 Change-Id: I8eb604c82f1fa5289d3cd1a20084d56e4d7485e3
2024-01-24Convert coverageMutator to a TransitionMutator Colin Cross
Convert coverageMutator to a TransitionMutator as a step towards variants-on-demand. Bug: 319288033 Test: coverage_test.go Test: treehugger coverage builds Change-Id: Ic50c0040dea8b42c36b5d784221daa00b7b0d379
2024-01-18Merge "Add better error handling to bootDexJar function" into main Treehugger Robot
2024-01-17Add better error handling to bootDexJar function Spandan Das
aosp/2876754 missed adding error handling to one of the places which consumes the dex jar deapexed from prebuilt apexes. This CL ensures that when we have multiple prebuilt apexes _without_ flagging, the hiddenapi processing code emits a more descriptive error "Multiple deapxers..." rather than a cryptic error "<module> does not provide a dex jar" Test: m nothing --no-skip-soong-tests Change-Id: I80849fa7cca17d724ac53c94bb353b169175ee28
2024-01-16Merge "Implicitly bump up Java target to 1.8" into main Treehugger Robot
2024-01-15Implicitly bump up Java target to 1.8 Sorin Basca
Bug: 320294595 Test: m Change-Id: I693e564c67d17254d68f3a9c16664c1da93b9488
2024-01-12Add defaults support for bootclasspath_fragment module type Jihoon Kang
This change transforms the bootclsspath_fragment module into a defaultable module, in order to modify the "art-bootclasspath-fragment" module definition based on the build flag in https://r.android.com/2897389 Test: m nothing Bug: 315027929 Change-Id: I01ba7b15e4fcdea9bd31c369110a3c9ee38bc9f6
2024-01-10Merge "Replace panic with ModuleErrorf" into main Treehugger Robot
2024-01-09Replace panic with ModuleErrorf Spandan Das
This is a followup cleanup for aosp/2876754 and replaces panic with ctx.ModuleErrorf. The latter creates a more expressive build error. Implementation details - export moduleErrorf interface from build/soong/android. This minimal interface will be used as a parameter for `DexJarBuildPath` - Add ModuleErrorf to the function signature of DexJarBuildPath. This parameter only gets used for Import and SdkLibraryImport structs. These two can have duplicate deapexer definitions, and ModuleErrorf will be used to report that error - Create a minimal implementation of `ModuleErrorf` in tests of java and apex Test: m nothing --no-skip-soong-tests Change-Id: I0febec651f40c3f04deb957e64133c94b80fbd78
2024-01-08Add aconfig_declarations property to droidstubs and java_sdk_library Jihoon Kang
In consideration of the incremental build performance, this change let droidstubs and java_sdk_library (which generates droidstubs per api scope) modules to specify `aconfig_declaration` modules where the dependent flags are defined in via the "aconfig_declarations" property, opposed to passing uniform "all_aconfig_declaration"-generated flag arguments to metalava. When "aconfig_declarations" property is defined for java_sdk_library modules, the property is passed to the generated droidstubs modules. When "aconfig_declarations" property is defined for droidstubs modules, the all aconfig_declaration modules listed in the property are listed as deps, all cache protobuf files are gathered and metalava-consumable flags are generated in "revert-annotations.txt". Although this change introduces scalable implementation to easily support generation of the "runtime" stubs corresponding flags, actual support of the runtime flags/stubs will be done in future changes. This change mostly focuses on the generation of the "exportable" flags. Utilization of the generated "exportable" flags will be done in future changes. Test: go test ./java Bug: 315485740 Change-Id: I37becd1b9dd9069d7ac4abed130906df30b3fdf4
2023-12-20Use the correct bootjars when multiple prebuilt apexes exist Spandan Das
hiddenapi and dexpreopt require boot and system server jars from apexes. When building with prebuilts, this comes via java_import/java_sdk_library_import, which acts as a hook for prebuilt_apex/apex_set. If we have multiple apexes in the tree, this hook becomes 1:many. This CL prepares dex_bootjars to select the right deapexerd .jar files when mutliple prebuilts exist. Implementation details - Update prebuilt module types (prebuilt_apex/apex_set) and source apexes to set a map of library name to dex jar path on host. - dex_bootjars will access the path of the .dex jar on host via the provider. These then copied/installed to the right locations. This CL does not drop the old mechanism to get the dex file (i.e. by creating a dep on java_library). Once all mainline modules have been flagged using apex_contributions, the old mechanism will be dropped Bug: 308790457 Test: git_master-art-host:art-gtest https://android-build.corp.google.com/builds/abtd/run/L21500030000926533 Test: git_main:art_standalone_dexpreopt_tests https://android-build.corp.google.com/builds/abtd/run/L99000030000891212 Test: Added a unit test that checks that the right .jar is selected when multiple prebuilts exists Change-Id: I6ef94135b9303a35135810930af4b641df13a583
2023-12-18Move validation from FindDeapexerProviderForModule to rdeps Spandan Das
FindDeapexerProviderForModule raises an exception if multiple apexes in the tree has an export dep on the java module. In prepartation to support multiple prebuilts, move this error check out of FindDeapexerProviderForModule and into rdeps. i.e. raise an exception only if an rdep calls DexJarBuildPath - This should be a no-op for now. - In the short-term future, a java import module will be allowed to have multiple deapexers. An error will be raised if anyone actually tries to depend on the dexjar - In the long-term future, this function will be removed. All processing will be done at the prebuilt apex level and not at the prebuilt java library level Since this check now happens in the moduleCtx of rdeps, add some additional props to unit tests to ensure that it does not exit early on unrelated validation checks (e.g. hidden_api prop is not set) Test: go test ./apex ./java Bug: 308790457 Change-Id: I3323d993c1ea8f43305834cae8e65b6fe41dfefd
2023-12-14Convert OtherModuleProvider to generic providers API Colin Cross
Convert all of the callers of OtherModuleProvider/OtherModuleHasProvider to use the type-safe android.OtherModuleProvider API. Bug: 316410648 Test: builds Change-Id: Id77f514d68761a262d9ea830a601dbed804bbbe5
2023-12-14Convert Provider to generic providers API Colin Cross
Convert all of the callers of Provider/HasProvider to use the type-safe android.ModuleProvider API. Bug: 316410648 Test: builds Change-Id: I73479de1625fa2865b6c73444cd477e50d56dc5a
2023-12-14Convert SetProvider to generic providers API Colin Cross
Convert all of the callers of SetProvider to use the type-safe android.SetProvider API. Bug: 316410648 Test: builds Change-Id: If58f4b5355264ddab2045bc3591a4eac19cd58fc
2023-12-14Convert NewProvider/NewMutatorProvider to generic providers API Colin Cross
Convert all of the callers to NewProvider and NewMutatorProvider to use a generic type parameter instead of an example object. Bug: 316410648 Test: builds Change-Id: Ic9cdafc87336e26730d3fd596df05de0e7267542
2023-12-08Remove ConvertWithBp2build implementations Colin Cross
Remove the ConvertWithBp2build implementations from all the module types, along with the related code. Bug: 315353489 Test: m blueprint_tests Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-07Add aconfig flag support for android_app Jihoon Kang
This change adds an overrideable property flags_packages to android_app, which is used to list the aconfig_declarations module names that the app depends on. The build action of android_app is modified to pass all flags text file provided by the aconfig_declarations to aapt2 link as --feature-flags arguments. Test: m nothing --no-skip-soong-tests Bug: 306024510 Change-Id: I4924f88b9954950cc1936a472cd7ac70f41add5d
2023-11-30Merge "Add container property to aconfig_declarations." into main Yu Liu
2023-11-29Don't write transitive dependencies to Android-${TARGET_PRODUCT}.mk Colin Cross
Java libraries were writing lists of files that changed whenever transitive dependencies changed to Android-${TARGET_PRODUCT}.mk, causing Kati analysis to rerun whenever a dependency was changed in Soong. In both cases, Make would immediately use the list to write a single output file. Write the files in Soong and pass the path to the file to Make instead, which will both reduce the size of Android-${TARGET_PRODUCT}.mk and skip Kati analysis more often. Bug: 309006256 Test: m checkbuild Change-Id: I5dff16c6fb7cca8c6da927b37c612c7b1d0954e6
2023-11-28Add container property to aconfig_declarations. Yu Liu
Bug: 311155208 Test: Unit test Change-Id: I7b187138856d0144203961e82b6dad5e2f8eed9d
2023-11-17Change deps of ctx.Install* from Paths to InstallPaths Colin Cross
Installed files should only depend on other installed files, change the deps arguments of the ctx.Install* methods from Paths to InstallPaths. Bug: 311428265 Test: builds Change-Id: I1ebef60a943bdbe907744cc43aa985371ac56d32 Merged-In: I1ebef60a943bdbe907744cc43aa985371ac56d32
2023-11-15Merge "Stop collecting path entry for module_bp_java_deps.json from each ↵ Colin Cross
module type" into main
2023-11-15Stop collecting path entry for module_bp_java_deps.json from each module type Colin Cross
The jdepsGeneratorSingleton can get the module path directly, it doesn't need to be collected by each module type that implements IDEInfo. Fixes module types (like android_library) that didn't reach the code that collected the path. Bug: 309835196 Test: out/soong/module_bp_java_deps.json contains path for ExtServices.core Change-Id: If8cb81b4f708e0367f156ade164bee253bf53492
2023-11-15Add proto for Test ownership metadata. Aditya Choudhary
This Cl adds a new rule to Soong to generate test spec metadata. Also, this CL adds a provider in various test module to provide test spec related data to the Soong rule. Will add providers and test code to other Module in the future changes. Provider added for the following test modules in this change: android_robolectric_test, android_test, bootclasspath_fragment_test, java_test, java_test_host, python_test, python_test_host, sh_test,and sh_test_host. Bug: 296873595 Change-Id: I5f89f72d5874bb7838ae357efdb8c6ca208e18a7
2023-11-01Merge "Add the name of the sdk library to dynamically generated java ↵ Spandan Das
modules" into main
2023-10-31Add the name of the sdk library to dynamically generated java modules Spandan Das
The name of the sdk library will be used in source vs prebuilt selection. For soong modules that are not dynamically created from a java_sdk_library, the value will be nil. Bug: 308174768 Test: TH Change-Id: Ic7e9889f00c6184992b663a7124967bb0794d475
2023-10-31transitive r8 flags for installable {android,java}_libraries Sam Delmerico
Only android_apps were actually applying transitive proguard flags files to their r8 invocation. This CL ensures that this also occurs for installable android_libraries and java_libraries. Bug: 302342049 Test: go test ./java Change-Id: Ie94d688d04367ee3d39e7e760fb3003df5829951
2023-10-18Merge changes from topic "revert-2786699-import-sdk-version-none-WYNCDQGHTE" ↵ Treehugger Robot
into main * changes: Revert "Don't use java_library for java_import neverlink" Revert "Do not convert sdk_version: "none""
2023-10-18Merge "Shard Javac" into main Treehugger Robot
2023-10-18Revert "Don't use java_library for java_import neverlink" Liz Kammer
Revert submission 2786699-import-sdk-version-none Reason for revert: b/306220520 Reverted changes: /q/submissionid:2786699-import-sdk-version-none Change-Id: I4fbe5fa54dc11fac898a7f15704833f01b9fa269
2023-10-18Revert "Do not convert sdk_version: "none"" Liz Kammer
Revert submission 2786699-import-sdk-version-none Reason for revert: b/306220520 Reverted changes: /q/submissionid:2786699-import-sdk-version-none Change-Id: I309e269db70d9fedaf010ef44791516392fcb4ea
2023-10-18Shard Javac usta
Test: m nothing Test: allowlist frameworks/opt/calendar to bp2build convert Test: add `javac_shard_size: 2` to calendar-common Test: b //frameworks/opt/calendar:calendar-common Bug: 297356812 Change-Id: Ie22bcf04946f3945952a74a46772b777b1522b70
2023-10-17Do not convert sdk_version: "none" Liz Kammer
These also require system_modules to be set. Wait until we convert system_modules to convert sdk_version: "none" Test: CI Change-Id: I5bbdcb6819709a7c5a7932cb860a0de945f3528e
2023-10-17Don't use java_library for java_import neverlink Liz Kammer
Restricting use of sdk_version = "none" to only the rule types that will correctly handled sdk_version = "none" by also handling system_module attr Test: CI && go tests Change-Id: Ifa1c60ba8f5e3fcb28986cc84cdfaedcbd2d2957
2023-10-16Merge changes from topic "stub_validation" into main Jihoon Kang
* changes: Add current api check as validation for from-text stub generation Disable full_api_surface_stubs for some java_api_library modules
2023-10-13Add current api check as validation for from-text stub generation Jihoon Kang
Currently, there is no build action ensuring that the API text files are up to date, unless a user runs `m checkapi` or `m update-api`. This means that the user must run `m update-api` after making a change that modifies api surface(s), so that the API text file reflects the local change. This adds additional layer of action to developers, and it is not guaranteed that the developer will always run `m update-api` after making an api surface-affecting changes. To prevent such mistake, this change adds droidstub-level api check as validation for from-text stub generation. With this change, the build will fail if the API text file is not up to date and the user must run `m update-api` when making api surface-affecting local changes. The validation is done by adding all droidstubs modules associated with the java_api_contributions passed to java_api_library via `api_contributions` as dependency and setting the current api timestamp files as the validations for the from-text stubs generating build rule. The full api surface libraries will not run the validations to avoid circular dependency. However, all java_sdk_library generated java_api_library modules will run validations, mapped to the droidstubs in the same api domaion. If the user sets the environment variable `DISABLE_STUB_VALIDATION=true`, validation actions are not run. Validation actions run by default. Test: m nothing --build-from-text-stub and run ninja query to verify `check_current_api.timestamp`s are listed as validation \ DISABLE_STUB_VALIDATION=true m nothing --build-from-text-stub and run ninja query to verify that validation actions are not added Bug: 288624417 Change-Id: I329e6438fe8f3ac30d8c6a971d57853ed6b0d150
2023-10-12Handle java_resources as deps Liz Kammer
Test: CI && unit tests Change-Id: I51f3c7d876c3cc25cb0459d933e1a510cfb5bf13
2023-10-12Change openjdk9 specific props in bp2build/Soong Liz Kammer
JDK17 is the default java version, adding these props conditionally openjdk9 is no longer relevant Test: CI Change-Id: I5d80fd22f474cedf389d1e295620cfc17bc327a0
2023-10-11Merge "Change java_test_host to support cov variant." into main Yu Liu
2023-10-10Change java_test_host to support cov variant. Yu Liu
Bug: 279960392 Test: CI and m --skip-soong-tests TARGET_PRODUCT=aosp_x86_64 EMMA_INSTRUMENT=true CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="external/cronet" mts Change-Id: I4489ed725aee6097e6e340f5f6d06ecaf1c64222
2023-10-09Introduce system_modules property to java_api_library Jihoon Kang
System_modules property provides the jars passed as bootclasspath when compiling the stubs in the java_api_library where its creating java_sdk_library's sdk_version is none, as the jars will not be provided from the full_surface_stub_libs but compiled by itself in the child change. The jar provided by the system_modules will also be passed to metalava to resolve hierarchy coming from outer dependencies. Test: m --build-from-text-stub Bug: 288624417 Change-Id: I8f3b89efa24bceb070d7a37fae3c7334dd7f0868
2023-09-28Collect transitive source files for java modules Anton Hansson
This new entry in the JavaInfoProvider lists all the transitive source files contained within the library. That is, the source files of the module and all its static dependencies. Bug: 151360309 Test: unit test in java_go + some manual testing Change-Id: I7fe3035b9e46774095c0e9196cd77fa1027adf6d
2023-09-25Merge changes from topics "remove_api_files", "remove_naming_convention" ↵ Jihoon Kang
into main * changes: Remove naming conventioned based file sorting in java_api_library Remove api_files property from java_api_library
2023-09-22Pass java_library libs and static_libs to java_*_proto_library Zi Wang
If a java_library module has proto srcs, a java_*_proto_library target will be created for it. Proto sources are generated and then compiled by a java_library target. We need to pass the libs and static_libs of the java_library module to this java_library target so that the compile-time classpath is correct. Test: updated unit tests and CI Bug: 301469542 Change-Id: I05b2efce6fda2223e85728b3c4c7b1815d04c3dd
2023-09-22Remove naming conventioned based file sorting in java_api_library Jihoon Kang
With api_files property being removed from java_api_library, all api files are passed to java_api_library via java_api_contribution, which provide api_surface information. Instead of relying on the naming convention of the api files, java_api_library can utilize this information to sort the api files from narrower api scope to the wider api scope. Test: m --build-from-text-stub Bug: 295429988 Change-Id: Idd832778833c072c6b7e9d1f775533e5f4e2af00
2023-09-21Remove api_files property from java_api_library Jihoon Kang
java_api_contribution provides api_surface information, but files directly passed to java_api_library do not possess such information. Currently, the api surface is assumed via naming convention for api files passed via api_files property, but this is fragile. This change removes the api_files property from java_api_library and enforce all api files to be passed via java_api_contribution Test: m nothing --build-from-text-stub Bug: 300964421 Change-Id: If01d9ed978fe469d4ee0d685582a51629ebecc56
2023-09-20Have ConvertWBp2build use Bp2buildMutatorContext Chris Parsons
This no-op refactoring facilitates some upcoming functional changes for "bp2build allowlist v2". The work requires that the bp2build conversion mutator be changed from a TopDown mutator to a BottomUp mutator. Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext makes it easier to make this functional change without touching tens of files and multiple projects. Bug: 285631638 Test: m bp2build Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2