diff --git a/README.md b/README.md index d6015c1e2..04505a3b3 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,11 @@ your project's root directory. If you do not have one, create an empty BUILD file to fix issues you may see. See [#242](https://github.com/bazelbuild/rules_jvm_external/issues/242) +**Note:** If you're using an older version of `rules_jvm_external` and +haven't repinned your dependencies, you may see a warning that you lock +file "does not contain a signature of the required artifacts" then don't +worry: either ignore the warning or repin the dependencies. + ### Updating `maven_install.json` Whenever you make a change to the list of `artifacts` or `repositories` and want @@ -206,6 +211,25 @@ prefix (e.g.`@unpinned_maven` or `@unpinned_`). For example, if your `maven_install` is named `@foo`, `@unpinned_foo` will be created. +### Requiring lock file repinning when the list of artifacts changes + +It can be easy to forget to update the `maven_install.json` lock file +when updating artifacts in a `maven_install`. Normally, +rules_jvm_external will print a warning to the console and continue +the build when this happens, but by setting the +`fail_if_repin_required` attribute to `True`, this will be treated as +a build error, causing the build to fail. When this attribute is set, +it is possible to update the `maven_install.json` file using: + +```shell +$ REPIN=1 bazel run @unpinned_maven//:pin +``` + +Alternatively, it is also possible to modify the +`fail_if_repin_required` attribute in your `WORKSPACE` file, run +`bazel run @unpinned_maven//:pin` and then reset the +`fail_if_repin_required` attribute. + ### Custom location for `maven_install.json` You can specify a custom location for `maven_install.json` by changing the diff --git a/coursier.bzl b/coursier.bzl index 2019b56b4..76ac8d171 100644 --- a/coursier.bzl +++ b/coursier.bzl @@ -183,6 +183,21 @@ def _compute_dependency_tree_signature(artifacts): signature_inputs.append(":".join(artifact_group)) return hash(repr(sorted(signature_inputs))) +# Compute a signature of the list of artifacts that will be used to build +# the dependency tree. This is used as a check to see whether the dependency +# tree needs to be repinned. +# +# Visible for testing +def compute_dependency_inputs_signature(artifacts): + artifact_inputs = [] + for artifact in artifacts: + parsed = json_parse(artifact) + # Sort the keys to provide a stable order + keys = sorted(parsed.keys()) + flattened = ":".join(["%s=%s" % (key, parsed[key]) for key in keys]) + artifact_inputs.append(flattened) + return hash(repr(sorted(artifact_inputs))) + def extract_netrc_from_auth_url(url): """Return a dict showing the netrc machine, login, and password extracted from a url. @@ -301,6 +316,12 @@ def _add_outdated_files(repository_ctx, artifacts, repositories): executable = True, ) +def _fail_if_repin_required(repository_ctx): + if not repository_ctx.attr.fail_if_repin_required: + return False + + return "REPIN" not in repository_ctx.os.environ.keys() + def _pinned_coursier_fetch_impl(repository_ctx): if not repository_ctx.attr.maven_install_json: fail("Please specify the file label to maven_install.json (e.g." + @@ -346,7 +367,29 @@ def _pinned_coursier_fetch_impl(repository_ctx): dep_tree = maven_install_json_content["dependency_tree"] - dep_tree_signature = dep_tree.get("__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY") + # Then, check to see if we need to repin our deps because inputs have changed + if dep_tree.get("__INPUT_ARTIFACTS_HASH") == None: + print("NOTE: %s_install.json does not contain a signature of the required artifacts. " % repository_ctx.name + + "This feature ensures that the build does not use stale dependencies when the inputs " + + "have changed. To generate this signature, run 'bazel run @unpinned_%s//:pin'." % repository_ctx.name) + else: + computed_artifacts_hash = compute_dependency_inputs_signature(repository_ctx.attr.artifacts) + if computed_artifacts_hash != dep_tree.get("__INPUT_ARTIFACTS_HASH"): + if _fail_if_repin_required(repository_ctx): + fail("%s_install.json contains an invalid input signature and must be regenerated. " % (repository_ctx.name) + + "This typically happens when the maven_install artifacts have been changed but not repinned. " + + "PLEASE DO NOT MODIFY THIS FILE DIRECTLY! To generate a new " + + "%s_install.json and re-pin the artifacts, either run:\n" % repository_ctx.name + + " REPIN=1 bazel run @unpinned_%s//:pin\n" % repository_ctx.name + + "or:\n" + + " 1) Set 'fail_if_repin_required' to 'False' in 'maven_install'\n" + + " 2) Run 'bazel run @unpinned_%s//:pin'\n" % repository_ctx.name + + " 3) Reset 'fail_if_repin_required' to 'True' in 'maven_install'\n\n"); + else: + print("The inputs to %s_install.json have changed, but the lock file has not been regenerated. " % repository_ctx.name + + "Consider running 'bazel run @unpinned_%s//:pin'" % repository_ctx.name) + + dep_tree_signature = dep_tree.get("__RESOLVED_ARTIFACTS_HASH") if dep_tree_signature == None: print("NOTE: %s_install.json does not contain a signature entry of the dependency tree. " % repository_ctx.name + @@ -862,7 +905,9 @@ def _coursier_fetch_impl(repository_ctx): artifact.update({"sha256": shas[str(repository_ctx.path(file))]}) dep_tree.update({ - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": _compute_dependency_tree_signature(dep_tree["dependencies"]), + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__RESOLVED_ARTIFACTS_HASH": _compute_dependency_tree_signature(dep_tree["dependencies"]), + "__INPUT_ARTIFACTS_HASH": compute_dependency_inputs_signature(repository_ctx.attr.artifacts), }) repository_ctx.report_progress("Generating BUILD targets..") @@ -1002,6 +1047,7 @@ pinned_coursier_fetch = repository_rule( "jetify": attr.bool(doc = "Runs the AndroidX [Jetifier](https://developer.android.com/studio/command-line/jetifier) tool on artifacts specified in jetify_include_list. If jetify_include_list is not specified, run Jetifier on all artifacts.", default = False), "jetify_include_list": attr.string_list(doc = "List of artifacts that need to be jetified in `groupId:artifactId` format. By default all artifacts are jetified if `jetify` is set to True.", default = JETIFY_INCLUDE_LIST_JETIFY_ALL), "additional_netrc_lines": attr.string_list(doc = "Additional lines prepended to the netrc file used by `http_file` (with `maven_install_json` only).", default = []), + "fail_if_repin_required": attr.bool(doc = "Whether to fail the build if the maven_artifact inputs have changed but the lock file has not been repinned.", default = False), }, implementation = _pinned_coursier_fetch_impl, ) diff --git a/defs.bzl b/defs.bzl index 153406711..3c15ef35c 100644 --- a/defs.bzl +++ b/defs.bzl @@ -39,7 +39,8 @@ def maven_install( resolve_timeout = 600, jetify = False, jetify_include_list = JETIFY_INCLUDE_LIST_JETIFY_ALL, - additional_netrc_lines = []): + additional_netrc_lines = [], + fail_if_repin_required = False): """Resolves and fetches artifacts transitively from Maven repositories. This macro runs a repository rule that invokes the Coursier CLI to resolve @@ -75,6 +76,7 @@ def maven_install( jetify: Runs the AndroidX [Jetifier](https://developer.android.com/studio/command-line/jetifier) tool on artifacts specified in jetify_include_list. If jetify_include_list is not specified, run Jetifier on all artifacts. jetify_include_list: List of artifacts that need to be jetified in `groupId:artifactId` format. By default all artifacts are jetified if `jetify` is set to True. additional_netrc_lines: Additional lines prepended to the netrc file used by `http_file` (with `maven_install_json` only). + fail_if_repin_required: Whether to fail the build if the required maven artifacts have been changed but not repinned. Requires the `maven_install_json` to have been set. """ repositories_json_strings = [] for repository in parse.parse_repository_spec_list(repositories): @@ -140,6 +142,7 @@ def maven_install( jetify = jetify, jetify_include_list = jetify_include_list, additional_netrc_lines = additional_netrc_lines, + fail_if_repin_required = fail_if_repin_required, ) def artifact(a, repository_name = DEFAULT_REPOSITORY_NAME): diff --git a/docs/api.md b/docs/api.md index b0ffa0223..05249770b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -48,7 +48,7 @@ Generate a javadoc from all the `deps` ## java_export
-java_export(name, maven_coordinates, pom_template, visibility, kwargs)
+java_export(name, maven_coordinates, pom_template, visibility, tags, kwargs)
 
Extends `java_library` to allow maven artifacts to be uploaded. @@ -99,6 +99,7 @@ Generated rules: | maven_coordinates | The maven coordinates for this target. | none | | pom_template | The template to be used for the pom.xml file. | None | | visibility | The visibility of the target | None | +| tags |

-

| [] | | kwargs | These are passed to [java_library](https://docs.bazel.build/versions/master/be/java.html#java_library), and so may contain any valid parameter for that rule. | none | @@ -107,10 +108,11 @@ Generated rules: ## maven_install
-maven_install(name, repositories, artifacts, fail_on_missing_checksum, fetch_sources,
+maven_install(name, repositories, artifacts, fail_on_missing_checksum, fetch_sources, fetch_javadoc,
               use_unsafe_shared_cache, excluded_artifacts, generate_compat_repositories,
               version_conflict_policy, maven_install_json, override_targets, strict_visibility,
-              resolve_timeout, jetify, jetify_include_list, additional_netrc_lines)
+              resolve_timeout, jetify, jetify_include_list, additional_netrc_lines,
+              fail_if_repin_required)
 
Resolves and fetches artifacts transitively from Maven repositories. @@ -129,6 +131,7 @@ and fetch Maven artifacts transitively. | artifacts | A list of Maven artifact coordinates in the form of group:artifact:version. | [] | | fail_on_missing_checksum |

-

| True | | fetch_sources | Additionally fetch source JARs. | False | +| fetch_javadoc | Additionally fetch javadoc JARs. | False | | use_unsafe_shared_cache | Download artifacts into a persistent shared cache on disk. Unsafe as Bazel is currently unable to detect modifications to the cache. | False | | excluded_artifacts | A list of Maven artifact coordinates in the form of group:artifact to be excluded from the transitive dependencies. | [] | | generate_compat_repositories | Additionally generate repository aliases in a .bzl file for all JAR artifacts. For example, @maven//:com_google_guava_guava can also be referenced as @com_google_guava_guava//jar. | False | @@ -140,6 +143,7 @@ and fetch Maven artifacts transitively. | jetify | Runs the AndroidX [Jetifier](https://developer.android.com/studio/command-line/jetifier) tool on artifacts specified in jetify_include_list. If jetify_include_list is not specified, run Jetifier on all artifacts. | False | | jetify_include_list | List of artifacts that need to be jetified in groupId:artifactId format. By default all artifacts are jetified if jetify is set to True. | ["*"] | | additional_netrc_lines | Additional lines prepended to the netrc file used by http_file (with maven_install_json only). | [] | +| fail_if_repin_required | Whether to fail the build if the required maven artifacts have been changed but not repinned. Requires the maven_install_json to have been set. | False | # Maven specification functions diff --git a/maven_install.json b/maven_install.json index 10a014573..fd6b71979 100644 --- a/maven_install.json +++ b/maven_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": -13350534, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 750470154, + "__RESOLVED_ARTIFACTS_HASH": -13350534, "conflict_resolution": {}, "dependencies": [ { diff --git a/repositories.bzl b/repositories.bzl index b2c09fa5e..9299c7ac5 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -13,5 +13,6 @@ def rules_jvm_external_deps(repositories = _DEFAULT_REPOSITORIES): "com.google.cloud:google-cloud-storage:1.113.4", ], maven_install_json = "@rules_jvm_external//:rules_jvm_external_deps_install.json", + fail_if_repin_required = True, repositories = repositories, ) diff --git a/rules_jvm_external_deps_install.json b/rules_jvm_external_deps_install.json index c840bed33..54694083a 100644 --- a/rules_jvm_external_deps_install.json +++ b/rules_jvm_external_deps_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 877247292, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 792085290, + "__RESOLVED_ARTIFACTS_HASH": 258092686, "conflict_resolution": {}, "dependencies": [ { @@ -350,14 +352,14 @@ "coord": "com.google.code.gson:gson:2.8.6", "dependencies": [], "directDependencies": [], - "file": "v1/https/jcenter.bintray.com/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar", + "file": "v1/https/repo1.maven.org/maven2/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar", "mirror_urls": [ "https://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar", "https://jcenter.bintray.com/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar", "https://maven.google.com/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" ], "sha256": "c8fb4839054d280b3033f800d1f5a97de2f028eb8ba2eb458ad287e536f3f25f", - "url": "https://jcenter.bintray.com/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" + "url": "https://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar" }, { "coord": "com.google.errorprone:error_prone_annotations:2.4.0", @@ -376,14 +378,14 @@ "coord": "com.google.guava:failureaccess:1.0.1", "dependencies": [], "directDependencies": [], - "file": "v1/https/jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "mirror_urls": [ "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "https://jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", "https://maven.google.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" ], "sha256": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26", - "url": "https://jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + "url": "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" }, { "coord": "com.google.guava:guava:30.0-android", @@ -411,14 +413,14 @@ "coord": "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", "dependencies": [], "directDependencies": [], - "file": "v1/https/jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "mirror_urls": [ "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "https://jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "https://maven.google.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" ], "sha256": "b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99", - "url": "https://jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + "url": "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" }, { "coord": "com.google.http-client:google-http-client-appengine:1.38.0", @@ -576,14 +578,14 @@ "io.opencensus:opencensus-api", "com.google.guava:guava" ], - "file": "v1/https/jcenter.bintray.com/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar", + "file": "v1/https/repo1.maven.org/maven2/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar", "mirror_urls": [ "https://repo1.maven.org/maven2/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar", "https://jcenter.bintray.com/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar", "https://maven.google.com/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar" ], "sha256": "7155273bbb1ed3d477ea33cf19d7bbc0b285ff395f43b29ae576722cf247000f", - "url": "https://jcenter.bintray.com/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar" + "url": "https://repo1.maven.org/maven2/io/opencensus/opencensus-contrib-http-util/0.24.0/opencensus-contrib-http-util-0.24.0.jar" }, { "coord": "javax.annotation:javax.annotation-api:1.3.2", @@ -602,14 +604,14 @@ "coord": "org.checkerframework:checker-compat-qual:2.5.5", "dependencies": [], "directDependencies": [], - "file": "v1/https/jcenter.bintray.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", + "file": "v1/https/repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "mirror_urls": [ "https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "https://jcenter.bintray.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar", "https://maven.google.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar" ], "sha256": "11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a", - "url": "https://jcenter.bintray.com/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar" + "url": "https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar" }, { "coord": "org.threeten:threetenbp:1.5.0", diff --git a/tests/custom_maven_install/json_artifacts_testing_install.json b/tests/custom_maven_install/json_artifacts_testing_install.json index ae8d6b264..b144b2dd7 100644 --- a/tests/custom_maven_install/json_artifacts_testing_install.json +++ b/tests/custom_maven_install/json_artifacts_testing_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 1307948384, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 2095795909, + "__RESOLVED_ARTIFACTS_HASH": 1307948384, "conflict_resolution": {}, "dependencies": [ { diff --git a/tests/custom_maven_install/manifest_stamp_testing_install.json b/tests/custom_maven_install/manifest_stamp_testing_install.json index 9975f6b37..9d6a6f971 100644 --- a/tests/custom_maven_install/manifest_stamp_testing_install.json +++ b/tests/custom_maven_install/manifest_stamp_testing_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 1670744372, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 504078643, + "__RESOLVED_ARTIFACTS_HASH": 1670744372, "conflict_resolution": {}, "dependencies": [ { diff --git a/tests/custom_maven_install/maven_install.json b/tests/custom_maven_install/maven_install.json index b943d45b2..e35875986 100644 --- a/tests/custom_maven_install/maven_install.json +++ b/tests/custom_maven_install/maven_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 522253421, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 1727988957, + "__RESOLVED_ARTIFACTS_HASH": 522253421, "conflict_resolution": {}, "dependencies": [ { diff --git a/tests/custom_maven_install/policy_pinned_testing_install.json b/tests/custom_maven_install/policy_pinned_testing_install.json index 8efc4e9ec..2ad80c7df 100644 --- a/tests/custom_maven_install/policy_pinned_testing_install.json +++ b/tests/custom_maven_install/policy_pinned_testing_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 740235710, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": -1726667074, + "__RESOLVED_ARTIFACTS_HASH": 740235710, "conflict_resolution": {}, "dependencies": [ { diff --git a/tests/custom_maven_install/regression_testing_install.json b/tests/custom_maven_install/regression_testing_install.json index 1e8e64acd..a686dad0e 100644 --- a/tests/custom_maven_install/regression_testing_install.json +++ b/tests/custom_maven_install/regression_testing_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": -1776905028, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 1561270278, + "__RESOLVED_ARTIFACTS_HASH": -1755419239, "conflict_resolution": {}, "dependencies": [ { @@ -4610,10 +4612,10 @@ { "coord": "org.openjfx:javafx-base:11.0.1", "dependencies": [ - "org.openjfx:javafx-base:jar:linux:11.0.1" + "org.openjfx:javafx-base:jar:mac:11.0.1" ], "directDependencies": [ - "org.openjfx:javafx-base:jar:linux:11.0.1" + "org.openjfx:javafx-base:jar:mac:11.0.1" ], "file": "v1/https/repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1.jar", "mirror_urls": [ @@ -4625,21 +4627,21 @@ "url": "https://repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1.jar" }, { - "coord": "org.openjfx:javafx-base:jar:linux:11.0.1", + "coord": "org.openjfx:javafx-base:jar:mac:11.0.1", "dependencies": [ - "org.openjfx:javafx-base:jar:linux:11.0.1" + "org.openjfx:javafx-base:jar:mac:11.0.1" ], "directDependencies": [ - "org.openjfx:javafx-base:jar:linux:11.0.1" + "org.openjfx:javafx-base:jar:mac:11.0.1" ], - "file": "v1/https/repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-linux.jar", + "file": "v1/https/repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-mac.jar", "mirror_urls": [ - "https://repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-linux.jar", - "https://maven.google.com/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-linux.jar", - "https://packages.confluent.io/maven/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-linux.jar" + "https://repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-mac.jar", + "https://maven.google.com/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-mac.jar", + "https://packages.confluent.io/maven/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-mac.jar" ], - "sha256": "2ebf6fa2cbbe1c8b4f7780e06e97beb038f644d5ecf9f15a41c5e88ee0ef9cf1", - "url": "https://repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-linux.jar" + "sha256": "2d8052a08fd2e5d98e1d5a16d724ea5dd02102879de20a193225f57199803983", + "url": "https://repo1.maven.org/maven2/org/openjfx/javafx-base/11.0.1/javafx-base-11.0.1-mac.jar" }, { "coord": "org.ow2.asm:asm-analysis:6.2", diff --git a/tests/custom_maven_install/unsafe_shared_cache_with_pinning_install.json b/tests/custom_maven_install/unsafe_shared_cache_with_pinning_install.json index 1e9473d6c..cf7a09984 100644 --- a/tests/custom_maven_install/unsafe_shared_cache_with_pinning_install.json +++ b/tests/custom_maven_install/unsafe_shared_cache_with_pinning_install.json @@ -1,6 +1,8 @@ { "dependency_tree": { - "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": -1675048513, + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 1727988957, + "__RESOLVED_ARTIFACTS_HASH": -1675048513, "conflict_resolution": {}, "dependencies": [ { diff --git a/tests/unit/coursier_test.bzl b/tests/unit/coursier_test.bzl index 645c20fe3..a95b4063f 100644 --- a/tests/unit/coursier_test.bzl +++ b/tests/unit/coursier_test.bzl @@ -2,6 +2,7 @@ load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") load( "//:coursier.bzl", "add_netrc_entries_from_mirror_urls", + "compute_dependency_inputs_signature", "extract_netrc_from_auth_url", "get_netrc_lines_from_entries", "get_coursier_cache_or_default", @@ -9,6 +10,8 @@ load( "split_url", infer = "infer_artifact_path_from_primary_and_repos", ) +load("//:specs.bzl", "maven") + ALL_TESTS = [] @@ -476,6 +479,23 @@ def _get_coursier_cache_or_default_enabled_with_home_dot_coursier_directory_test get_coursier_cache_or_default_enabled_with_home_dot_coursier_directory_test = add_test(_get_coursier_cache_or_default_enabled_with_home_dot_coursier_directory_test) +def _calculate_inputs_hash_does_not_care_about_input_order_test(ctx): + env = unittest.begin(ctx) + + # Order of artifacts is switched in each hash + hash1 = compute_dependency_inputs_signature([ + """{"group": "first", "artifact": "artifact", "version": "version"}""", + """{"group": "second", "artifact": "artifact", "version": "version"}""", + ]) + hash2 = compute_dependency_inputs_signature([ + """{"group": "second", "artifact": "artifact", "version": "version"}""", + """{"group": "first", "artifact": "artifact", "version": "version"}""", + ]) + + return unittest.end(env) + +calculate_inputs_hash_does_not_care_about_input_order_test = add_test(_calculate_inputs_hash_does_not_care_about_input_order_test) + def coursier_test_suite(): unittest.suite( "coursier_tests",