Add provided scope to war

This commit is contained in:
Dave Syer 2014-06-04 15:31:11 +01:00
parent 32b99a8350
commit 4f772e4a99
4 changed files with 50 additions and 32 deletions

View File

@ -3,7 +3,7 @@ package ${packageName};
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

View File

@ -1,9 +1,9 @@
buildscript {
ext {
springBootVersion = '${bootVersion}'
}
ext {
springBootVersion = '${bootVersion}'
}
repositories {
mavenCentral()<% if (!bootVersion.contains("RELEASE")) { %>
mavenCentral()<% if (!bootVersion.contains("RELEASE")) { %>
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
<% } %>
@ -34,9 +34,14 @@ repositories {
<% } %>
}
<% if (packaging=='war') { %>configurations {
providedRuntime
}
<% } %>
dependencies {<% styles.each { %>
compile("org.springframework.boot:spring-boot-starter${it}")<% } %>
<% if (language=='groovy') { %>compile("org.codehaus.groovy:groovy")<% } %>
compile("org.springframework.boot:spring-boot-starter${it}")<% } %><% if (language=='groovy') { %>
compile("org.codehaus.groovy:groovy")<% } %><% if (packaging=='war') { %>
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")<% } %>
testCompile("org.springframework.boot:spring-boot-starter-test")
}

View File

@ -26,6 +26,11 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency><% } %><% if (packaging=='war') { %>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency><% } %>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -46,30 +51,30 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin><% if (language=='groovy') { %>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.8-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
<extensions>true</extensions>
</plugin><% } %>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.8-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
<extensions>true</extensions>
</plugin><% } %>
</plugins>
</build><% if (!bootVersion.contains("RELEASE")) { %>

View File

@ -28,9 +28,17 @@ class IntegrationTests {
}
@Test
void webIsAdded() {
void webIsAddedPom() {
String body = new TestRestTemplate().getForObject('http://localhost:' + port + '/pom.xml?packaging=war', String)
assertTrue('Wrong body:\n' + body, body.contains('spring-boot-starter-web'))
assertTrue('Wrong body:\n' + body, body.contains('provided'))
}
@Test
void webIsAddedGradle() {
String body = new TestRestTemplate().getForObject('http://localhost:' + port + '/build.gradle?packaging=war', String)
assertTrue('Wrong body:\n' + body, body.contains('spring-boot-starter-web'))
assertTrue('Wrong body:\n' + body, body.contains('providedRuntime'))
}
@Test