-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use attr.output instead of deprecated outputs dict #21
Merged
johnynek
merged 1 commit into
bazeltools:master
from
CodeIntelligenceTesting:prepare-for-bzlmod-2
Oct 15, 2022
Merged
Changes from all commits
Commits
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
Empty file.
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,46 @@ | ||
def _jar_jar_impl(ctx): | ||
rule_file = ctx.file.rules | ||
if rule_file != None and ctx.attr.inline_rules != []: | ||
fail("Using both a rules file and inline_rules are incompatible; use one or the other.") | ||
if rule_file == None and ctx.attr.inline_rules == []: | ||
fail("You have to specify either a rules file or inline_rules.") | ||
if rule_file == None: | ||
rule_file = ctx.actions.declare_file("jar_jar-rules-" + ctx.label.name + ".tmp") | ||
ctx.actions.write( | ||
output = rule_file, | ||
content = "\n".join(ctx.attr.inline_rules) | ||
) | ||
|
||
args = ctx.actions.args() | ||
args.add("process") | ||
args.add(rule_file) | ||
args.add(ctx.file.input_jar) | ||
args.add(ctx.outputs.output_jar) | ||
|
||
ctx.actions.run( | ||
inputs = [rule_file, ctx.file.input_jar], | ||
outputs = [ctx.outputs.output_jar], | ||
executable = ctx.executable._jarjar_runner, | ||
progress_message = "jarjar %s" % ctx.label, | ||
arguments = [args], | ||
) | ||
|
||
return [ | ||
JavaInfo( | ||
output_jar = ctx.outputs.output_jar, | ||
compile_jar = ctx.outputs.output_jar, | ||
), | ||
DefaultInfo(files = depset([ctx.outputs.output_jar])), | ||
] | ||
|
||
jar_jar = rule( | ||
implementation = _jar_jar_impl, | ||
attrs = { | ||
"output_jar": attr.output(mandatory = True), | ||
fmeum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"input_jar": attr.label(allow_single_file = True), | ||
"rules": attr.label(allow_single_file = True), | ||
"inline_rules" : attr.string_list(), | ||
"_jarjar_runner": attr.label(executable = True, cfg = "exec", default = "//src/main/java/com/github/johnynek/jarjar:app"), | ||
}, | ||
provides = [JavaInfo], | ||
) |
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
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.
another update we should consider is using
java_common
to run ajar on the output jar to make a compile jar.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.
Did this in #24. The previous PR also broke a few tests I didn't notice, which is fixed by #22.