-
Notifications
You must be signed in to change notification settings - Fork 4
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
Migrate from bazel-distribution to rules_jvm_external for Maven distribution #39
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e71ff9a
swap to maven_export for distribution
sugarmanz 442846c
swap to maven_publish for staged-maven-deploy.sh
sugarmanz 75d4b50
distribution kwargs
sugarmanz d6eeb58
deploy_env and excluded_workspaces
sugarmanz 260f273
remove kt_android as it's not yet ready
sugarmanz ed5f24b
--experimental_google_legacy_api for sync & build
sugarmanz 2e6ec7b
use embedded jdk
sugarmanz 80a7c40
remove unused kt_jvm params
sugarmanz 8148d3a
add pom_template to kt_jvm
sugarmanz 9ed35f8
common rc flags
sugarmanz d6e63ab
only load js rules for js test
sugarmanz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Use embedded JDK | ||
common --repo_env=JAVA_HOME=../bazel_tools/jdk | ||
common --experimental_google_legacy_api |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,15 @@ | ||
load("@vaticle_bazel_distribution//maven:rules.bzl", "assemble_maven", "deploy_maven", "MavenDeploymentInfo") | ||
load("@rules_jvm_external//:defs.bzl", "maven_export") | ||
load("//internal:scope_name.bzl", "scope_name") | ||
|
||
def distribution( | ||
*, | ||
name, | ||
|
||
release_repo, | ||
snapshot_repo, | ||
version_file, | ||
|
||
# (optional) | ||
project_name = None, | ||
project_description = None, | ||
project_url = None, | ||
scm_url = None, | ||
developers = None, | ||
|
||
workspace_refs = None, | ||
): | ||
assemble_name = scope_name(name, "assemble") | ||
assemble_maven( | ||
name = assemble_name, | ||
target = ":%s" % name, | ||
project_name = project_name, | ||
project_description = project_description, | ||
project_url = project_url, | ||
scm_url = scm_url, | ||
developers = developers, | ||
version_file = version_file, | ||
workspace_refs = workspace_refs, | ||
maven_coordinates, | ||
lib_name = None, | ||
**kwargs): | ||
maven_export( | ||
name = scope_name(name, "export"), | ||
lib_name = lib_name if lib_name else name, | ||
maven_coordinates = maven_coordinates, | ||
**kwargs | ||
) | ||
|
||
install_maven( | ||
name = scope_name(name, "install"), | ||
target = ":%s" % assemble_name, | ||
) | ||
|
||
deploy_maven( | ||
name = scope_name(name, "deploy"), | ||
target = ":%s" % assemble_name, | ||
release = release_repo, | ||
snapshot = snapshot_repo, | ||
) | ||
|
||
def _install_maven_impl(ctx): | ||
deployment_info = ctx.attr.target[MavenDeploymentInfo] | ||
file = deployment_info.jar | ||
|
||
script = ctx.actions.declare_file("%s-install" % ctx.label.name) | ||
script_content = "mvn install:install-file -Dfile={}".format(file.short_path,) | ||
ctx.actions.write(script, script_content, is_executable = True) | ||
|
||
runfiles = ctx.runfiles(files = [file]) | ||
return [DefaultInfo(executable = script, runfiles = runfiles)] | ||
|
||
install_maven = rule( | ||
implementation = _install_maven_impl, | ||
attrs = { | ||
"target": attr.label( | ||
mandatory = True, | ||
providers = [MavenDeploymentInfo], | ||
doc = "assemble_maven target to install", | ||
), | ||
}, | ||
executable = True, | ||
) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
load("//internal:maybe.bzl", "maybe") | ||
|
||
def maven(tag = "3.3", sha = "d85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab"): | ||
def maven(tag = "5.3", sha = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac"): | ||
maybe( | ||
http_archive, | ||
name = "rules_jvm_external", | ||
strip_prefix = "rules_jvm_external-%s" % tag, | ||
sha256 = sha, | ||
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % tag, | ||
) | ||
|
||
# Load maven rules from git | ||
def maven_repository( | ||
remote = "https://github.com/sugarmanz/rules_jvm_external.git", | ||
branch = "maven-export-aar", | ||
**kwargs): | ||
maybe( | ||
git_repository, | ||
name = "rules_jvm_external", | ||
remote = remote, | ||
branch = branch, | ||
**kwargs | ||
) |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plan is to try to get your PR in
rules_jvm_external
merged, yea?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, but IMO it's not really acceptable as-is. It requires an
--experimental_google_legacy_api
flag, which would require every consumer of the rules to enable that flag. I'm not sure what the path forward is, but will likely try to get some feedback from the team over there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened a PR for feedback:
bazel-contrib/rules_jvm_external#1049