springdoc-openapi-gradle-plugin icon indicating copy to clipboard operation
springdoc-openapi-gradle-plugin copied to clipboard

[Question] How to hook up generateOpenApiDocs to build task?

Open kkocel opened this issue 1 year ago • 3 comments

I would like to have openapi file generated during build time.

When I configure generateOpenApiDocs to be run after build:

tasks.named("build") {
    finalizedBy("generateOpenApiDocs")
}

I get the following error:

Some problems were found with the configuration of task ':forkedSpringBootRun' (type 'JavaExecFork').
  - Gradle detected a problem with the following location: '/Users/user/projects/service/build/classes/java/aot'.
    
    Reason: Task ':forkedSpringBootRun' uses this output of task ':compileAotJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Is there a recommended way to configure this? If so the it could be put in the README.

kkocel avatar Aug 23 '23 07:08 kkocel

Repository with reproduction - https://github.com/kkocel/openapigradlerepro

kkocel avatar Aug 29 '23 14:08 kkocel

I have a similar issue than @kkocel when attaching the "generateOpenApiDocs" to my gradle build task.

tasks.named("build") {
    finalizedBy("generateOpenApiDocs")
}

On my machine, the build fails for the following reasons:

  • Reason: Task ':app:forkedSpringBootRun' uses this output of task ':app:compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
  • Reason: Task ':app:forkedSpringBootRun' uses this output of task ':app:test' without declaring an explicit or implicit dependency.
  • Reason: Task ':app:forkedSpringBootRun' uses this output of task ':app:jar' without declaring an explicit or implicit dependency.
  • Reason: Task ':app:forkedSpringBootRun' uses this output of task ':app:bootJar' without declaring an explicit or implicit dependency.
  • Reason: Task ':app:forkedSpringBootRun' uses this output of task ':app:generateTestEffectiveLombokConfig' without declaring an explicit or implicit dependency.

I am using the gradle wrapper version 8.6

LaFrimousse avatar Feb 04 '24 08:02 LaFrimousse

Is there a working sample for this? Running into bunch of issues with forkedSpringBootRun when running with Gittlab Ci, but runs fine on the local machine.

pratikjain227 avatar Apr 09 '24 04:04 pratikjain227