ciscoo / cxf-codegen-gradle

Gradle plugin to generate Java artifacts from WSDL
Apache License 2.0
26 stars 6 forks source link

Using binding files fails with configuration cache enabled #98

Closed eye2web closed 5 months ago

eye2web commented 7 months ago

I'm getting the following error in combination with gradle cache / config cache.

 Task `:X` of type `io.mateo.cxf.codegen.wsdl2java.Wsdl2Java`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.5/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

Plugin version: 2.2.0 cxf version: 3.6.2 Gradle version: 8.5

ciscoo commented 7 months ago

Please provide an example.

eye2web commented 7 months ago

Here is an example:

val generatedFilesDir = layout.projectDirectory.file("build/generated").asFile

tasks.register("X", Wsdl2Java::class) {
    toolOptions {
        autoNameResolution.set(true)
        outputDir.set(generatedFilesDir)
        wsdl.set(layout.projectDirectory.file("src/main/resources/wsdl/X.wsdl").asFile.absolutePath)
        bindingFiles.add(layout.projectDirectory.file("src/main/resources/wsdl/X.xjb.xml").asFile.absolutePath)
    }
}

sourceSets {
    getByName("main") {
        java.srcDir(generatedFilesDir)
    }
}
ciscoo commented 7 months ago

I'm not able to reproduce using that example:

import io.mateo.cxf.codegen.wsdl2java.Wsdl2Java

plugins {
    java
    id("io.mateo.cxf-codegen") version "2.2.0"
}

repositories {
    mavenCentral()
}

val generatedFilesDir = layout.projectDirectory.file("build/generated").asFile

tasks.register("X", Wsdl2Java::class) {
    toolOptions {
        autoNameResolution.set(true)
        outputDir.set(generatedFilesDir)
        wsdl.set(layout.projectDirectory.file("src/main/resources/wsdl/X.wsdl").asFile.absolutePath)
        bindingFiles.add(layout.projectDirectory.file("src/main/resources/wsdl/X.xjb.xml").asFile.absolutePath)
    }
}

sourceSets {
    getByName("main") {
        java.srcDir(generatedFilesDir)
    }
}

Please provide a complete yet minimal sample that reproduces the problem. You can share it by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

eye2web commented 7 months ago

I Tried to reproduce the problem here: https://github.com/eye2web/cxf-codegen-gradle but I can'r reproduce it. Really strange.

I'm working on a big project that contains multiple includeBuilds using the plugin.

Sometimes i'm getting the error in 6 projects, sometimes in 3. Sometimes none. It's behaviour is strange.

3 problems were found reusing the configuration cache.
- Task `:y:y` of type `io.mateo.cxf.codegen.wsdl2java.Wsdl2Java`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.5/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
- Task `:x:x` of type `io.mateo.cxf.codegen.wsdl2java.Wsdl2Java`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.5/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
- Task `:z:z` of type `io.mateo.cxf.codegen.wsdl2java.Wsdl2Java`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.5/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
See the complete report at /build/reports/configuration-cache/afkrx92nbaxf3a9bn9wgem[482](-/jobs/978975#L482)/2ke5wz0qhzj9pxezanx4mvisk/configuration-cache-report.html
ciscoo commented 6 months ago

Using the provided project, I'm unable to reproduce myself as well.

However, I am wondering if this line specifically could be the potential culprit: https://github.com/ciscoo/cxf-codegen-gradle/blob/master/cxf-codegen-gradle/src/main/java/io/mateo/cxf/codegen/wsdl2java/Wsdl2Java.java#L96

In your project, if you remove setting bindingFiles, does the issue still occur?

eye2web commented 5 months ago

Thanks for your help :-) Temporarily removing the bindingFiles seems to work. Can I test the full behavior with bindingFiles with a snapshotversion if a potential fix comes available?

ciscoo commented 5 months ago

This has been fixed in the latest snapshot. Final release will be published once Gradle 8.6 is released.