Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @rules_jvm_external//pin:pin as a convenience script to pin all maven_installs in a workspace #411

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jin
Copy link
Member

@jin jin commented May 22, 2020

e.g. for this repo, there are 7 maven_install external repositories:

//external:unpinned_unsafe_shared_cache_with_pinning
//external:unpinned_regression_testing
//external:unpinned_policy_pinned_testing
//external:unpinned_maven_install_in_custom_location
//external:unpinned_maven
//external:unpinned_manifest_stamp_testing
//external:unpinned_json_artifacts_testing

Running @rules_jvm_external//pin runs the :pin target on every single one of them, making batch-pinning easy.

@joprice
Copy link
Contributor

joprice commented Jun 8, 2020

I ran this locally bazel query //external/... and I see pins of dependencies showing up as well:

...
//external:unpinned_annex_scalafmt
//external:unpinned_annex_proto
//external:unpinned_annex

I didn't realize that they were using the same mechanism, and never thought about how they were being pinned. Choosing one and running bazel run @unpinned_annex//:pin results in a new json pin file being generated at the root of the repo. In the case of this script, will that wind up in the right place or is this a special case?

@jin
Copy link
Member Author

jin commented Jun 9, 2020

Oh! That's an edge case I haven't thought about. This script currently doesn't handle those unpinned repos correctly, because the maven_install.json are pulled from the dependencies as well. cc @borkaehw

This is one of the reasons why I recommend not sharing maven_install.json to downstream dependents if one is publishing a library. Instead, export the list of artifacts and let downstream dependencies pin their maven_install directly.

(
cd $BUILD_WORKING_DIRECTORY
# TODO: use --ui_event_filters to filter DEBUG lines away when it's in a Bazel release.
for R in $(bazel query --noshow_progress --noshow_loading_progress //external:all | grep unpinned);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably can also add kind(coursier_fetch, ...) filter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attr(generator_name, unpinned_maven, ...) is also an option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants