Gradle plugin with multi-spec support - #12
Merged
Merged
Conversation
JustworksPlugin, JustworksExtension, JustworksGenerateTask, JustworksSharedTypesTask, JustworksSpecConfiguration for multi-spec DSL. Functional tests included. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Introduced `generateTo` methods in `ApiResponseGenerator`, `ModelGenerator`, and `ClientGenerator` to streamline file generation and output directory management. - Updated `JustworksGenerateTask` to use the new methods with enhanced polymorphic type handling.
…teTo methods - Unified `ApiResponseGenerator`, `ModelGenerator`, and `ClientGenerator` under `CodeGenerator` to streamline generation logic. - Removed redundant `generateTo` methods, simplifying file generation and output handling. - Updated Gradle tasks to leverage the new `CodeGenerator` structure.
- Removed redundant parameter formatting in `writeFile` and `runner` methods. - Bumped Arrow dependency version from `2.1.2` to `2.2.1.1`. - Applied consistent formatting in assertion blocks for readability.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new plugin Gradle submodule that exposes the core OpenAPI parser/generator as a Gradle plugin with a multi-spec DSL, plus functional coverage to validate end-to-end generation in a consumer build.
Changes:
- Introduces
com.avsystem.justworksGradle plugin with multi-spec DSL (justworks { specs { ... } }) and per-spec generation tasks. - Adds Gradle tasks for spec-based generation and one-time shared type generation, wiring outputs into the main source set and
compileKotlin. - Extracts a
CodeGeneratorfacade incoreand expands functional tests for plugin behavior.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle.kts | Includes new plugin subproject in the build. |
| plugin/build.gradle.kts | New Gradle plugin module build, plus functional test source set/task setup. |
| plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksPlugin.kt | Registers extension and tasks per spec; wires generated sources + compileKotlin dependency. |
| plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksExtension.kt | Adds NamedDomainObjectContainer-based DSL root for multi-spec configuration. |
| plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksSpecConfiguration.kt | Per-spec configuration model (spec file + packages). |
| plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksGenerateTask.kt | Cacheable task that parses spec and writes generated sources. |
| plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksSharedTypesTask.kt | Cacheable task for shared response/error type generation. |
| plugin/src/functionalTest/kotlin/.../JustworksPluginFunctionalTest.kt | TestKit functional suite validating tasks, outputs, and multi-spec behavior. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/CodeGenerator.kt | New facade for orchestrating generation and writing files. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/ApiResponseGenerator.kt | Adds helper generate() to return shared-type FileSpecs list. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/ClientGenerator.kt | Minor formatting change (currently introduces extra blank line). |
| .gitignore | Adds common Gradle/IDE/build output ignores. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
packageName was only used to derive apiPackage/modelPackage, which is already done in JustworksPlugin before wiring task inputs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MattK97
requested changes
Mar 19, 2026
- Add deleteRecursively() to JustworksSharedTypesTask before generation - Extract SerializersModule file name constant to SerializersModuleGenerator.FILE_NAME - Extract spec name regex and task name computation to JustworksPlugin companion - Eliminate duplicated taskName logic in source set wiring Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
MattK97
requested changes
Mar 19, 2026
…d generation into CodeGenerator - Changed `buildMapToResult` to use `@PublishedApi` and `internal` modifier for improved visibility and API stability. - Updated `generateSharedTypes` to include `ApiClientBaseGenerator` in file generation logic.
…adle tasks - Replaced repeated directory cleaning and creation logic with `cleanAndCreate` extension function. - Updated `
- Introduced `writeBuildFile` and `writeMultiSpecProject` helper methods to reduce duplication in test setup. - Added assertion for `ApiClientBase.kt` generation in shared types test.
…` for clarity - Updated directory handling logic in `JustworksGenerateTask` and `JustworksSharedTypesTask`. - Ensures consistent behavior for directory recreation across tasks.
- Applied `org.jetbrains.kotlinx.kover` plugin to `plugin/build.gradle.kts`. - Excluded `functionalTest` sources from coverage reporting. - Updated CI workflow to include plugin coverage report and upload it to Codecov.
…ecreateDirectoryTest` - Covers directory creation, content deletion, nested structure creation, and instance consistency.
|
halotukozak
added a commit
that referenced
this pull request
Mar 20, 2026
Gradle plugin with multi-spec support
This file contains hidden or 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
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.
Summary
JustworksPlugin— registers tasks per spec configurationJustworksExtensionwithNamedDomainObjectContainerfor multi-spec DSLJustworksGenerateTask— wires parser + generators into Gradle taskJustworksSharedTypesTask— generates shared API response typesJustworksSpecConfiguration— per-spec configuration (specFile, packages, outputDir)CodeGeneratorfacade — orchestrates model/client generation with file I/OTest plan
./gradlew plugin:testpasses./gradlew core:testpasses./gradlew plugin:functionalTestpassesReplaces #5 (closed due to deleted base branch)
🤖 Generated with Claude Code