Reorganize integration tests

Make spring-boot-integration-tests a top level project and move the
existing gradle tests and security tests to be sub-modules.
This commit is contained in:
Phillip Webb
2015-02-23 16:53:53 -08:00
parent f0ef882ff2
commit 7ac8cac3b5
46 changed files with 61 additions and 32 deletions

View File

@@ -0,0 +1,30 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
jar {
baseName = 'classifier-extension'
}
springBoot {
classifier = 'exec'
mainClass = 'demo.Application'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.springframework:spring-core"
}

View File

@@ -0,0 +1,30 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
jar {
baseName = 'classifier'
}
bootRepackage {
classifier = 'exec'
mainClass = 'demo.Application'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.springframework:spring-core"
}

View File

@@ -0,0 +1,63 @@
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
repositories {
mavenLocal()
mavenCentral()
}
configurations {
exclusions
springVersion
}
apply plugin: 'spring-boot'
dependencies {
exclusions "org.springframework.boot:spring-boot-starter"
springVersion "org.springframework:spring-core"
versionManagement files('../../src/test/resources/custom-versions.properties')
}
task checkExclusions {
doFirst {
def commonsLogging = getResolvedDependencies(configurations.exclusions)
.find { it.selected.id.group == 'commons-logging' }
if (commonsLogging) {
throw new GradleException("commong-logging is a transitive dependency")
}
}
}
task checkSpringVersion {
doFirst {
def springVersions = getResolvedDependencies(configurations.springVersion)
.findAll{it.selected.id.group == 'org.springframework'}
.collect {it.selected.id.version}
if (springVersions.size() != 1 || !springVersions.contains("4.0.3.RELEASE")) {
throw new GradleException("Spring version was not 4.0.3.RELEASE")
}
}
}
def getResolvedDependencies(def configuration) {
def allDependencies = configuration.incoming
.resolutionResult.allDependencies
.split { it instanceof UnresolvedDependencyResult }
def unresolved = allDependencies.first()
def resolved = allDependencies.last()
if (unresolved) {
throw new GradleException("Resolution failed: ${unresolved}")
}
resolved
}

View File

@@ -0,0 +1,2 @@
org.springframework\:spring-core=4.0.3.RELEASE
org.springframework.boot\:spring-boot-starter=1.1.0.RELEASE

View File

@@ -0,0 +1,29 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'spring-boot'
group = 'flatdir'
version = '0.0.0'
run {
main = 'Foo'
}
jar {
baseName = 'flatdir'
}
repositories {
flatDir( dirs:'lib' )
}
dependencies {
compile ':foo:1.0.0'
}

View File

@@ -0,0 +1,32 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'installer'
version = '0.0.0'
run {
main = 'org.springframework.boot.SpringApplication'
}
jar {
baseName = 'install-app'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter"
}

View File

@@ -0,0 +1,41 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'installer'
version = '0.0.0'
install {
repositories.mavenInstaller {
pom.project {
parent {
groupId 'org.springframework.boot'
artifactId 'spring-boot-starter-parent'
version "${project.bootVersion}"
}
}
}
}
jar {
baseName = 'installer'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
versionManagement 'io.spring.platform:platform-versions:1.0.0.RELEASE@properties'
compile "org.springframework.boot:spring-boot-starter"
}

View File

@@ -0,0 +1,40 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'installer'
version = '0.0.0'
install {
repositories.mavenInstaller {
pom.project {
parent {
groupId 'org.springframework.boot'
artifactId 'spring-boot-starter-parent'
version "${project.bootVersion}"
}
}
}
}
jar {
baseName = 'installer'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter"
}

View File

@@ -0,0 +1,32 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'installer'
version = '0.0.0'
run {
main = 'org.springframework.boot.SpringApplication'
}
jar {
baseName = 'installer'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter"
}

View File

@@ -0,0 +1,28 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
}
}
subprojects {
apply plugin: 'java'
dependencies {
compile rootProject.files {'lib/foo.jar'}
}
}
apply plugin: 'spring-boot'
springBoot {
mainClass = 'foo.bar.Baz'
}
dependencies {
compile project(':one')
compile project(':two')
}

View File

@@ -0,0 +1,22 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
}
}
project(':projectA') {
apply plugin: 'spring-boot'
dependencies {
runtime project(':projectB')
}
bootRepackage {
mainClass 'com.foo.Bar'
}
}
project(':projectB') {
apply plugin: 'java'
}

View File

@@ -0,0 +1,40 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
}
}
project('main') {
apply plugin: 'spring-boot'
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile project(':common')
}
springBoot {
mainClass = 'foo.bar.Baz'
}
}
project('common') {
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "commons-logging:commons-logging:1.1.3"
compile files { "lib/foo.jar" }
}
}

View File

@@ -0,0 +1,30 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'spring-boot'
group = 'nojar'
version = '0.0.0'
jar {
enabled = false
}
bootRepackage {
enabled = false
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter'
}

View File

@@ -0,0 +1,50 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
}
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'spring-boot'
apply plugin: 'java'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-freemarker'
compile 'org.springframework.boot:spring-boot-starter-web'
compile files("foo.jar")
}
springBoot {
mainClass = 'foo.bar.Baz'
}
bootRepackage.enabled = Boolean.valueOf(project.repackage)
task customJar(type: Jar) {
archiveName = 'custom.jar'
from sourceSets.main.output
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
task customRepackagedJar(type: BootRepackage, dependsOn: customJar) {
withJarTask = customJar
}
task customRepackagedJarWithStringReference(type: BootRepackage, dependsOn: customJar) {
withJarTask = 'customJar'
}

View File

@@ -0,0 +1,30 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
classpath("org.springframework:springloaded:${project.springLoadedVersion}")
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter")
}
applicationDefaultJvmArgs = [
"-DSOME_ARG=someValue"
]
jar {
baseName = 'spring-loaded-jvm-args'
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
public class Application {
public static void main(String[] args) throws Exception {
PrintWriter writer = new PrintWriter(new FileWriter(new File("build/output.txt")));
for (String argument: ManagementFactory.getRuntimeMXBean().getInputArguments()) {
writer.println(argument);
}
writer.close();
}
}

View File

@@ -0,0 +1,26 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
classpath("org.springframework:springloaded:${project.springLoadedVersion}")
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter")
}
jar {
baseName = 'spring-loaded-old-gradle'
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;
public class Application {
public static void main(String[] args) throws Exception {
PrintWriter writer = new PrintWriter(new FileWriter(new File("build/output.txt")));
for (String argument: ManagementFactory.getRuntimeMXBean().getInputArguments()) {
writer.println(argument);
}
writer.close();
}
}

View File

@@ -0,0 +1,60 @@
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
repositories {
mavenLocal()
mavenCentral()
}
configurations {
springBootStarter
}
dependencies {
springBootStarter "org.springframework.boot:${project.starter}:${project.bootVersion}"
}
apply plugin: 'spring-boot'
task checkCommonsLogging {
doFirst {
def commonsLogging = resolvedDependencies
.find { it.selected.id.group == 'commons-logging' }
if (commonsLogging) {
throw new GradleException("${project.starter} pulls in commons-logging")
}
}
}
task checkSpring {
doFirst {
def wrongSpring = resolvedDependencies
.findAll{it.selected.id.group == 'org.springframework'}
.findAll{it.selected.id.version != project.springVersion}
.collect {it.selected.id}
if (wrongSpring) {
throw new GradleException("${project.starter} pulled in ${wrongSpring as Set}")
}
}
}
def getResolvedDependencies() {
def allDependencies = configurations.springBootStarter.incoming
.resolutionResult.allDependencies
.split { it instanceof UnresolvedDependencyResult }
def unresolved = allDependencies.first()
def resolved = allDependencies.last()
if (unresolved) {
throw new GradleException("Resolution of ${project.starter} failed: ${unresolved}")
}
resolved
}

View File

@@ -0,0 +1,27 @@
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
}
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'spring-boot'
apply plugin: 'war'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-freemarker'
providedRuntime "org.springframework.boot:spring-boot-starter-$servletContainer"
}
springBoot {
mainClass = 'foo.bar.Baz'
}