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 jar plugin #86

Merged
merged 2 commits into from
Aug 16, 2023
Merged

Add jar plugin #86

merged 2 commits into from
Aug 16, 2023

Conversation

hpmellema
Copy link
Contributor

Description of changes:

Adds a plugin that adds smithy files to an existing jar task.

The plugin requires that a plugin that creates a jar task be applied and adds the following when a prerequisite plugin has been added to the project:

  • A smithyJarStaging task that copies the smithy sources into the correct file structure for inclusion in a JAR
  • An updateJarManifest action that is added with doFirst to the jar task. This will add smithy-specific build info to the jar
  • A smithyJarValidate task that will validate the smithy sources added to the JAR created by the jar task

Note: The integ tests will be moved over to this plugin and the smithy-base plugin in a separate PR.

Smithy Validate Task

The smithy validate task remains largely unchanged from the existing implementation. It is renamed from Validate for clarity and updated to use lazy configuration.

SmithyJarStaging task

This task copies files in the source plugin of a projection into the correct file structure for inclusion into a jar as resources.
The logic in the SmithyJarStaging used to be included in the SmithyBuildJar task, but has been broken out for clarity, and so users can stage multiple jars from the outputs of a single SmithyBuildTask. The staging task is disabled by default if the JAR task is disabled so that unnecessary copying is avoided.

Manifest Action

The SmithyManifestUpdateAction updates the Manifest of a JAR task to contain smithy-specific information. It is invoked by attaching to a task as follows:

jarTask.doFirst("updateJarManifest", new SmithyManifestUpdateAction(project, tagSet));
This will update the manifest of the jar created by the jarTask to include some build information as well as any specified smithy source stages.

An example Manifest is provided as follows (from the adds-tags example):

Manifest-Version: 1.0
Build-Timestamp: 2023-07-26T13:35:45.191-0600
Created-With: Smithy-Gradle-Plugin (0.7.0), Gradle (8.2)
Build-Jdk: 17.0.7
Build-OS: Mac OS X x86_64 13.3.1
Smithy-Tags: software.amazon.smithy:adds-tags, software.amazon.smithy, software.amazon.smithy:adds-tags:9.9.9, Foo, Baz

Previously the Manifest was updated via a task (SmithyTags).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hpmellema hpmellema requested a review from a team as a code owner August 15, 2023 13:50
@hpmellema hpmellema merged commit 210ed29 into smithy-lang:main Aug 16, 2023
4 checks passed
@hpmellema hpmellema deleted the add-jar-plugin branch August 16, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants