124 lines
3.6 KiB
Groovy
124 lines
3.6 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
mavenLocal()
|
|
maven { url "https://repo.spring.io/snapshot" }
|
|
maven { url "https://repo.spring.io/milestone" }
|
|
maven { url "https://repo.spring.io/release" }
|
|
maven { url 'https://repo.spring.io/plugins-snapshot' }
|
|
maven { url "https://repo.spring.io/plugins-release-local" }
|
|
maven { url "https://repo.spring.io/plugins-staging-local/" }
|
|
}
|
|
dependencies {
|
|
classpath "org.springframework.boot:spring-boot-gradle-plugin:${findProperty('bootVersion') ?: bootVersion}"
|
|
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${project.findProperty('verifierVersion') ?: verifierVersion}"
|
|
}
|
|
}
|
|
|
|
group = 'com.example'
|
|
version = '0.0.1-SNAPSHOT'
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
mavenLocal()
|
|
maven { url "https://repo.spring.io/snapshot" }
|
|
maven { url "https://repo.spring.io/milestone" }
|
|
maven { url "https://repo.spring.io/release" }
|
|
}
|
|
|
|
apply plugin: 'groovy'
|
|
apply plugin: 'org.springframework.boot'
|
|
apply plugin: 'io.spring.dependency-management'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'maven'
|
|
apply plugin: 'spring-cloud-contract'
|
|
|
|
dependencyManagement {
|
|
imports {
|
|
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
|
|
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${project.findProperty('verifierVersion') ?: verifierVersion}"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile("org.springframework.boot:spring-boot-starter-web")
|
|
compile("org.springframework.boot:spring-boot-starter-actuator")
|
|
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
|
|
|
testCompile 'org.springframework.boot:spring-boot-starter-test'
|
|
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner'
|
|
// tag::dependencies[]
|
|
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
|
|
testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc'
|
|
// end::dependencies[]
|
|
}
|
|
|
|
test {
|
|
systemProperty 'spring.profiles.active', 'gradle'
|
|
testLogging {
|
|
exceptionFormat = 'full'
|
|
}
|
|
afterSuite { desc, result ->
|
|
if (!desc.parent) {
|
|
println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
|
|
if (result.testCount == 0) {
|
|
throw new IllegalStateException("No tests were found. Failing the build")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
contracts {
|
|
baseClassMappings {
|
|
baseClassMapping('.*standalone.*', 'com.example.fraud.FraudBaseWithStandaloneSetup')
|
|
baseClassMapping('.*webapp.*', 'com.example.fraud.FraudBaseWithWebAppSetup')
|
|
}
|
|
}
|
|
|
|
generateClientStubs.enabled = false
|
|
|
|
task stubsJar(type: Jar, dependsOn: ['copySnippets', 'copySources', 'copyClasses']) {
|
|
baseName = project.name
|
|
classifier = 'stubs'
|
|
from project.file("${project.buildDir}/stubs")
|
|
}
|
|
|
|
artifacts {
|
|
archives stubsJar
|
|
}
|
|
|
|
task copySnippets(type: Copy, dependsOn: test) {
|
|
from "target/snippets/stubs"
|
|
into "${project.buildDir}/stubs/META-INF/${project.group}/${project.name}/${project.version}/mappings"
|
|
}
|
|
|
|
task copySources(type: Copy) {
|
|
from "src/main/java"
|
|
include '**/model/Fraud*.*'
|
|
into "${project.buildDir}/stubs/"
|
|
}
|
|
|
|
task copyClasses(type: Copy) {
|
|
from "${project.buildDir}/classes/main/"
|
|
include '**/model/Fraud*.*'
|
|
into "${project.buildDir}/stubs/"
|
|
}
|
|
|
|
clean.doFirst {
|
|
delete 'target/snippets/stubs'
|
|
delete "~/.m2/repository/com/example/http-server-restdocs-gradle"
|
|
}
|
|
|
|
task resolveDependencies {
|
|
doLast {
|
|
project.rootProject.allprojects.each { subProject ->
|
|
subProject.buildscript.configurations.each { configuration ->
|
|
configuration.resolve()
|
|
}
|
|
subProject.configurations.each { configuration ->
|
|
configuration.resolve()
|
|
}
|
|
}
|
|
}
|
|
}
|