Skip to content

Proposal to change the com.github.johnrengelman.processes gradle process plugin #36

Closed
@kpramesh2212

Description

@kpramesh2212

Background:

Spring docs open api gradle plugin is used to generate the openapi.json or openapi.yaml file during the build process.

The plugin works as follows

  1. When this plugin is added to the project, it adds the following 2 tasks

    a) forkedSpringBootRun is of type com.github.jengelman.gradle.plugins.processes.tasks.Fork

    b) generateOpenApiDocs

  2. When the user calls the task gradle clean generateOpenApiDocs. The plugin make a call to forkedSpringBootRun task.

  3. forkedSpringBootRun task internally calls the bootJar task (added by the spring boot gradle plugin) and runs it in a separate process

  4. Finally generateOpenApiDocs makes a call to the spring boot apiDocs url which was started by forkedSpringBootRun task to generate the openapi.json or (.yaml) file and then at end shutdowns the forkedSpringBootRun process.

Proposal:

The proposal is to completely remove com.github.johnrengelman.processes plugin and use a much simpler process plugin called com.github.hesch.execfork

Why should we replace?

The following are the reasons to replace com.github.johnrengelman.processes plugin

  1. The plugin is very old and was developed for older versions of gradle. The plugin uses gradle api calls which are now deprecated in the newer versions of the gradle api.

  2. The developer of the plugin has not released any new updates for newer releases of gradle and the plugin seems to be not maintained any more.

  3. Internally we in the springdoc gradle plugin team have few issues which cannot be solved using this com.github.johnrengelman.processes plugin. The following are few examples

    a) The forkedSpringBootRun task is reliant on the bootJar task. This means before we can generate the openapi.json file the spring boot jar needs to be completely build. There are some users who would like to have the openapi.json file added to the spring boot jar. The only way to accomplish this is to rebuild the jar using another gradle task which is not very good approach

    b) Adding JVM arguments and environmental properties we have to write our own logic and expose them as gradle extension properties (see forkProperties). Customizing the boot application becomes complex

    c) The forkedSpringBootRun starts the spring boot application using the system JVM which might not be feasible for many users who might have different JVM in their IDE. In order to fix this issue we would again need to expose another gradle extension property (say javaHome).

    e) There is a critical error that pops up when we try to use ForkJavaTask from com.github.johnrengelman.processes plugin due to deprecated and removed gradle api

What is the replacement for com.github.johnrengelman.processes plugin

The replacement plugin that I am planning to use is called com.github.hesch.execfork

How will the Spring docs open api gradle plugin work?

Once we add the replacement plugin, the following steps describe how the plugin would work

  1. When spring docs open api gradle plugin is added to the gradle build it adds the following tasks

    a) forkedSpringBootRun is of type com.github.psxpaul.task.JavaExecFork

    b) generateOpenApiDocs

  2. When the user calls the task gradle clean generateOpenApiDocs. The plugin make a call to forkedSpringBootRun task.

  3. forkedSpringBootRuntask internally <b>copies all the task property values of the</b>bootRun` task (added by the spring boot gradle plugin) and runs it in a separate process. Please note at this stage no jar is build.

  4. Finally generateOpenApiDocs makes a call to the spring boot apiDocs url which was started by forkedSpringBootRun task to generate the openapi.json or (.yaml) file and then at end shutdowns the forkedSpringBootRun process.

Important

The main point is the users shouldn't see much difference in running the task.

Any configuration that user needs to provide like setting the environment variable, jvm argument, java home ect, the user can provide those by customization of bootRun task. We the springdoc openapi gradle plugin will automatically copy those values from the bootRun task and use it in our forkedBootRunTask. This way we dont have to provide any customization properties. This means we can drop the forkedProperties extension

One more advantage is forkedBootRunTask now doesnt invoke the jar building process. This mean user can generate the openapi.json file and now added to the jar file quite easily without having to duplicate the jar creation process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions