Comments (5)
Related: #190
from rules_android.
from rules_android.
To make sure we're talking about the same things, I adapted the basicapp in examples:
BUILD
:
load("@rules_android//android:rules.bzl", "android_binary", "android_library")
android_binary(
name = "basic_app",
manifest = "AndroidManifest.xml",
deps = [":basic_lib"],
)
android_library(
name = "basic_lib",
srcs = ["BasicActivity.java"],
manifest = "AndroidManifest.xml",
resource_files = glob(["res/**"]),
deps = [":manifest_AAA"],
)
android_library(
name = "manifest_AAA",
manifest = "AndroidManifestBar.xml",
deps = [":manifest_ZZZ"],
exports_manifest = True,
)
android_library(
name = "manifest_ZZZ",
manifest = "AndroidManifestBaz.xml",
exports_manifest = True,
)
AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.basicapp" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="30" />
</manifest>
AndroidManifestBar.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<meta-data android:name = "data" android:value = "bar"/>
</manifest>
AndroidManifestBaz.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<meta-data android:name = "data" android:value = "baz"/>
</manifest>
And then the merged manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.basicapp" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="30" />
<meta-data
android:name="data"
android:value="bar" />
<application />
</manifest>
With "bar" from AndriodManifestBar.xml as expected.
If the the names of the libraries are swapped (but not their dependency order, i.e. it's still AndroidManifest.xml -> AndroidManifestBar.xml -> AndroidManifestBaz.xml):
load("@rules_android//android:rules.bzl", "android_binary", "android_library")
android_binary(
name = "basic_app",
manifest = "AndroidManifest.xml",
deps = [":basic_lib"],
)
android_library(
name = "basic_lib",
srcs = ["BasicActivity.java"],
manifest = "AndroidManifest.xml",
resource_files = glob(["res/**"]),
deps = [":manifest_ZZZ"],
)
android_library(
name = "manifest_ZZZ",
manifest = "AndroidManifestBar.xml",
deps = [":manifest_AAA"],
exports_manifest = True,
)
android_library(
name = "manifest_AAA",
manifest = "AndroidManifestBaz.xml",
exports_manifest = True,
)
then the merged manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.basicapp" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="30" />
<meta-data
android:name="data"
android:value="baz" />
<application />
</manifest>
It contains "baz" from the lower-level android_library.
As changed in #190 and #193, this results from the sorting here:
rules_android/rules/busybox.bzl
Line 787 in 3414610
Are there other cases (besides the naming of the targets) that results in unexpected merging priorities?
Interstingly, disabling the sorting and using "dependency order" has actually been available in the native rules since early 2019:
bazelbuild/bazel@1fcf614
but that option was added mostly incidentally in the course of adjusting things for changes related to configuration paths and didn't make it in the Starlark migration of the relevant code. I traced the origin of sorting the manifests to see why we do this -- I found the change in late 2014 (prior to open sourcing bazel) that doesn't give much explanation (I suspect it might have just been overly enthusiastic application of "sorting is deterministic")
from rules_android.
I had considered just making "dependency order" the default for the bazel version of the rules (as #190 does, but adjusting so that internally we keep the sorting behavior) but it occurs to me that this would create a potential incompatibility between the native rules and the starlark rules, which could make migrating from native to starlark more complicated -- so we might need a switch in bazel anyway (as #193 does)
from rules_android.
This should be addressed with f13f245
Note that the default is now to merge manifests in "dependency" order instead of what we're now calling "legacy" order (roughly alphabetical). The previous behavior can be enabled with --@rules_android//rules/flags:manifest_merge_order=legacy
from rules_android.
Related Issues (20)
- Support bundling local resource from `resources/` dir into `android_library` and `android_binary` HOT 1
- aidl rust backend HOT 3
- Bug: ProguardMapping is not queryable nor deterministically generated HOT 1
- Default debug_keystore is missing HOT 2
- Migrate Rules docs from Native rules to Starlark Rules HOT 1
- Migrate Bazel Android Tools from bazel repo to rules_android repo HOT 1
- Remove exports_manifest attribute of android_library HOT 2
- The new Golang implementation for the BumpMinSdkFloor action fails when manfiest doesn't have namespace HOT 2
- deploy_info gobinary visibility breaks builds when defining a custom android toolchain
- The Starlark implementaiton of process_deploy_jar fails to execute java.create_deploy_jar HOT 5
- Build fails when `--incremental_dexing` is disabled HOT 1
- Remove dependencies on --experimental_google_legacy_api and --experimental_enable_android_migration_apis HOT 1
- Can't build example basicapp HOT 5
- _copy_file and _copy_dir fail on macOS
- AAR libraries from Maven don't expose their resources unlike in built-in Android rules HOT 3
- Mobile install v3 doesn't work with --start=debug HOT 1
- Flags underneath rules/flags/ aren't working correctly HOT 1
- Android platforms breaks incremental dexing and desugaring HOT 4
- mobile-install fails with dependencies from rules_jvm_external HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_android.