Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Gradle Tomcat 8

The Spring Boot reference guide provides instructions for upgrading to Tomcat 8 by setting a custom property in Maven:

<properties>
  <tomcat.version>8.0.3</tomcat.version>
</properties>

What is the equivalent way to do the same in a Gradle build?

I have tried the following to no avail. It stays on version 7.0.52 at app startup.

buildscript {
  ...    
  ext['tomcat.version'] = '8.0.3'
  ...
}
like image 348
craig.schneider Avatar asked Mar 24 '14 21:03

craig.schneider


1 Answers

Gradle has no equivalent of a "parent pom", so you have to call out the dependency explicitly. Because it's groovy you can probably do it programmatically, something like:

configurations.all {
  resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    if (details.requested.group == 'org.apache.tomcat.embed') {
        details.useVersion '8.0.3'
    }
  }
}  

We could add some support for version properties to the Spring Boot Gradle plugin (feel free to open an issue in github) but it would probably have to be optional.

like image 189
Dave Syer Avatar answered Oct 23 '22 12:10

Dave Syer