summaryrefslogtreecommitdiff
path: root/java/java.go
AgeCommit message (Collapse)Author
2020-11-24Add java sdk library enforcement flagJaeMan Park
Add java sdk library enforcement for inter-partition library dependency, for ensuring backward-compatible libraries for inter-partition dependencies. Test: m nothing Bug: 168180538 Change-Id: I6bfac54c3499b03003a3bc6c2bb62b165b4ce5f9
2020-11-24Merge "Remove restriction on exported plugins that generate APIs"Treehugger Robot
2020-11-23Annotate dependency tags for dependencies of installed filesColin Cross
Relands Ic22603a5c0718b5a21686672a7471f952b4d1017 with a minor change to track libc++ dependencies for python hosts and after a fix to an internal genrule that depended on transitively installed java libraries (ag/13068670). Soong currently assumes that installed files should depend on installed files of all transitive dependencies, which results in extra installed file dependencies through genrules, static libs, etc. Annotate dependency tags for dependencies for which the installed files are necessary such as shared libraries and JNI libraries. This avoids extra installed files, and is also a first step towards genrules using their own copy of tools instead of the installed copy. Bug: 124313442 Test: m checkbuild Test: java.TestBinary Test: cc.TestInstallSharedLibs Test: deptag_test.go Change-Id: I725871249d561428e6f67bba6a7c65b580012b72
2020-11-23Remove restriction on exported plugins that generate APIsColin Cross
hilt_android requires seven separate annotation processors, which is only feasible to support using exported_plugins to avoid having to list all seven in every module that uses it. Unfortunately they all set generates_api: true. Turbine is already disabled for modules that directly use a plugin that sets generates_api: true, because turbine doesn't run annotation processors. Also add support for disabling turbine if a module transitively uses a plugin that generates APIs via exported_plugins. Bug: 173397767 Test: TestExportedPlugins Change-Id: If70354a3dd67efb4ce88bc9c934d41ccb6241b28
2020-11-20Merge "Support extra checks for ErrorProne in a dedicated property"Colin Cross
2020-11-20Merge "Use java host unit tests template for unit tests"Julien Desprez
2020-11-19Support extra checks for ErrorProne in a dedicated propertyColin Cross
Previous extra checks for ErrorProne were added using the plugins proeprty to get them into the -processorpath argument. This works fine for java-only modules, but fails for mixed java+kotlin modules because the processorpath is given to kapt and not javac. Add a dedicated errorprone.extra_check_modules property (mirroring the lint.extra_check_modules property), and add that to a separate processorpath that is used only for errorprone rules and not cleared when kotlin is used. Test: TestKapt/errorprone Change-Id: Id6ef02ce758532d1df8b8d969fad83bb44fe93ab
2020-11-19Merge "java link time error improve"Treehugger Robot
2020-11-19Use java host unit tests template for unit testsJulien Desprez
Test: make aoa-helper-tests Bug: 172961860 Change-Id: I2eaee277961f29adfd22e7c65248c9403bd69b81
2020-11-18Merge "Add unit_test test option in test configs"Dan Shi
2020-11-17java link time error improveSteven Moreland
Asked about error message including "against private API.Adjust sdk_version", which is a bit hard to parse due to missing space. Also tried to make error message less verbose, so that it is more clear what to do, and fixed a grammar mistake. Bug: N/A Test: N/A Change-Id: Ib9a30d86b5cb0e9b3b7d5576ecb9498a9b316042
2020-11-16Merge changes Ic22603a5,I5330b571Colin Cross
* changes: Annotate dependency tags for dependencies of installed files Use the the preferred architecture symlink as the tool path if it exists
2020-11-16Add unit_test test option in test configsDan Shi
This change allows a test (native, java, rust or python) to be included in host-unit-tests suite when test option `unit_test` is set to true. Bug: 172006742 Test: m host-unit-tests Change-Id: I69d3eb5b51198c549e2e6914ceac3a4fc33c3cf2
2020-11-16Rename fields and methods to reflect class loader context changes.Ulya Trafimovich
Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: Iebfbf2ffdac5ee48476d2aac312b3b8f4471fc85
2020-11-16Do not add dependencies of shared SDK libraries to manifest_fixer.Ulya Trafimovich
Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Bug: 168686456 Change-Id: Ibd9742684fa6a8f1353ca0e513f7fa814a6ec9fc
2020-11-16Add nested class loader subcontext at the proper hierarchy level.Ulya Trafimovich
When adding a subcontext in a class loader context tree, there are two possible cases: 1) the root of the subcontext is itself a <uses-library> and should be present as a node in the tree, or 2) the root is not a <uses-library>, but some of its dependencies are -- in that case they should be disconnected from the root, and the resulting forrest should be added at the top-level. Example: 1) C is a <uses-library>: A ├── B └── C ├── D └── E └── F 2) C is not a <uses-library>: A ├── B ├── D └── E └── F Before the patch subcontexts for transitive dependencies were added before the subcontext for the direct dependency (even if it was a <uses-library>, resulting in case-2 hierarchy when case-1 should have been used. Previosuly this didn't matter because class loader context was a flat set of libraries, but now it matters because class loader context is a tree. This patch changes the order in which libraries are added, so that direct dependencies are added before transitive ones. The context adding method now accepts an "implicit root" parameter, so that when adding transitive dependencies it can check if the corresponding direct dependency is a <uses-library> and already present in the context. Partially constructed class loader context is now propagated top-down into aapt.buildActions, so that the method can use existing part of the context to decide where the missing part should be connected. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I649aff9e27494306885a4f4fc90226c399636b57
2020-11-14Annotate dependency tags for dependencies of installed filesColin Cross
Soong currently assumes that installed files should depend on installed files of all transitive dependencies, which results in extra installed file dependencies through genrules, static libs, etc. Annotate dependency tags for dependencies for which the installed files are necessary such as shared libraries and JNI libraries. This avoids extra installed files, and is also a first step towards genrules using their own copy of tools instead of the installed copy. Bug: 124313442 Test: m checkbuild Test: java.TestBinary Test: cc.TestInstallSharedLibs Test: deptag_test.go Change-Id: Ic22603a5c0718b5a21686672a7471f952b4d1017
2020-11-03Rework class loader context implementation.Ulya Trafimovich
The old representation consisted of a list of libraries (UsesLibraries), a list of optional libraries (OptionalUsesLibraries) and a mapping from library name to its build/install paths (LibraryPaths). The separation into lists and map was necessary because of special handling of compatibility libraries, which is now unified with normal libraries. The new representation is a mapping from target SDK version to a tree structure ClassLoaderContext. Each node of the tree represents a library and contains library name, build/install paths and a slice of subcontexts for dependencies. The same library may occur in the tree multiple times in case it is a dependency of multiple libraries. The order in which libraries are added matters (the resulting tree shape may be different). Test results have to be updated, as the resulting <uses-library> list is reodered (previously it was a sorted list of map keys, and now it is formed by a depth-first preorder traversal of the class loader tree). Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Bug: 168686456 Change-Id: I11be8cd2967f004fd58753d7c5fb99fed179cd63
2020-11-02Add ctx.ModuleDir and top level module dirs of input sources to JDK9Jingwen Chen
--patch-module lookup. javac --patch-module accepts a list of directories and/or jars for JDK9 module patching (see bug for more details). In Bazel-Ninja execution, Bazel executes the javac action in its own execution root working directory, unlike Ninja, which works in the Android top level directory. The Bazel execution root is formed of a symlink forest of top level directories. This symlink forest is a problem for javac because it doesn't traverse into symlinks. To support Bazel executing these javac actions, we explicitly encode the module directory, and the top level directory of any other source file inputs into the --patch-module javac flag. For example, the "core-all" libcore module compiles into `java.base`, and depends on filegroups outside of `libcore` (`tools`). This CL adds `tools` to the --patch-module lookup dir, on top of `libcore`. See java_test.go for more details. Bug: 150878007 Fixes: 150878007 Test: m Test: bazel build droid (aosp_flame) Change-Id: Id95b0a9a675fc75678f7b5e600344b4403f0c518
2020-10-30java compilation: refactor and extract javac flag computation into aJingwen Chen
separate function. This cleans up the internal wiring for a follow-up --patch-module functionality change. Bug: 150878007 Test: m Change-Id: Ie7d9c2b1ad40e055da8a53d632510bef408fc7d2
2020-10-27Add separate dependency tags for compat libs based on SDK version.Ulya Trafimovich
The version in the tag is the SDK version that in which compatibility library was added as a separate libary. Using distinct tags makes it possible to differentiate between dependencies for different SDK versions (this will be needed in subsequent CLs). Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I72296c05d6649e811ddc701aaeb84f91d1ba66cb
2020-10-15Add empty tag support for java_importSaeid Farivar Asanjan
Test: manual Change-Id: I53d7c6bb620fa8fe7f5c3ec0a12f723eb62fca16
2020-10-09Add jni_libs to host java binariesColin Cross
Add a property to support dependencies on JNI libraries for host java binaries. Fixes: 170389375 Test: TestBinary Change-Id: Ieeca3c3997615f0b17ae1f058b94e6c9ba929cab
2020-10-09Make java_binary common variant a dependencyColin Cross
ctx.PrimaryModule() is wrong in the case of a java_binary that supports both host and device, use an explicit dependency instead. Once the dependency exists there is no need to manually request the jar be installed, it will automatically be installed by the host installation rules for dependencies. Test: TestBinary Change-Id: Iddeea2d08bc574c79d42139020558cd70d718ca1
2020-10-09Replace jniDependencyTag with a valueColin Cross
Support GetDirectDepsWithTag on JNI deps by replacing the jniDependencyTag type with a jniLibTag value. Test: app_test.go Change-Id: I8d66a5d3f433562e131a1fbafce75891d1b094dd
2020-10-07Merge "Remove global state from apex modules"Colin Cross
2020-10-07Merge "Allow access to the class jar for java_import using {.jar} tag"Paul Duffin
2020-10-07Merge changes from topic "uses-libs-24"Ulyana Trafimovich
* changes: Fail the build if dexpreopt cannot find path to a <uses-library>. Add dependency on implementation <uses-library> for modules that depend on component libraries.
2020-10-06Remove global state from apex modulesColin Cross
A global variant was used to store the global mapping between modules and APEXes. Replace it with storing pointers to APEX contents inside each module so that they can query the contents of any APEXes they belong to. Bug: 146393795 Test: all Soong tests Test: single line change to build.ninja host install dependency ordering Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
2020-10-06Allow access to the class jar for java_import using {.jar} tagPaul Duffin
Layoutlib requires access to the jar file (containing .class) files for a number of libraries including "core-libart". It does that using the {.jar} output tag, e.g. "core-libart{.jar}". This change makes sure that works when "core-libart" is provided as a java_import instead of a java_library. Bug: 142938164 Test: m nothing Change-Id: I605019d680c28e4a33f0ca14279d63fa62b9774b
2020-10-06Add dependency on implementation <uses-library> for modules that depend on ↵Ulya Trafimovich
component libraries. If a dexpreopted Java module depends on a component library (such as stubs), it must be dexpreopted against the implementation library, because that is what it will use at run time. Therefore dexpreopt needs to know about the implementation library. One of the subtests of TestUsesLibraries is removed. This is because the subtest was previosuly split in two variants with the only difference that the first variant had dependency on a stubs library, and the second one had dependency on the implementation. The latter caused dexpreopt to be disabled because Soong couldn't find the implementation (it had only the name, but no access to the module). Now that there is a dependency on the implementation, the problem goes away and the two subtest variants can be merged into one. Add a method for getting the name of the implementation library for the optional SDK library. Currently it is the same as the SDK library name, but it may change in future. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I584df4b6db874c7ae3c478231fc51572a46929b1
2020-09-22Convert more versions in config to ApiLevel.Dan Albert
The test case I removed is invalid. The codename has had its int assigned, but the config claims it is not final. If this ever does need to be supported it's just a matter of making sure the Q -> 29 mapping (or whatever) in the finalized codenames map in android/api_levels.go. Test: treehugger Bug: http://b/154667674 Change-Id: I4f42ec2fd4a37750519ee3937938a1c65b6bb1e8
2020-09-22Replace ApiStrToNum uses with ApiLevel.Dan Albert
Test: treehugger Bug: http://b/154667674 Change-Id: I2954bb21c1cfdeb305f25cfb6c8711c930f6ed50
2020-09-14Merge "Add hidden_api for java_import"Liz Kammer
2020-09-11Consistently use default install path for compatibility <uses-library>.Ulya Trafimovich
Previously default install path was provided only for comatibility libraries that are added explicitly via `uses_libs`/`optional_uses_libs` properties. This didn't take into account compatibility libraries that are added by Soong when it computes transitive closure of SDK library dependencies. As a result, install path in such cases remained unknown, and the corresponding compatibility library was omitted from class loader context, which caused 'ClassLoaderContext shared library size mismatch' errors at first boot on device. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: If661272f46803299c8640f7f5ef161c8217d07e4
2020-09-10Merge "Merge Android R"Xin Li
2020-09-10Add hidden_api for java_importLiz Kammer
Test: go java tests Test: m Bug: 160455085 Change-Id: Ib6e826e32ca73ceea0799b26145ad06b1e62a1bf
2020-09-10Merge "Replace `is_uses_lib` property with `provides_uses_lib`."Ulyana Trafimovich
2020-09-10Replace `is_uses_lib` property with `provides_uses_lib`.Ulya Trafimovich
The previous property was boolean-valued and provided only the information whether the library should be treated as <uses-library> by Soong. The new property is an optional string, which is the name of the <uses-library>. The name can be different from the module name, as in the case of "qcrilhook" module which provides <uses-library> "com.qualcomm.qcrilhook". Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: I65b68e6f7c420ab9c443a76de4c917d31fcd8c8f
2020-09-10Merge "Check UseRBE is set before replacing any template with the RE version."Kousik Kumar
2020-09-08Merge "Be more strict about unknown install <uses-library> paths." am: ↵Ulyana Trafimovich
117a5ef307 Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1418529 Change-Id: Ib28e902e7f8ec57a15ef50692024cd37a96696bc
2020-09-07Be more strict about unknown install <uses-library> paths.Ulya Trafimovich
Allow default install paths only for compatibility libraries. For other libraries that are explicitly specified in `uses_libs` and `optional_uses_libs` unknown install path should be an error. Bug: 132357300 Test: lunch cf_x86_phone-userdebug && m Change-Id: I2209c90a939a8aa46c42e13bb42d09c07e4d0895
2020-09-07Merge "Allow non-SDK Java libraries to masquerade as <uses-library>." am: ↵Ulyana Trafimovich
bb3467d297 Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1417188 Change-Id: If25aaa0174091e966cc5c6b16063b6486a7b4ab6
2020-09-07Merge "Allow non-SDK Java libraries to masquerade as <uses-library>."Ulyana Trafimovich
2020-09-03Check UseRBE is set before replacing any template with the RE version.Ramy Medhat
Test: presubmit Change-Id: I6df58b4e700f0d231367af2710672d731d20a736
2020-09-02Merge "Add compile_dex for java_import" am: e263af74dbTreehugger Robot
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1392497 Change-Id: I9fbbd7e1f02a64f5e0ed9b583a61e64fd4306362
2020-09-01Add compile_dex for java_importLiz Kammer
Test: go java tests Test: m Bug: 160455085 Change-Id: I2db95dfe565e78b630007adc3360a58614d0127e
2020-09-01Allow non-SDK Java libraries to masquerade as <uses-library>.Ulya Trafimovich
Extend usesLibraryProperties with a boolean is_uses_lib property and move these properties from java.AndroidApp to java.Module to allow java.Library modules set the new propery and be recognized as <uses-library> by Soong. Bug: 132357300 Test: lunch cf_x86_phone-userdebug && m Change-Id: I01cd5e0da3dd543c1c0597249d37d0914b213ca7
2020-08-29Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)Xin Li
Bug: 166295507 Merged-In: Ifca7b65f4e27bf14cdc30f72f790b0de90130bae Change-Id: I3a39be5f0b8736de4822c6a14072c78d4e4ad89d
2020-08-27Propagate transitive SDK Java library dependencies to dexpreopt.Ulya Trafimovich
For some dependencies, like stubs, the SDK library may not be found at build time (either because the implementation library is not among the dependencies of the dexpreopted module, or because it's part of a prebuilt, or because it's missing from the build altogether). In such cases dexpreopt is useless, because dex2oat does not have access to the full classpath (unless the &-classpath is used). Therefore do not dexpreopt in such cases. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: If289088cfd103011ccb16165e95a97b30fd31b81