gretty-gradle-plugin / gretty

Advanced gradle plugin for running web-apps on jetty and tomcat.
MIT License
129 stars 36 forks source link

For a non spring boot application, gretty is complaining for spring boot dependency #247

Open dhamep opened 2 years ago

dhamep commented 2 years ago

I have upgraded the gretty version 1.1.2 to 3.0.6. since then its failing at

Caused by: org.gradle.api.GradleException: Could not generate a proxy class for class 
  org.akhikhl.gretty.AppBeforeIntegrationTestTask.
  at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:220)
  at org.gradle.api.internal.AbstractClassGenerator.generate(AbstractClassGenerator.java:49) 
  at org.gradle.api.internal.project.taskfactory.TaskFactory.createTaskObject(TaskFactory.java:116) 
  at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:81) 
  at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.j ...... 
  at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52) ...
104 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer 
  at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:112) ... 
120 more 
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer

Indeed we do have this following setting:

void excludeUnneededGrettyDependencies() { // we do not need hot appl redeploy and this allows us to
  // get rid of unwanted spring boot 3rd party dependencies
  project.gretty {
    springBoot = false
  }
}

Because of which earlier version 1.1.2 version didn't complains for spring boot dependency. Can you please confirm why this is complaining now? Or any specific version i can use to get rid of this error?

f4lco commented 2 years ago

Hi @dhamep, 1.1.2 to 3.0.6 - that's an upgrade 🙂

So I do not think that springBoot = false is the root cause here, because the majority of our integration tests are not Spring Boot apps and have that toggle set to false. Also, that springBoot toggle takes effect on the classpath of the webapp, not on the classpath Gradle uses for executing the plugin. We are talking about the latter here - Gradle fails to instantiate one of the tasks of Gretty. That makes me wonder if any other dependency exclusions exist in your project.

So I can confirm that Gretty-the-plugin has a dependency on Spring Boot to provide that dev server functionality and cannot run without that dependency. Maybe that dev server feature came in after 1.1.2, which would explain why this failure you are observing is new.

So I would suggest you check the output of ./gradlew buildEnvironment to really make sure that the Spring Boot dependency is there. Below I included an example output from https://github.com/gretty-gradle-plugin/gretty-sample:

buildEnvironment of gretty-sample ``` $ gw buildEnvironment > Task :buildEnvironment ------------------------------------------------------------ Root project 'gretty-sample' ------------------------------------------------------------ classpath \--- org.gretty:org.gretty.gradle.plugin:3.0.6 \--- org.gretty:gretty:3.0.6 +--- org.gretty:gretty-core:3.0.6 | +--- commons-cli:commons-cli:1.3.1 | +--- commons-configuration:commons-configuration:1.10 | | +--- commons-lang:commons-lang:2.6 | | \--- commons-logging:commons-logging:1.1.1 | +--- commons-io:commons-io:2.4 | +--- org.apache.commons:commons-lang3:3.3.2 | +--- org.bouncycastle:bcprov-jdk15on:1.60 | +--- org.springframework.boot:spring-boot-devtools:2.0.2.RELEASE | | +--- org.springframework.boot:spring-boot:2.0.2.RELEASE | | | +--- org.springframework:spring-core:5.0.6.RELEASE | | | | \--- org.springframework:spring-jcl:5.0.6.RELEASE | | | \--- org.springframework:spring-context:5.0.6.RELEASE | | | +--- org.springframework:spring-aop:5.0.6.RELEASE | | | | +--- org.springframework:spring-beans:5.0.6.RELEASE | | | | | \--- org.springframework:spring-core:5.0.6.RELEASE (*) | | | | \--- org.springframework:spring-core:5.0.6.RELEASE (*) | | | +--- org.springframework:spring-beans:5.0.6.RELEASE (*) | | | +--- org.springframework:spring-core:5.0.6.RELEASE (*) | | | \--- org.springframework:spring-expression:5.0.6.RELEASE | | | \--- org.springframework:spring-core:5.0.6.RELEASE (*) | | \--- org.springframework.boot:spring-boot-autoconfigure:2.0.2.RELEASE | | \--- org.springframework.boot:spring-boot:2.0.2.RELEASE (*) | \--- org.gretty:gretty-common:3.0.6 | \--- org.slf4j:slf4j-api:1.7.32 +--- org.springframework.boot:spring-boot-loader-tools:2.0.2.RELEASE | +--- org.springframework:spring-core:5.0.6.RELEASE (*) | \--- org.apache.commons:commons-compress:1.14 \--- org.eclipse.jetty:jetty-util:8.1.22.v20160922 (*) - dependencies omitted (listed previously) A web-based, searchable dependency report is available by adding the --scan option. BUILD SUCCESSFUL in 1s 1 actionable task: 1 executed ```

When Gradle executes the build script and processes the Gretty plugin application with that Spring Boot dependency on the classpath, the error should disappear.