title: Spring Boot: Use different Tomcat Version
body: <p>In Spring Boot Documentation there is a section <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html#_use_tomcat_7_x_or_8_0_with_gradle" rel="noreferrer">Use Tomcat 7.x or 8.0 with Gradle</a>
  This works great with Maven as shown in some spring-boot-samples, but unfortunately not for Gradle.</p>
  
  <p>Is there a easier solution than excluding all tomcat dependencies form tomcat-starter and add them separately with another version?</p>
  
  <p>To Reproduce:
  If you convert the sample project <a href="https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-tomcat80-ssl" rel="noreferrer">spring-boot-sample-tomcat80-ssl</a> into a Gradle project with following dependencies:</p>
  
  <pre><code>dependencies {
      compile("org.springframework.boot:spring-boot-starter:1.4.2.RELEASE")
      compile("org.springframework.boot:spring-boot-starter-tomcat:1.4.2.RELEASE")
      compile("org.springframework:spring-webmvc:4.3.4.RELEASE")
      compile("org.apache.httpcomponents:httpclient:4.5.2")
      compile("org.apache.tomcat:tomcat-juli:8.0.36")
      compile("org.yaml:snakeyaml:1.17")
      testCompile 'org.springframework.boot:spring-boot-starter-test:1.4.2.RELEASE'
  }
  </code></pre>
  
  <p>The output from <code>gradlew dependencies</code> looks like this:</p>
  
  <pre><code>compile - Dependencies for source set 'main'.
  +--- org.springframework.boot:spring-boot-starter:1.4.2.RELEASE
  |    +--- org.springframework.boot:spring-boot:1.4.2.RELEASE
  |    |    +--- org.springframework:spring-core:4.3.4.RELEASE
  |    |    |    \--- commons-logging:commons-logging:1.2
  |    |    \--- org.springframework:spring-context:4.3.4.RELEASE
  |    |         +--- org.springframework:spring-aop:4.3.4.RELEASE
  |    |         |    +--- org.springframework:spring-beans:4.3.4.RELEASE
  |    |         |    |    \--- org.springframework:spring-core:4.3.4.RELEASE (*)
  |    |         |    \--- org.springframework:spring-core:4.3.4.RELEASE (*)
  |    |         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
  |    |         +--- org.springframework:spring-core:4.3.4.RELEASE (*)
  |    |         \--- org.springframework:spring-expression:4.3.4.RELEASE
  |    |              \--- org.springframework:spring-core:4.3.4.RELEASE (*)
  |    +--- org.springframework.boot:spring-boot-autoconfigure:1.4.2.RELEASE
  |    |    \--- org.springframework.boot:spring-boot:1.4.2.RELEASE (*)
  |    +--- org.springframework.boot:spring-boot-starter-logging:1.4.2.RELEASE
  |    |    +--- ch.qos.logback:logback-classic:1.1.7
  |    |    |    +--- ch.qos.logback:logback-core:1.1.7
  |    |    |    \--- org.slf4j:slf4j-api:1.7.20 -&gt; 1.7.21
  |    |    +--- org.slf4j:jcl-over-slf4j:1.7.21
  |    |    |    \--- org.slf4j:slf4j-api:1.7.21
  |    |    +--- org.slf4j:jul-to-slf4j:1.7.21
  |    |    |    \--- org.slf4j:slf4j-api:1.7.21
  |    |    \--- org.slf4j:log4j-over-slf4j:1.7.21
  |    |         \--- org.slf4j:slf4j-api:1.7.21
  |    +--- org.springframework:spring-core:4.3.4.RELEASE (*)
  |    \--- org.yaml:snakeyaml:1.17
  +--- org.springframework.boot:spring-boot-starter-tomcat:1.4.2.RELEASE
  |    +--- org.apache.tomcat.embed:tomcat-embed-core:8.5.6
  |    +--- org.apache.tomcat.embed:tomcat-embed-el:8.5.6
  |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:8.5.6
  |         \--- org.apache.tomcat.embed:tomcat-embed-core:8.5.6
  +--- org.springframework:spring-webmvc:4.3.4.RELEASE
  |    +--- org.springframework:spring-aop:4.3.4.RELEASE (*)
  |    +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
  |    +--- org.springframework:spring-context:4.3.4.RELEASE (*)
  |    +--- org.springframework:spring-core:4.3.4.RELEASE (*)
  |    +--- org.springframework:spring-expression:4.3.4.RELEASE (*)
  |    \--- org.springframework:spring-web:4.3.4.RELEASE
  |         +--- org.springframework:spring-aop:4.3.4.RELEASE (*)
  |         +--- org.springframework:spring-beans:4.3.4.RELEASE (*)
  |         +--- org.springframework:spring-context:4.3.4.RELEASE (*)
  |         \--- org.springframework:spring-core:4.3.4.RELEASE (*)
  +--- org.apache.httpcomponents:httpclient:4.5.2
  |    +--- org.apache.httpcomponents:httpcore:4.4.4
  |    +--- commons-logging:commons-logging:1.2
  |    \--- commons-codec:commons-codec:1.9
  +--- org.apache.tomcat:tomcat-juli:8.0.36
  \--- org.yaml:snakeyaml:1.17
  </code></pre>
  
  <p>Executing the <code>SampleTomcatSslApplicationTests</code> you can see the wrong Tomcat Version in Logs:</p>
  
  <pre><code>2016-12-21 10:20:36.713  INFO 11368 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
  2016-12-21 10:20:36.714  INFO 11368 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
  </code></pre>
  
  <p><strong>SOLUTION</strong></p>
  
  <ul>
  <li>use spring boot gradle plugin -> here comes the magic</li>
  <li>set <code>ext['tomcat.version'] = '8.0.36'</code> in build script</li>
  </ul>