Skip to content

Gradle plugin with multi-spec support - #12

Merged
halotukozak merged 15 commits into
masterfrom
feat/plugin
Mar 20, 2026
Merged

Gradle plugin with multi-spec support#12
halotukozak merged 15 commits into
masterfrom
feat/plugin

Conversation

@halotukozak

@halotukozak halotukozak commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • JustworksPlugin — registers tasks per spec configuration
  • JustworksExtension with NamedDomainObjectContainer for multi-spec DSL
  • JustworksGenerateTask — wires parser + generators into Gradle task
  • JustworksSharedTypesTask — generates shared API response types
  • JustworksSpecConfiguration — per-spec configuration (specFile, packages, outputDir)
  • CodeGenerator facade — orchestrates model/client generation with file I/O
  • Functional test suite

Test plan

  • ./gradlew plugin:test passes
  • ./gradlew core:test passes
  • ./gradlew plugin:functionalTest passes

Replaces #5 (closed due to deleted base branch)

🤖 Generated with Claude Code

halotukozak and others added 6 commits March 19, 2026 09:53
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.
Copilot AI review requested due to automatic review settings March 19, 2026 11:08
@halotukozak halotukozak self-assigned this Mar 19, 2026
@halotukozak
halotukozak requested review from mzielu and removed request for mzielu March 19, 2026 11:09

Copilot AI left a comment

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.

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.justworks Gradle 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 CodeGenerator facade in core and 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.

Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/ClientGenerator.kt Outdated
Comment thread plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksGenerateTask.kt Outdated
@halotukozak
halotukozak requested a review from MattK97 March 19, 2026 11:16
halotukozak and others added 2 commits March 19, 2026 12:18
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>
Comment thread plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksSharedTypesTask.kt Outdated
Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/CodeGenerator.kt Outdated
Comment thread plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksPlugin.kt Outdated
Comment thread plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksPlugin.kt Outdated
- 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>
Comment thread plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksGenerateTask.kt Outdated
…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.

@MattK97 MattK97 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, one minor thing

…ecreateDirectoryTest`

- Covers directory creation, content deletion, nested structure creation, and instance consistency.
@github-actions

Copy link
Copy Markdown
Overall Project 90.22% -1.3% 🍏
Files changed 18.64%

File Coverage
SerializersModuleGenerator.kt 100% 🍏
ApiClientBaseGenerator.kt 100% 🍏
ApiResponseGenerator.kt 92.42% -7.58%
CodeGenerator.kt 0%

@halotukozak
halotukozak merged commit a6c7265 into master Mar 20, 2026
1 check passed
@halotukozak
halotukozak deleted the feat/plugin branch March 20, 2026 09:17
halotukozak added a commit that referenced this pull request Mar 20, 2026
Gradle plugin with multi-spec support
@halotukozak halotukozak added this to the 0.0.1 milestone Apr 2, 2026
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