feat(no-ticket): add Maven shell-plugin credential helper#314
Draft
cloudsmith-iduffy wants to merge 1 commit into
Draft
feat(no-ticket): add Maven shell-plugin credential helper#314cloudsmith-iduffy wants to merge 1 commit into
cloudsmith-iduffy wants to merge 1 commit into
Conversation
Maven has no native credential-helper protocol, so add a shell-plugin approach: a `mvn` shim (placed first on PATH via `credential-helper shell-init`) transparently forwards to the generic top-level `cloudsmith exec`, which provisions an ephemeral settings.xml from the resolved credential (API key or OIDC), runs the real `mvn`, and cleans up. - `cloudsmith exec -- <cmd>`: runs a package-manager command authenticated against Cloudsmith. The plugin is inferred from the command's binary name; unmatched commands run unchanged. Resolves the real binary while excluding the shims dir to avoid recursion, and cleans up temp dirs (even on failure, with provisioning errors surfaced as a clean message, never a traceback). - `credential-helper install maven --org --repo [--registry-id]` and `credential-helper shell-init`, wired into the existing installer registry. - One injected <server> authenticates both dependency resolution (download CDN) and distributionManagement (native Maven upload); Maven matches it by id. Install prints the distributionManagement snippet for opt-in deploy. - Custom Cloudsmith domains are org-scoped via a reusable common.repo_path_segment (drop <org> for custom domains, keep it for *.cloudsmith.io); download custom domains carry backend_kind=None, upload custom domains carry BackendKind.MAVEN. - settings.xml / distributionManagement live in cloudsmith_cli/templates/*.tmpl rendered via a shared templates.render() (also adopted by webserver.py). - Shell-plugin state is stored as [package-manager:<format>] sections in package-managers.ini in the CLI config dir, via configparser. - The `--registry-id` flag and the shared PluginEntry field use a package-manager-neutral name (Maven <server> id, NuGet source key, etc.). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5d8b024 to
cbb6c35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a Maven credential helper to the CLI. Maven has no native credential-helper protocol, so this uses a shell-plugin approach: a
mvnshim (placed first onPATHviacloudsmith credential-helper shell-init) transparently forwards tocloudsmith exec -- mvn …, which provisions an ephemeralsettings.xmlfrom the resolved credential (API key or OIDC), runs the realmvn, and cleans up afterwards.Highlights:
cloudsmith exec— a generic, top-level command that runs any command with Cloudsmith credentials provisioned for it; the package manager is inferred from the command (no format argument), and commands with no integration run unchanged. Pluscredential-helper shell-initandinstall maven(with--repo/--server-id).<server>authenticates both dependency resolution (download CDN) anddistributionManagement(native Maven upload) — Maven matches it by<id>, not host.common.repo_path_segmenthelper org-scopes Cloudsmith URLs (a custom domain is bound to one org, so the<org>path segment is dropped; the*.cloudsmith.iodefaults keep it). Used by both the download and upload URLs.settings.xmllives incloudsmith_cli/templates/maven_settings.xml.tmpl(real XML, editor-validated) and is rendered via a sharedtemplates.render()thatwebserver.pyalso uses.plugins.json, shims) lives in the CLI config dir (get_default_config_path()), consistent with the custom-domain cache.Proven end-to-end with GitHub OIDC (no API key anywhere) — install, build (download), and a native
mvn clean deploy(upload), with~/.m2caching:Type of Change
Additional Notes
install maven,eval "$(… shell-init)",mvn clean deploy.find_packages/ existingpackage_data; no packaging changes needed.