summaryrefslogtreecommitdiff
path: root/java/java.go
AgeCommit message (Collapse)Author
2024-10-04Add JNI libs support to device variants of java_binary Spandan Das
This adds jni_libs support back to device variants, which was removed in https://r.android.com/3230584. These will be installed by the two packaging systems in different ways 1. Kati: By being listed in `LOCAL_REQUIRED_MODULES` of the autogenerated Android.mk 2. Soong: Via the`jniInstallTag`, whose `InstallDepNeeded` value is true This CL also makes it an error for a native library to be listed in `required` of a `java_binary(_host)`. Test: m nothing --no-skip-soong-tests Test: Verified that there are no diff in system_intermediates/file_list.txt (device variants) Test: m installclean && m <host_java_bin> ; verified that the jni library is installed in out/host/linux-x86/lib64 (host variants) Bug: 370110572 Change-Id: I6aebc648191ab39f2da15a5f2807d46abab22cb0
2024-09-30Merge "Make the java jni_libs property configurable" into main Treehugger Robot
2024-09-30Make the java jni_libs property configurable Jihoon Kang
Bug: 323382414 Bug: 370563864 Test: m nothing --no-skip-soong-tests Change-Id: I11d8350d338e44d27537c6e5529034ba8a38265c
2024-09-27Merge "Remove top down strict updatability checks" into main Colin Cross
2024-09-26Merge "Remove the SdkLibraryDependency interface" into main Treehugger Robot
2024-09-26Remove top down strict updatability checks Colin Cross
The enforce_strict_updatability_linting and apex_strict_updatability_lint are some of the last top down mutators, and removing them will help with incremental analysis. Both mutators are used to propagate a flag to transitive java dependencies that causes them to add extra checks to their lint rules to require that baselines not include any skipped NewApi checks. Instead of modifying dependencies to check the baselines, propagate the baselines up to the modules that are requesting the checks, and perform the checks on all transitive baselines there. Bug: 367784740 Test: TestJavaLintStrictUpdatabilityLinting Test: TestApexStrictUpdtabilityLint Flag: EXEMPT refactor Change-Id: Ief2e3b26d745da61f13e621d635a5879d9c56779
2024-09-26Merge "Use providers for lint" into main Colin Cross
2024-09-26Remove the SdkLibraryDependency interface Jihoon Kang
Instead, provide the information of the source/prebuilt java_sdk_library to the rdeps via the SdkLibraryInfoProvider. Test: m nothing --no-skip-soong-tests && diff ninja file Bug: 348040422 Change-Id: If6cd3cd260a8ce8dccead7f302840cabf68a9fae
2024-09-25Use providers for lint Colin Cross
Bug: b/348040422 Test: lint_test.go Flag: EXEMPT refactor Change-Id: I420bee2c7056a3f4acee3af5955f79c504ea61d9
2024-09-23Merge changes I0edb681b,I0ea2327f into main Spandan Das
* changes: Remove internal deapexer module Remove deapex support from java_*_import
2024-09-20Remove deapex support from java_*_import Spandan Das
prebuilt_apex/apex_set currently supports its deapexed contents to be returned via a sibling java_import/java_sdk_import module. This is necesssary for 1. dexpreopt/hiddenapi processing 2. usage as shared library (1) is no longer necessary. this information is provided by the top-level prebuilt apexes now (2) is no longer possible since `exported_java_libs` has been removed in https://r.android.com/3272110 This CL uses a hack for java_sdk_library_improt. Even though (1) is provided by the top-level apex, there are still some places where dexpreopt/hiddenapi processing visits the import modules. This CL uses a bogus path to make analysis work. If this bogus path gets used, there will be an error during ninja execution Test: go test ./apex Test: in internal lunch cf_x86_64_phone-next-userdebug (uses mainline prebuilts) Test: verified that file_list.txt is same Bug: 368337090 Change-Id: I0ea2327f648f0fc60e337b232f7265e140772ffd
2024-09-20Revert^2 "Restrict java_sdk_library in libs of java_import and droidstubs ↵ Jihoon Kang
modules" These are all remaining usages of "magic", which are being removed with this change. The follow up change will remove the "magic". Test: m nothing --no-skip-soong-tests Bug: 366069293 Change-Id: If432cdc6621ac00564e14acbaefca53db1723686
2024-09-18Align CLC add context behavior between java_sdk_library and its impl lib Jihoon Kang
This change allows the impl lib of java_sdk_library to call AddContext(...) instead of AddContextMap(...) and ensure that the behavior between the top level java_sdk_library and the impl lib is identical when creating the class loader context. Test: CI && ABTD Bug: 366572133 Change-Id: Ia0bc7558ca737fcd3ad4ed62b3190aa567aa103f
2024-09-12Merge changes from topic "kotlin_kythe" into main Spandan Das
* changes: Add kotlin kzips to build_kzip.bash Create .kzip files for kotlin translation units
2024-09-11Create .kzip files for kotlin translation units Spandan Das
This CL creates the build rules to invoke the standalone kotlin extractor and create .kzip files for each kotlin translation unit. These will be indexed by the internal g3 kotlin indexers Implementation details - Create a `kotlinKytheExtract` static rule. Its inputs will be source .kt/.srcjar files and other verbatim args passed to kotlinc. The extrator will serialize this information into a .kzip file. The .kzip file should contain the necessary information to "replay" the compilation - Create a xref_kotlin phony rule to build all .kzip files corresponding to kotlin translation units. This implementation has one limitation. Since the kotlin indexers "replay" the compilation using its own version of kotlinc-jvm, there might be indexing issues caused by kotlinc version skew between android builds and indexing builds. `-kotlin-home` can likely solve that, but this CL defers that for now. Bug: 265428637 Test: Built the phony `xref_kotlin`, and ran the indexer locally using go/kythe-git-local-run#indexing-to-local-xrefs-server Change-Id: Ifb370f2df8aa46f71df3fe1ae7d7aa5da773cc8b
2024-09-06Merge "Make the java static_libs property configurable" into main Cole Faust
2024-09-05Make the java static_libs property configurable Cole Faust
Bug: 362579941 Test: m nothing --no-skip-soong-tests Change-Id: Iccc93cf14753aae1adb26c6eedd00aabf1c2f6a6
2024-09-04Use transitive header jars in classpaths Colin Cross
Skip combining jars into turbine-combined, combined, and withres jars and instead collect transitive jars to use in the classpath and to produce the final dexed jar. This reduces the size of a `m checkbuild` in git_main by 11%, from 1300 KiB to 1154 KiB. It may also improve caching and reduce uplink network bandwidth when building with RBE, as now the classpath inputs to rules are themselves outputs of previous rules and so already in the RBE CAS. The downside is that the classpath inputs to each rule are now much longer, increasing the Soong ninja file size 11%, from 4.6 GiB to 5.1 GiB. This could be mitigated in the future by supporting something like depsets in the generated ninja file to reduce duplication. Bug: 308016794 Test: TestSimple, TestKotlin, TestClasspath Flag: build.RELEASE_USE_TRANSITIVE_JARS_IN_CLASSPATH Change-Id: I2b7b4261375494370da70f98597c8719f1d561cf
2024-09-04Remove obsolete robolectric test runner integration Colin Cross
The `m Run*RoboTests` test runner is no longer supported, remove the code to generate the Make rules for it. Also reduce the number of combining steps by passing the extra jars that need to be combined into the compile step. This relands Icf05079bf570bed7a10962cbf03459bd53c51f99 with a fix to reorder the instrumented app classes after dependency classes. Test: atest --host SystemUiRoboTests Flag: EXEMPT refactor Change-Id: I174ceb95af5557e1859eeb12a2f5fac2332975a8
2024-09-03Rename collectTransitiveHeaderJars and friends to mention R8 Colin Cross
collectTransitiveHeaderJarsForR8 visits direct dependencies and collects all transitive libs and static_libs header jars. The semantics of the collected jars are odd (it collects combined jars that contain the static libs, but also the static libs, and it collects transitive libs dependencies of static_libs), so these are only used to expand the --library arguments to R8. Rename the method and all the fields it uses with a "ForR8" suffix to avoid confusion when more transitive header jar collection is added to support transitive classpaths. Bug: 308016794 Test: all soong tests pass Change-Id: I291a86fbbc2e2f088598fb309d1b992080d60941
2024-09-03Move checkbuild targets of Soong modules into Soong Colin Cross
Pass the name of Soong's checkbuild target for each module to Make so that it can depend on it from the main checkbuild rule. This will give better control over which files get built, allowing checkbuild to skip the jar combining step when transitive classpath jars are enabled. The per-module checkbuild targets are passed to make instead of added directly as a dependency of checkbuild in order to maintain the existing behavior of only building modules exposed to make in checkbuild. Also tweak the existing calls to CheckbuildFile and add InstallFileWithoutCheckbuild to match the files that are in the Make-based checkbuild. Bug: 308016794 Test: m checkbuild Change-Id: Ic5140819381d58f4d00f23a7a12447950c4cf268
2024-08-27Add ctx argument to IDEInfo() Cole Faust
The IDEInfo() methods read properties. To make those properties configurable, we need a context to evaluate them with. Bug: 362579941 Test: m nothing --no-skip-soong-tests Change-Id: I26d4b7084439b3006e50b02277298f74a929e1aa
2024-08-20Only add deps on java_binary's jni_libs on host Cole Faust
The jni_libs property of java_binary is documented to only install the jni libraries on host. However, it was adding installable deptag deps on those libraries, even if they were for device. This caused soong to emit installation rules for the jni libraries, causing them to be installed to the staging directory, but not emitting proper information to make, so they wouldn't be included on the built partitions. Only install them if the module is built for host, so that they don't erroneously appear in the staging directory. Bug: 344695913 Test: Presubmits Change-Id: Ic40b4fc6d7dbd51c03b08e28037be5428db49c33
2024-08-16Track resources separately in java_import Colin Cross
java_import currently collects the "implementation and resource jar" from each of its dependencies. This results in different resource conflict resolution than other java modules, which collect implementation jars and resource jars separately. Modify java_import to match the other module types. Flag: EXEMPT refactor Test: all soong tests pass Change-Id: I06134e2621582799b3a525d2c12b900b8d86d171
2024-08-15Convert more stored WritablePaths to Paths Colin Cross
Similar to I40f28075ce151e4be80d6cfc7ec173dfa46f9bbf, convert more long-lived WritablePaths to Paths. Test: all soong tests pass Flag: EXEMPT refactor Change-Id: I9be448f811694fe0524fbbd7c5d4553cf69d533a
2024-08-14Move kotlin stdlib to normal dependency tag Colin Cross
The kotlin standard library was added with a custom dependency tag, which then required special handling later. We know up front whether it will be treated the same as a static_libs or libs dependency, so just reuse staticLibTag or libTag, and remove all the special handling. Bug: 308016794 Test: TestKotlin Flag: exempt REFACTOR Change-Id: I2c5601faec284d88f28e13378d9cbffc24560efa
2024-08-09Use a provider for systems modules Colin Cross
Replace the SystemModulesProvider interface with Provider Test: all soong tests Flag: EXEMPT refactor Change-Id: If313580b28094d55b71f1635259bafa850ef7af5
2024-08-08Merge changes Ifc905b14,I62166c6d into main Treehugger Robot
* changes: Fix IDEInfo for java_import Add IdeInfo for android_library_import
2024-08-08Fix IDEInfo for java_import Spandan Das
`Jars` property in module_bp_java_deps.json should be relative to the android build top, and not relative to the Android.bp file Bug: 356572093 Test: m out/soong/module_bp_java_deps.json and verified that `jars` in an arbitrary java_import module is relative to android top Change-Id: Ifc905b14500dfa4254b27505fcc8af8f18349587
2024-08-07Convert JavaInfoProvider to *JavaInfo Colin Cross
Convert JavaInfoProvider to return a *JavaInfo instead of a JavaInfo. This will reduce copying when reading the provider, and also allows JavaInfo to recursively contain a depset of JavaInfos from dependencies. Bug: 308016794 Test: go test ./java/... Flag: EXEMPT refactor Change-Id: Ibf6d9b797f760ad1fe815d59839839fdfad91733
2024-08-07Merge "Don't hold on to WritablePath" into main Treehugger Robot
2024-08-06Revert "Revert "Enable from-text stub generation in non-sdk java..." Jihoon Kang
Revert submission 3207397-revert-2982300-java_api_library_non_sdk-FIKZOSARQI Reason for revert: Post submit build breakage culprit fixed Reverted changes: /q/submissionid:3207397-revert-2982300-java_api_library_non_sdk-FIKZOSARQI Change-Id: Ic79b7fd074f02febba94183cb1479874efe044b5
2024-08-05Revert "Enable from-text stub generation in non-sdk java_sdk_library" Liana Kazanova
Revert submission 2982300-java_api_library_non_sdk Reason for revert: DroidMonitor: Potential culprit for b/357648959 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Reverted changes: /q/submissionid:2982300-java_api_library_non_sdk Change-Id: I5ef7afd9ec3e10ea99f82d02172843ad9b2cfda9
2024-07-30Enable from-text stub generation in non-sdk java_sdk_library Jihoon Kang
This change allows from-text stubs to be generated for all java_sdk_library modules, unlike how it is currently limited to the modules that contribute to the api surfaces (i.e. the SDK). This change accomplish this by modifying the dependency of the from-text stubs generation, so that the sdk_library generated from-text stubs generating java_api_library modules no longer depend on the full api surface stubs, but generate the stubs in the module level, and combined later to generate the full api surface stubs. This change also removes the java_api_library modules defined in core-libraries/Android.bp, which are passed to generate the system modules. Given that the from-text vs from-source toggle is done within the java_sdk_library stubs level, these modules no longer need to exist. Implementation details: - Allow sdk_version to be specified in java_api_library modules. For java_sdk_library-generated java_api_library modules, they inherit that of the sdk_library module. Some java_sdk_library modules that do not contribute to the api surface are allowed to set sdk_version to something other than "none" or "core". - Implement java_api_library to implement `SdkContext`. This allows java_api_library to collect required deps from sdk_version (classpath, bootclasspath, system modules), and pass the collected jars when generating the stubs srcjar in metalava and compiling the stubs srcjar in javac. - Remove hardcoded list of sdk_library modules that are allowed to genereate stubs from the api signature files, and allow from-text stubs generation by default. Modules that are not able to generate stubs from the api signature files are specified by setting the newly introduced `Build_from_text_stubs` property to `false`. Test: ENABLE_HIDDENAPI_FLAGS=true m Bug: 327507877 Change-Id: Ia35d2f3cf9fae48fc8c4bd99a84ae18d7c0e7bee
2024-07-30Don't hold on to WritablePath Colin Cross
Since only a single rule can write to a given WritablePath, it is unecessary to hold on to the WritablePath once the rule has been created. Keeping a WritablePath causes complications, as it prevents using the input Path as the output when no modifications to the input file are necessary. The normal pattern should be to create a WritablePath using PathForModuleOut, build the rule that writes to the WritablePath, and then store the WritablePath as a Path for use as an input to any future rules. WithoutRel previously only existed on OutputPath, which required keeping the output path of the module as an OutputPath for as long as possible in order to call WithoutRel on it at the end of the module. Add WithoutRel to Path, make it always return a Path type, and implement it on all the types that implement Path by using a helper in basePath. Replace long-lived WritablePaths with Paths. Test: all soong tests pass Flag: EXEMPT refactor Change-Id: I40f28075ce151e4be80d6cfc7ec173dfa46f9bbf
2024-07-23Pass config files to metalava Paul Duffin
Adds a filegroup "metalava-config-files" whose contents are passed to Metalava using the `--config-file` option. Bug: 354699349 Test: m checkapi Change-Id: I1e246517c2ef678e41214c975aecee97f9faca67
2024-07-19Add all compile deps to module_bp_java_deps.json Spandan Das
`Dependencies` in module_bp_java_deps.json currently only contains the `libs` and `static_libs` of the corresponding module. This is only a subset of the dependencies which are required to compile the java module. Most notably, the SDK deps (determined using `sdk_version`) are missing. This CL adds all the compile dependencies to the json file. Implementation details: 1. Add a `compileDepNames` to java.Module in base.go. Almost all the module types in java package are composed with the java.Module struct. 2. Populate this property in java.Module.collectDeps. This function is used by java.Module.compile to determine the classpath used for compilation. 3. Return `compileDepNames` in java.Module.CompilerDeps. Since `compileDepNames` is populated in `GenerateAndroidBuildActions`, update existing unit tests that check for correctness of IDEInfo.Deps Bug: 353811607 Test: m nothing --no-skip-soong-tests Test: cat out/soong/module_bp_java_deps.json | jq '."DebuggingRestrictionController".dependencies' [ "android_system_stubs_current", <-- missing previously "core-lambda-stubs", <-- missing previously "core-public-stubs-system-modules", <-- missing previously "com.google.android.material_material", ... ... ] Change-Id: I166c0eaf6e87ca7adc98bb4e21447cf82612d103
2024-07-18Populate java_api_libray's IDEInfo Spandan Das
Adding the srcjar to module_bp_java_deps.json is useful for IDE autocompletion of rdeps. Bug: 353806911 Test: cat out/soong/module_bp_java_deps.json | jq '."core.current.stubs.from-text"' { "dependencies": [ "stub-annotations" ], "srcjars": [ "out/soong/.intermediates/build/soong/java/core-libraries/core.current.stubs.from-text/android_common/metalava/core.current.stubs.from-text-stubs.srcjar" ], "path": [ "build/soong/java/core-libraries" ], "libs": [ "stub-annotations" ] } Change-Id: Ie4ad985a7da40b478453735dfdb10d0ac63ab8f4
2024-07-11Add IsAddingDependency to IncomingTransitionContext Colin Cross
Add an IsAddingDependency method to IncomingTransitionContext that returns true if IncomingTransition is called after the transition has already won while adding a new dependency. This will be used as part of the transition mutators to support an apex use case where incoming dependencies during the initial apex mutator need to be rewritten onto the platform variant for modules that don't support the apex, but a later call to OtherModuleDependencyVariantExists must not rewrite the requested apex variation onto the platform variant. This should be used sparingly, all uses will have to be removed in order to support creating variants on demand. Bug: 319288033 Test: TestIsAddingDependency Flag: EXEMPT refactor Change-Id: Ib8e419d35ff8f7cbff9667c1cd40d05ccfacab8b
2024-07-10Use OutputFilesProvider on java modules mrziwang
In the context of incremental soong, the output files inter-module-communication will be through OutputFilesProvider. The OutputFileProducer interface will be deprecated. Test: CI Bug: 339477385 Change-Id: I3c9f0b766325dd490bc903dc65259c3953d34606
2024-07-09Use OutputFilesProvider on Import, AARImport and AndroidAppImport mrziwang
In the context of incremental soong, the output files inter-module-communication will be through OutputFilesProvider. The OutputFileProducer interface will be deprecated. Test: CI Bug: 339477385 Change-Id: I51ccf59f97cb8a790642cb4463c479feaf18058a
2024-06-26Merge "Enforce that tests in MTS specify a min_sdk_version" into main Spandan Das
2024-06-25Enforce that tests in MTS specify a min_sdk_version Spandan Das
Specifying min_sdk_version ensures backwards compatibility. There are some existing violations, and those have been baseline'd using an allowlist. Bug: 156476221 Test: m nothing Change-Id: I55098206da8ec5cfa0a9f5e7b41c9b8dedbdcbd2
2024-06-19Merge "Support passing multiple --migrate-nullness option for ↵ Paul Duffin
java_api_library" into main
2024-06-18Support passing multiple --migrate-nullness option for java_api_library Paul Duffin
Bug: 347751326 Test: m droid Change-Id: I7702021348004b5f6d686d71ee566c5589dbc4f5
2024-06-17Make required a configurable property Cole Faust
So that users can use select statements with it. Fixes: 347605145 Bug: 342006386 Test: m nothing --no-skip-soong-tests Change-Id: Ica0ca6d1725b000b3748c0293e5a9f9b38ed87f9
2024-06-10Merge "Remove exportable modules when generating snapshots targeting older ↵ Jihoon Kang
platform" into main
2024-06-10Remove exportable modules when generating snapshots targeting older platform Jihoon Kang
This change modifies the contents of the generated Android.bp files so that when generating a snapshot on a older platform, the "exportable" modules are removed from the bp files, as the "exportable" modules are first introduced in V and do not exist in older platforms. Bug: 345162614 Test: ABTD Change-Id: I2dba51b98deec7805bd796647a66981f237c55a9
2024-06-02Reapply "Change test_module_config from copying files to symlink ..." Ronald Braunstein
This reverts commit c6a321e4dee7ce2a832a9308ab4c7279a1cd0dfb. Original commit broke whe building sdk/ndk in postsubmit because of missing target arch. See: https://android-build.corp.google.com/artifact/submitted/11914755/mainline_modules_sdks-trunk_staging-userdebug/latest/view/logs%2Fbuild_error.log Reapplying originaly commit and adding fix in patchest. Test: DIST_DIR=/usr/local/google/dist/bug TARGET_RELEASE=trunk_staging TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true packages/modules/common/build/mainline_modules_sdks.sh Test: m general-tests Change-Id: Id844feb7ff9750bcd5af890a9fd26f7342344965
2024-05-31Revert "Change test_module_config from copying files to symlink ..." Priyanka Advani
Revert submission 3060229-ron-tmc-symlinks Reason for revert: Droidmonitor created revert due to b/344045516 Reverted changes: /q/submissionid:3060229-ron-tmc-symlinks Change-Id: If5045366677163560cdae95c0ab74256b4b49b9a