Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Spring Boot gradle plugin configured in plugins DSL #893

Closed
PatrickWalter214 opened this issue Jul 13, 2024 · 2 comments
Closed

Comments

@PatrickWalter214
Copy link
Contributor

When the liberty gradle plugin is currently added to a new Spring Boot Application initialized by the Spring Initializr, the libertyDeploy task fails with the following error:

Caused by: java.lang.NullPointerException: Cannot invoke method getArchiveBaseName() on null object at io.openliberty.tools.gradle.tasks.DeployTask.installProjectArchive(DeployTask.groovy:128)

I had a look into the source code and came to the following conclusion:
springBootTask initialized in the DeployTask.groovy by findSpringBootTask(project, springBootVersion) is initializes with null. Looking at the findSpringBootTask method in AbstractLibertyTask.groovy this can happen if the provided springBootVersion is null. Looking at the find findSpringBootVersion method defined in AbstractLibertyTask.groovy, which initializes the springBootVersion in DeployTask.groovy, the method relies on finding the dependency with name "spring-boot-gradle-plugin".

Analyzing project.buildscript.configurations.classpath.getAllDependencies() with the configuration generated by the Spring Initializr reveals that the name of the dependency is in fact org.springframework.boot.gradle.plugin:

DefaultExternalModuleDependency{group='org.springframework.boot', name='org.springframework.boot.gradle.plugin', version='3.3.1', configuration='default'}

To enable an error free task one has to replace the "org.springframework.boot" plugin defined in the plugins block with the plugin application apply plugin: "org.springframework.boot" as described on the org.springframework.boot plugin page.

As defining the plugin in the plugins block seems to be the more modern way of adding plugins to a gradle build, they at least call the plugin application legacy on the org.springframework.boot plugin page, and as the Spring Initializr sets up new Spring Boot projects with the org.springframework.boot plugin inside the plugins block, I would like to see the liberty plugin adding support for this. In addition there is documentation for the liberty plugin in the README to also be added inside of the plugins block, so the plugins block way seems to be supported by the liberty plugin too.

I would like to contribute by simply accepting org.springframework.boot.gradle.plugin as a valid name in addition to spring-boot-gradle-plugin. Let me know if this would be ok as a contribution.

@cherylking
Copy link
Member

@PatrickWalter214 Thank you for reporting this and for your thorough investigation. We welcome contributions to improve our plugins. The contribution would just need a new or modified test that proves the fix works, and you would need to provide the CLA as described in the CONTRIBUTING doc.

@cherylking
Copy link
Member

Fixed via #909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants