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

Gradle plugin 1.7.0 fails with latest Spring Boot 3.1.2, Gradle Kotlin 8.3 with "Task with name 'bootRun' not found in root project" #121

Open
matthewadams opened this issue Aug 21, 2023 · 5 comments

Comments

@matthewadams
Copy link

Steps to reproduce:

  • Generate a new Gradle Kotlin Spring Boot project (see settings below) from start.spring.io
image
  • Update gradle to 8.3 in gradle/wrapper/gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
  • Add the springdoc plugin to the project:
...
plugins {
	id("org.springframework.boot") version "3.1.2"
	id("io.spring.dependency-management") version "1.1.2"
	id("org.springdoc.openapi-gradle-plugin") version "1.7.0" // <-- added
	kotlin("jvm") version "1.8.22"
	kotlin("plugin.spring") version "1.8.22"
}
...
  • Issue command ./gradlew generateOpenApiDocs, observe failure
$ ./gradlew generateOpenApiDocs

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/matthewadams/Downloads/demo/build.gradle.kts' line: 3

* What went wrong:
An exception occurred applying plugin request [id: 'org.springdoc.openapi-gradle-plugin', version: '1.7.0']
> Failed to apply plugin 'org.springdoc.openapi-gradle-plugin'.
   > Task with name 'bootRun' not found in root project 'demo'.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 307ms
@matthewadams matthewadams changed the title Gradle plugin 1.7.0 fails with latest Spring Boot 3.1.2, Gradle 8.3 with "Task with name 'bootRun' not found in root project" Gradle plugin 1.7.0 fails with latest Spring Boot 3.1.2, Gradle Kotlin 8.3 with "Task with name 'bootRun' not found in root project" Aug 21, 2023
@nbam-e
Copy link

nbam-e commented Aug 22, 2023

@matthewadams I had the same issue with bootRun not found after upgrading.

In our case our plugins section looked like this:

plugins {
	id 'org.springframework.boot' version '2.7.14'
	id 'org.springdoc.openapi-gradle-plugin' version '1.7.0'
	id 'java'
}

The issue went away when reordering this to

plugins {
	id 'java'
	id 'org.springframework.boot' version '2.7.14'
	id 'org.springdoc.openapi-gradle-plugin' version '1.7.0'
}

So maybe try with kotlin before springboot?

It seems that the openapi plugin now depends on a particular initialization order whereas previously (before 1.7.0) it did not matter. If this behavior change is intentional, it should probably be documented somewhere.

@Leprechaunz
Copy link

I'm having same issue with version 1.7.0.

  • First project (Spring Boot 3.1.2, Gradle 8.1.1) was fixed by adding id("application") as first plugin. @nbam-e 's idea about moving Kotlin before Spring Boot also worked for me.
  • Second project (Spring Boot 2.7.14, Gradle 7.6.1) was fixed with same way as first project (by adding id("application")).
  • Third project (Spring Boot 2.7.14, Gradle 8.1.1) didn't work at all.

Looks like there is a workaround. But it's not working for combination of Spring Boot 2.7.14 & Gradle 8.1.1.

@matthewadams
Copy link
Author

Sure enough, reording like this got rid of the problem:

plugins {
	kotlin("jvm") version "1.8.22"
	kotlin("plugin.spring") version "1.8.22"
	id("org.springframework.boot") version "3.1.2"
	id("org.springdoc.openapi-gradle-plugin") version "1.7.0"
	id("io.spring.dependency-management") version "1.1.2"
}

This either needs to be identified as a bug and fixed, or at least documented.

Thanks! 🙏🏼

@vanta
Copy link

vanta commented Sep 6, 2023

Any update here? Gradle 8 is out for some time, same for SpringBoot 3, and looks like it's not easy to work with them using springdoc

orchestr7 added a commit to saveourtool/app-cloud-template that referenced this issue Mar 12, 2024
### What's done:
- fixing the task using a workaround springdoc/springdoc-openapi-gradle-plugin#121
orchestr7 added a commit to saveourtool/app-cloud-template that referenced this issue Mar 13, 2024
### What's done:
- fixing the task using a workaround springdoc/springdoc-openapi-gradle-plugin#121
@vlsi
Copy link

vlsi commented Mar 13, 2024

I guess the fix (at springdoc-openapi-gradle-plugin side) is

a) Either stop using bootRun task directly (e.g. here

// The task, used to run the Spring Boot application (`bootRun`)
val bootRunTask = tasks.named(SPRING_BOOT_RUN_TASK_NAME)
). Is the task really helpful?
b) Wait for both org.springframework.boot and java plugins, and massage bootRun only in case both plugins are added (see https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#reacting-to-other-plugins.java ). For instance: plugins.withId("org.springframework.boot") { plugins.withId("java") { massageBootRunTask() } }

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

5 participants