Skip to content

Add a Gradle Plugin for codegen#1235

Open
adwsingh wants to merge 3 commits into
mainfrom
adwsingh/gradle-plugin
Open

Add a Gradle Plugin for codegen#1235
adwsingh wants to merge 3 commits into
mainfrom
adwsingh/gradle-plugin

Conversation

@adwsingh

Copy link
Copy Markdown
Contributor

What behavior changes?

Adds a Gradle plugin (software.amazon.smithy.java.gradle.smithy-java) that replaces manual smithy-base + afterEvaluate boilerplate with a single plugin application that auto-wires source sets, dependencies, and task ordering.

Why is this change needed?

Every customer project currently duplicates ~30 lines of Gradle plumbing to wire generated code. This plugin makes the zero-config path a one-liner and provides an explicit DSL (modes, generatedPluginOutputs) for customization.

How was this validated?

./gradlew :mcp:mcp-schemas:sourcesJar :mcp:mcp-schemas:jar --rerun-tasks --configuration-cache passes with correct service files in all artifacts. Configuration cache reuse confirmed on subsequent runs.

What should reviewers focus on?

SmithyJavaPlugin.java (dependency wiring via ValueSource, service-file merge with eachFile source-path filtering) and SmithyBuildModesValueSource.java (configuration cache tracked file read).

Additional Links

N/A


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

@adwsingh adwsingh requested review from sugmanue and yasmewad June 10, 2026 17:31
@adwsingh adwsingh force-pushed the adwsingh/gradle-plugin branch from b19eccd to 7687f8a Compare June 10, 2026 17:31
Comment thread gradle-plugin/build.gradle.kts Outdated

@Override
public void apply(Project project) {
project.getPlugins().apply(JavaLibraryPlugin.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of a server I believe this should be just java right?

Set<String> resolved = modes.get();
addIfAbsent(deps, project.getDependencies(), "codegen-plugin", version);
if (resolved.contains("client")) {
addIfAbsent(deps, project.getDependencies(), "client-core", version);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it need to be here? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codegen-plugin only has client-core as compileOnly, and client mode validates Client is present at runtime via Class.forName, so it does need to be present on the smithyBuild classpath. The dependency in the other block is for compiling/consuming the generated source.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this makes sense, but isn't it that for the clients client-core must be an api-level dependency as the codegen result depends on it and exposes some part of it? smithyBuild inherits implementation that inherits api iirc.

addIfAbsent(deps, project.getDependencies(), "client-core", version);
}
if (resolved.contains("server")) {
addIfAbsent(deps, project.getDependencies(), "server-api", version);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be part of implementation instead? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same rationale as the client-core comment

@adwsingh adwsingh force-pushed the adwsingh/gradle-plugin branch from 7687f8a to cc09ab3 Compare June 10, 2026 21:40
@adwsingh adwsingh force-pushed the adwsingh/gradle-plugin branch from c2c28b7 to 361bdd3 Compare June 10, 2026 22:55
@adwsingh adwsingh force-pushed the adwsingh/gradle-plugin branch from 361bdd3 to 4c661c2 Compare June 11, 2026 06:06
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.

3 participants