You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 71c8d9c
Browse filesBrowse the repository at this point in the historyBrowse files
[GRADLE-PLUGIN] Add schemaLocations (ConfigurableFileCollection) and expose schema tracking via extension DSL (#24979)
* Add schemaLocations (ConfigurableFileCollection) and expose schema tracking via extension DSL
- Add schemaLocations: ConfigurableFileCollection to GenerateTask, allowing
tracking of multiple files/dirs/trees as up-to-date/cache inputs for
\\\-referenced schemas, complementing the existing single-directory
schemaLocation.
- Fix schemaLocation/schemaLocations never being wired from
OpenApiGeneratorGenerateExtension to GenerateTask (openApiGenerate {
schemaLocation = ... } previously had no effect).
- Switch schemaLocation's PathSensitivity from ABSOLUTE to RELATIVE for
build-cache portability, matching sibling inputs (inputSpec,
inputSpecFiles, templateDir). schemaLocations also uses RELATIVE.
- Add setSchemaLocationsAsStrings(vararg paths: String) Groovy-friendly
bridge on both GenerateTask and the extension, and setSchemaLocation(String)
on the extension to enable Groovy \=\ assignment.
- Document both properties in README.adoc with Kotlin/Groovy DSL examples.
- Add tests: extension-to-task wiring, up-to-date/execute behavior, Groovy
bridge methods, and configuration-cache compatibility (store/reuse across
runs and after tracked schema file changes).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix misleading test names and assertions for schemaLocation/schemaLocations wiring
- Rename GenerateTaskConfigurationCacheTest case to reflect that the configuration
cache entry is reused (not invalidated) when a tracked schema file changes.
- Strengthen ParameterWiringRegressionTest schemaLocation/schemaLocations/
setSchemaLocationsAsStrings tests to assert UP_TO_DATE reuse and forced
re-execution after a tracked file change, so removing the wiring would fail them.
- Strengthen the equivalent GroovyBridgeMethodsTest for setSchemaLocationsAsStrings.
- Clarify in README.adoc that setSchemaLocationsAsStrings replaces rather than
appends to schemaLocations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: extract shared assertTrackedSchemaInput helper for schema wiring tests
Deduplicate the repeated initial-SUCCESS/unchanged-UP_TO_DATE/modified-SUCCESS
pattern across the schemaLocation, schemaLocations, and
setSchemaLocationsAsStrings tests in ParameterWiringRegressionTest.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Revert "test: extract shared assertTrackedSchemaInput helper for schema wiring tests"
This reverts commit 5666738.
* Reapply "test: extract shared assertTrackedSchemaInput helper for schema wiring tests"
This reverts commit 395e01a.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|Optional directory containing additional schema files referenced via `$ref` in the input specification. By default, Gradle only tracks `inputSpec` for up-to-date checks, so changes to `$ref`-referenced schema files elsewhere would not trigger re-generation. Declaring this directory makes Gradle track all files inside it too. This only affects up-to-date/cache tracking; it does not change how `$ref`s are resolved at generation time. For schemas that aren't all under one directory, use `schemaLocations` instead.
167
+
168
+
|schemaLocations
169
+
|ConfigurableFileCollection
170
+
|empty
171
+
|Like `schemaLocation`, but accepts any combination of individual files, multiple directories, or filtered file trees instead of a single whole directory, e.g. `schemaLocations.from("schemas/user.yaml", "schemas/order.yaml")` or `schemaLocations.from(fileTree("schemas") { include("*.yaml") })`. Since it isn't a `Provider`-based property, it does not support Groovy `=` assignment — use `.from(...)`, or the `setSchemaLocationsAsStrings(vararg paths)` convenience method.
172
+
163
173
|mergedFileName
164
174
|String / Provider<String>
165
175
|`merged`
@@ -559,6 +569,47 @@ models: "User:Pet"
559
569
----
560
570
====
561
571
572
+
==== Tracking additional schema files ($ref)
573
+
574
+
By default, Gradle only watches `inputSpec` for up-to-date checks, so changes to `$ref`-referenced
575
+
schema files elsewhere are not picked up automatically. Use `schemaLocation` (a single directory)
576
+
or `schemaLocations` (any combination of files, directories, or filtered file trees) to have Gradle
577
+
track them too. Neither property changes how `$ref`s are resolved at generation time — they only
Copy file name to clipboardExpand all lines: modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,8 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
Copy file name to clipboardExpand all lines: modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
+44Lines changed: 44 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,30 @@ open class OpenApiGeneratorGenerateExtension(private val project: Project) {
85
85
*/
86
86
val inputSpecFiles:ConfigurableFileCollection= project.objects.fileCollection()
87
87
88
+
/**
89
+
* Optional directory containing additional schema files referenced via `$ref` in the input
90
+
* specification, tracked for up-to-date checks.
91
+
*
92
+
* Declaring this directory tells Gradle to track all files inside it for up-to-date checks.
93
+
* Without it, changes to `$ref`-referenced schemas will not trigger re-generation because
94
+
* Gradle only watches [inputSpec] by default.
95
+
*
96
+
* For schemas that aren't all under one directory, use [schemaLocations] instead.
97
+
*/
98
+
val schemaLocation:DirectoryProperty= project.objects.directoryProperty()
99
+
100
+
/**
101
+
* Optional collection of additional schema files/directories referenced via `$ref` in the input
102
+
* specification, tracked for up-to-date checks.
103
+
*
104
+
* Unlike [schemaLocation], which only accepts a single whole directory, this accepts any
105
+
* combination of individual files, multiple directories, or filtered file trees, e.g.:
Copy file name to clipboardExpand all lines: modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
+38-1Lines changed: 38 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -367,12 +367,36 @@ abstract class GenerateTask : DefaultTask() {
367
367
* Declaring this directory tells Gradle to track all files inside it for up-to-date checks.
368
368
* Without it, changes to `$ref`-referenced schemas will not trigger re-generation because
369
369
* Gradle only watches [inputSpec] by default.
370
+
*
371
+
* For schemas that aren't all under one directory (individual files, multiple directories, or a
372
+
* filtered subset of a directory), use [schemaLocations] instead, which accepts any combination of
373
+
* files, directories, and file trees.
370
374
*/
371
375
@get:Optional
372
376
@get:InputDirectory
373
-
@get:PathSensitive(PathSensitivity.ABSOLUTE)
377
+
@get:PathSensitive(PathSensitivity.RELATIVE)
374
378
abstractval schemaLocation:DirectoryProperty
375
379
380
+
/**
381
+
* Optional collection of additional schema files/directories referenced via `$ref` in the input
382
+
* specification, tracked for up-to-date checks.
383
+
*
384
+
* Unlike [schemaLocation], which only accepts a single whole directory, this property is a
385
+
* [ConfigurableFileCollection] and can be populated with any combination of individual files,
386
+
* multiple directories, or filtered file trees, e.g.:
fun`openApiGenerate with schemaLocation and schemaLocations should re-execute but reuse configuration cache on schema file change`(gradleVersion:String, format:String) {
151
+
val propertyFormat =PropertyFormat.valueOf(format)
0 commit comments