-
Notifications
You must be signed in to change notification settings - Fork 221
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 process based plugins to Smithy build #1672
Merged
Merged
Conversation
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
mtdowling
force-pushed
the
run-plugin
branch
6 times, most recently
from
March 12, 2023 04:44
c598d38
to
8508f4a
Compare
This commit adds the ability to integrate smithy build with process based plugins so that the Smithy CLI will be able to call other CLI tools through a process based plugin model. To do this, I've introduced the `run` plugin which takes a `command` array containing the program to run and arguments to provide. The plugin will open a process and send the serialized Smithy model to the standard input of the process. The process can then perform its logic and write files in the working directory its called with. A couple things are still missing here that we should figure out later: 1. The only way to see the output of a plugin is using --debug in the CLI. Should there be an output to somehow always show it? That will require some kind of hackery in the CLI I think. 2. There is no way currently to indicate the process is "serial" like how other Smithy Build plugins can. Serial indicates that a plugin requires some kind of global locking (like file locks) and can't be run in parallel with other plugins. In addition to adding the run plugin, you can also apply the same plugin multiple times in a single projectiony by giving it a custom artifact name using the "artifact-name via plugin-name" syntax.
sugmanue
approved these changes
Mar 13, 2023
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.
I left some minor notes.
smithy-utils/src/main/java/software/amazon/smithy/utils/IoUtils.java
Outdated
Show resolved
Hide resolved
smithy-utils/src/main/java/software/amazon/smithy/utils/IoUtils.java
Outdated
Show resolved
Hide resolved
smithy-utils/src/main/java/software/amazon/smithy/utils/IoUtils.java
Outdated
Show resolved
Hide resolved
smithy-build/src/main/java/software/amazon/smithy/build/SmithyBuildImpl.java
Show resolved
Hide resolved
sugmanue
approved these changes
Mar 13, 2023
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.
I just noted some duplication, not sure if those are per-design, i.e., part of the tests. I added a comments anyway.
smithy-build/src/main/java/software/amazon/smithy/build/plugins/RunPlugin.java
Show resolved
Hide resolved
smithy-build/src/test/java/software/amazon/smithy/build/SmithyBuildTest.java
Show resolved
Hide resolved
smithy-build/src/test/java/software/amazon/smithy/build/model/SmithyBuildConfigTest.java
Outdated
Show resolved
Hide resolved
sugmanue
approved these changes
Mar 14, 2023
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.
This commit adds the ability to integrate smithy build with process based plugins so that the Smithy CLI will be able to call other CLI tools through a process based plugin model.
To do this, I've introduced the
run
plugin which takes acommand
array containing the program to run and arguments to provide. The plugin will open a process and send the serialized Smithy model to the standard input of the process. The process can then perform its logic and write files in the working directory its called with.A couple things are still missing here that we should figure out later:
In addition to adding the
run
plugin, you can also apply the same plugin multiple times in a single projectiony by giving it a custom artifact name using the "plugin-name::artifact-name" syntax.Example:
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.