Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,18 @@ dev_maven.install(
resolver = "coursier",
)

dev_maven.install(
name = "coursier_pinned_layering",
artifacts = [
"com.google.code.findbugs:jsr305:3.0.1",
],
known_contributing_modules = [
"coursier_higher_layer",
],
resolver = "coursier",
version_conflict_policy = "pinned",
)

bazel_dep(name = "coursier_higher_layer", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "coursier_higher_layer",
Expand Down Expand Up @@ -1117,6 +1129,7 @@ use_repo(
"amend_artifacts",
"bom_only_pinning",
"coursier_layering",
"coursier_pinned_layering",
"duplicate_version_error",
"duplicate_version_warning",
"duplicate_version_warning_same_version",
Expand Down
2 changes: 1 addition & 1 deletion docs/bzlmod-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Combines artifact and bom declarations with setting the location of lock files t
| <a id="maven.install-strict_visibility_value"></a>strict_visibility_value | - | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `["@rules_jvm_external//visibility:private"]` |
| <a id="maven.install-use_credentials_from_home_netrc_file"></a>use_credentials_from_home_netrc_file | Whether to pass machine login credentials from the ~/.netrc file to coursier. | Boolean | optional | `False` |
| <a id="maven.install-use_starlark_android_rules"></a>use_starlark_android_rules | Whether to use the native or Starlark version of the Android rules. | Boolean | optional | `False` |
| <a id="maven.install-version_conflict_policy"></a>version_conflict_policy | Policy for user-defined vs. transitive dependency version conflicts<br><br>If "pinned", choose the user-specified version in maven_install unconditionally. With the Gradle and Maven resolvers, this only applies to artifacts contributed by the root module. If "default", follow the selected resolver's default policy. | String | optional | `"default"` |
| <a id="maven.install-version_conflict_policy"></a>version_conflict_policy | Policy for user-defined vs. transitive dependency version conflicts<br><br>If "pinned", choose the user-specified version in maven_install unconditionally. In layered installs, artifacts contributed by the root module take precedence over versions contributed by other modules. If "default", follow the selected resolver's default policy. | String | optional | `"default"` |

<a id="maven.override"></a>

Expand Down
20 changes: 10 additions & 10 deletions docs/bzlmod.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ plain versioned coordinate. This may lead to some surprises when resolution is c
"Highest" uses the Maven `ComparableVersion` ordering implemented by
`private/rules/maven_version.bzl`, not lexical string ordering.

`version_conflict_policy = "pinned"` changes this interaction. For the Gradle and Maven resolvers,
root artifacts are marked as `force_version` before layering. The duplicate-force check applies to
declared forces before this policy is applied. Maven then marks every versioned root declaration.
Gradle first selects one version for each root `group:artifact`: an unclassified declaration takes
precedence over classified declarations, and Maven `ComparableVersion` order selects among
declarations with the same classification status. Every root declaration for that module at the
selected version is then marked forced, including classified declarations. The root consequently
wins because it now forces the coordinate. For Coursier, layering is unchanged and the one
surviving direct version is later passed as a `--force-version` argument. A higher non-root
version can therefore displace the root under Coursier and then be pinned.
`version_conflict_policy = "pinned"` changes this interaction. Root artifacts are marked as
`force_version` before layering, whatever the resolver. The duplicate-force check applies to
declared forces before this policy is applied. Maven and Coursier mark every versioned root
declaration. Gradle first selects one version for each root `group:artifact`: an unclassified
declaration takes precedence over classified declarations, and Maven `ComparableVersion` order
selects among declarations with the same classification status. Every root declaration for that
module at the selected version is then marked forced, including classified declarations. The
root consequently wins because it now forces the coordinate. Coursier additionally passes every
direct artifact's version as a `--force-version` argument, so transitive dependencies cannot
displace the pinned version either.

The `force_version` flag can be set by an `artifact` tag, an `amend_artifact` tag, or a regular
artifact read by `from_toml`. Coordinates in `install.artifacts` cannot carry the flag. BOMs use the
Expand Down
245 changes: 228 additions & 17 deletions examples/android_local_test/maven_install.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": {
"androidx.annotation:annotation": 588494489,
"androidx.appcompat:appcompat": -864916242,
"androidx.emoji2:emoji2": -667316066,
"androidx.emoji2:emoji2-views-helper": -799295894,
"androidx.lifecycle:lifecycle-common": 965287242,
"androidx.lifecycle:lifecycle-livedata-core": -1534752455,
"androidx.lifecycle:lifecycle-runtime": -1133978085,
"androidx.lifecycle:lifecycle-viewmodel-savedstate": -1098900718,
"androidx.savedstate:savedstate": -833725607,
"androidx.test.ext:junit": 923457984,
"androidx.annotation:annotation": 1998854284,
"androidx.appcompat:appcompat": 526874845,
"androidx.emoji2:emoji2": 1270171825,
"androidx.emoji2:emoji2-views-helper": -985278619,
"androidx.lifecycle:lifecycle-common": -84119015,
"androidx.lifecycle:lifecycle-livedata-core": 993085898,
"androidx.lifecycle:lifecycle-runtime": 1906619816,
"androidx.lifecycle:lifecycle-viewmodel-savedstate": -577646767,
"androidx.savedstate:savedstate": -671028048,
"androidx.test.ext:junit": 199011195,
"com.google.code.findbugs:jsr305": 495355163,
"com.google.code.gson:gson": 2063056812,
"com.google.errorprone:error_prone_annotations": 1790047777,
"com.google.guava:guava": -249069712,
"com.google.j2objc:j2objc-annotations": -26400317,
"junit:junit": -744267592,
"org.assertj:assertj-core": -1145412507,
"org.robolectric:robolectric": -1784339344,
"com.google.code.gson:gson": 579810017,
"com.google.errorprone:error_prone_annotations": 1828684942,
"com.google.guava:guava": 1001533771,
"com.google.j2objc:j2objc-annotations": -57684360,
"junit:junit": 1633899997,
"org.assertj:assertj-core": -88843862,
"org.robolectric:robolectric": 1761992425,
"repositories": 1670674627
},
"__RESOLVED_ARTIFACTS_HASH": {
Expand Down Expand Up @@ -1140,13 +1140,40 @@
]
},
"packages": {
"androidx.activity:activity:aar": [
"androidx.activity",
"androidx.activity.contextaware",
"androidx.activity.result",
"androidx.activity.result.contract"
],
"androidx.annotation:annotation-experimental:aar": [
"androidx.annotation",
"androidx.annotation.experimental"
],
"androidx.annotation:annotation-jvm": [
"androidx.annotation"
],
"androidx.appcompat:appcompat-resources:aar": [
"androidx.appcompat.content.res",
"androidx.appcompat.graphics.drawable",
"androidx.appcompat.resources",
"androidx.appcompat.widget"
],
"androidx.appcompat:appcompat:aar": [
"androidx.appcompat.app",
"androidx.appcompat.graphics.drawable",
"androidx.appcompat.text",
"androidx.appcompat.view",
"androidx.appcompat.view.menu",
"androidx.appcompat.widget"
],
"androidx.arch.core:core-common": [
"androidx.arch.core.internal",
"androidx.arch.core.util"
],
"androidx.arch.core:core-runtime:aar": [
"androidx.arch.core.executor"
],
"androidx.collection:collection-jvm": [
"androidx.collection",
"androidx.collection.internal"
Expand All @@ -1157,12 +1184,196 @@
"androidx.concurrent:concurrent-futures-ktx": [
"androidx.concurrent.futures"
],
"androidx.core:core-ktx:aar": [
"androidx.core.animation",
"androidx.core.content",
"androidx.core.content.res",
"androidx.core.database",
"androidx.core.database.sqlite",
"androidx.core.graphics",
"androidx.core.graphics.drawable",
"androidx.core.location",
"androidx.core.net",
"androidx.core.os",
"androidx.core.text",
"androidx.core.transition",
"androidx.core.util",
"androidx.core.view",
"androidx.core.widget"
],
"androidx.core:core-viewtree:aar": [
"androidx.core.viewtree"
],
"androidx.core:core:aar": [
"android.support.v4.app",
"android.support.v4.graphics.drawable",
"android.support.v4.os",
"androidx.core.accessibilityservice",
"androidx.core.app",
"androidx.core.app.unusedapprestrictions",
"androidx.core.content",
"androidx.core.content.pm",
"androidx.core.content.res",
"androidx.core.database",
"androidx.core.database.sqlite",
"androidx.core.graphics",
"androidx.core.graphics.drawable",
"androidx.core.hardware.display",
"androidx.core.hardware.fingerprint",
"androidx.core.internal.view",
"androidx.core.location",
"androidx.core.math",
"androidx.core.net",
"androidx.core.os",
"androidx.core.provider",
"androidx.core.service.quicksettings",
"androidx.core.telephony",
"androidx.core.telephony.mbms",
"androidx.core.text",
"androidx.core.text.method",
"androidx.core.text.util",
"androidx.core.util",
"androidx.core.view",
"androidx.core.view.accessibility",
"androidx.core.view.animation",
"androidx.core.view.autofill",
"androidx.core.view.contentcapture",
"androidx.core.view.inputmethod",
"androidx.core.widget"
],
"androidx.cursoradapter:cursoradapter:aar": [
"androidx.cursoradapter.widget"
],
"androidx.customview:customview:aar": [
"androidx.customview.view",
"androidx.customview.widget"
],
"androidx.drawerlayout:drawerlayout:aar": [
"androidx.drawerlayout.widget"
],
"androidx.emoji2:emoji2-views-helper:aar": [
"androidx.emoji2.viewsintegration"
],
"androidx.emoji2:emoji2:aar": [
"androidx.emoji2.text",
"androidx.emoji2.text.flatbuffer"
],
"androidx.fragment:fragment:aar": [
"androidx.fragment.app",
"androidx.fragment.app.strictmode"
],
"androidx.interpolator:interpolator:aar": [
"androidx.interpolator.view.animation"
],
"androidx.lifecycle:lifecycle-common-jvm": [
"androidx.lifecycle"
],
"androidx.lifecycle:lifecycle-livedata-core:aar": [
"androidx.lifecycle"
],
"androidx.lifecycle:lifecycle-livedata:aar": [
"androidx.lifecycle"
],
"androidx.lifecycle:lifecycle-process:aar": [
"androidx.lifecycle"
],
"androidx.lifecycle:lifecycle-runtime-android:aar": [
"androidx.lifecycle"
],
"androidx.lifecycle:lifecycle-viewmodel-android:aar": [
"androidx.lifecycle",
"androidx.lifecycle.viewmodel",
"androidx.lifecycle.viewmodel.internal"
],
"androidx.lifecycle:lifecycle-viewmodel-savedstate-android:aar": [
"androidx.lifecycle",
"androidx.lifecycle.internal",
"androidx.lifecycle.serialization"
],
"androidx.loader:loader:aar": [
"androidx.loader.app",
"androidx.loader.content"
],
"androidx.profileinstaller:profileinstaller:aar": [
"androidx.profileinstaller"
],
"androidx.resourceinspection:resourceinspection-annotation": [
"androidx.resourceinspection.annotation"
],
"androidx.savedstate:savedstate-android:aar": [
"androidx.savedstate",
"androidx.savedstate.internal",
"androidx.savedstate.serialization",
"androidx.savedstate.serialization.serializers"
],
"androidx.startup:startup-runtime:aar": [
"androidx.startup"
],
"androidx.test.espresso:espresso-idling-resource:aar": [
"androidx.test.espresso",
"androidx.test.espresso.idling"
],
"androidx.test.ext:junit:aar": [
"androidx.test.ext.junit.rules",
"androidx.test.ext.junit.runners"
],
"androidx.test.services:storage:aar": [
"androidx.test.services.storage",
"androidx.test.services.storage.file",
"androidx.test.services.storage.internal"
],
"androidx.test:core:aar": [
"androidx.test.core.app",
"androidx.test.core.content.pm",
"androidx.test.core.graphics",
"androidx.test.core.internal.os",
"androidx.test.core.os",
"androidx.test.core.view"
],
"androidx.test:monitor:aar": [
"androidx.test",
"androidx.test.annotation",
"androidx.test.internal.platform",
"androidx.test.internal.platform.app",
"androidx.test.internal.platform.content",
"androidx.test.internal.platform.os",
"androidx.test.internal.platform.reflect",
"androidx.test.internal.platform.util",
"androidx.test.internal.runner",
"androidx.test.internal.runner.hidden",
"androidx.test.internal.runner.intent",
"androidx.test.internal.runner.intercepting",
"androidx.test.internal.runner.lifecycle",
"androidx.test.internal.util",
"androidx.test.platform",
"androidx.test.platform.app",
"androidx.test.platform.concurrent",
"androidx.test.platform.device",
"androidx.test.platform.graphics",
"androidx.test.platform.io",
"androidx.test.platform.tracing",
"androidx.test.platform.ui",
"androidx.test.platform.view.inspector",
"androidx.test.runner",
"androidx.test.runner.intent",
"androidx.test.runner.intercepting",
"androidx.test.runner.lifecycle"
],
"androidx.tracing:tracing:aar": [
"androidx.tracing"
],
"androidx.vectordrawable:vectordrawable-animated:aar": [
"androidx.vectordrawable.graphics.drawable"
],
"androidx.vectordrawable:vectordrawable:aar": [
"androidx.vectordrawable.graphics.drawable"
],
"androidx.versionedparcelable:versionedparcelable:aar": [
"androidx.versionedparcelable"
],
"androidx.viewpager:viewpager:aar": [
"androidx.viewpager.widget"
],
"com.almworks.sqlite4java:sqlite4java": [
"com.almworks.sqlite4java",
"javolution.util.stripped"
Expand Down
Loading