Skip to content

Commit 799fd16

Browse files
committed
fix Gradle cache incompatibility (#99)
1 parent eaf47c5 commit 799fd16

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/main/kotlin/io/openapiprocessor/gradle/OpenApiProcessorPlugin.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class OpenApiProcessorPlugin: Plugin<Project> {
7777
val extension = getExtension(project)
7878
extension.processors.get().forEach { entry ->
7979
val name = "process${entry.key.replaceFirstChar { it.uppercase() }}"
80-
val action = createTaskBuilderAction(entry.key, entry.value)
80+
val action = createTaskBuilderAction(entry.key, entry.value, extension)
8181
project.tasks.register(name, OpenApiProcessorTask::class.java, action)
8282
}
8383
}
@@ -87,14 +87,15 @@ class OpenApiProcessorPlugin: Plugin<Project> {
8787
/**
8888
* Creates an Action that configures a 'process{ProcessorName}' task from its configuration.
8989
*/
90-
private fun createTaskBuilderAction(name: String, processor: Processor): Action<OpenApiProcessorTask> {
90+
private fun createTaskBuilderAction(name: String, processor: Processor, extension: OpenApiProcessorExtension):
91+
Action<OpenApiProcessorTask> {
92+
9193
return object: Action<OpenApiProcessorTask> {
9294
// copy common api path to openapi-processor props if not set
9395
fun copyApiPath (task: OpenApiProcessorTask) {
9496
if(processor.hasApiPath ())
9597
return
9698

97-
val extension = getExtension(task.project)
9899
if (!extension.api.isPresent) {
99100
task.logger.warn ("'${EXTENSION_NAME_DEFAULT}.apiPath'!")
100101
return
@@ -116,8 +117,11 @@ class OpenApiProcessorPlugin: Plugin<Project> {
116117
override fun execute(task: OpenApiProcessorTask) {
117118
val project = task.project
118119

120+
task.getRootDir().set(project.rootDir.absolutePath)
121+
task.getCheckUpdates().set(extension.checkUpdates)
119122
task.getProcessorName().set(processor.name)
120123
task.getProcessorProps().set(processor.other)
124+
121125
task.group = "openapi processor"
122126
task.description = "process openapi with openapi-processor-${processor.name}"
123127

src/main/kotlin/io/openapiprocessor/gradle/OpenApiProcessorTask.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class OpenApiProcessorTask: DefaultTask() {
3737
abstract fun getApiDir(): DirectoryProperty
3838

3939
/**
40-
* mapping.yaml input file. Used by gradle for the up-to-date check.
40+
* mapping.yaml input file. Used by Gradle for the up-to-date check.
4141
*
4242
* @return mapping.yaml
4343
*/
@@ -77,6 +77,12 @@ abstract class OpenApiProcessorTask: DefaultTask() {
7777
@Internal
7878
abstract fun getProcessorProps(): MapProperty<String, Any>
7979

80+
@Internal
81+
abstract fun getCheckUpdates(): Property<String>
82+
83+
@Internal
84+
abstract fun getRootDir(): Property<String>
85+
8086
@Inject
8187
abstract fun getWorkerExecutor(): WorkerExecutor
8288

@@ -85,18 +91,19 @@ abstract class OpenApiProcessorTask: DefaultTask() {
8591
*/
8692
@TaskAction
8793
fun runProcessor() {
94+
val theRootDir = getRootDir()
95+
val theCheckUpdates = getCheckUpdates()
8896
val theProcessorName = getProcessorName()
8997
val theProcessorProps = getProcessorProps()
90-
val extension = OpenApiProcessorExtensionUtils.getExtension(project)
9198

9299
getWorkerExecutor().classLoaderIsolation {
93100
classpath.from(getDependencies())
94101

95102
}.submit(OpenApiProcessorWorker::class.java) {
103+
getRootDir().set(theRootDir)
104+
getCheckUpdates().set(theCheckUpdates)
96105
getProcessorName().set(theProcessorName)
97106
getProcessorProps().set(theProcessorProps)
98-
getRootDir().set(project.rootDir.absolutePath)
99-
getCheckUpdates().set(extension.checkUpdates)
100107
}
101108
}
102109
}

src/testInt/groovy/io/openapiprocessor/gradle/KotlinDslSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class KotlinDslSpec extends PluginSpec {
8282
@Unroll
8383
void "test kotlin dsl with with gradle 9 (#gradleVersion)" () {
8484
when:
85-
def result = build(gradleVersion)
85+
def result = build(gradleVersion, "org.gradle.configuration-cache=true")
8686
8787
then:
8888
result.task(':processV1').outcome == SUCCESS

0 commit comments

Comments
 (0)