Files
spring-cloud-contract/samples/standalone/webclient/http-server/build.gradle
Marcin Grzejszczak 01a4c9a23c Works with JDK16
2021-05-05 13:15:47 +02:00

125 lines
3.2 KiB
Groovy

plugins {
id "groovy"
id "org.springframework.boot"
id "io.spring.dependency-management"
id "maven-publish"
/**
* While the SCC Gradle plugin is not strictly necessary for this project.
* It is included to ensure that if the contractDslDir does not exist, then
* the plugin reports "NO-SOURCE" for associated tasks, rather than resulting
* in an error for the end user.
*/
id "org.springframework.cloud.contract"
}
group = 'com.example'
version = '0.0.1'
repositories {
mavenCentral()
mavenLocal()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/release" }
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${BOM_VERSION}"
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${verifierVersion}"
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-actuator")
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.restdocs:spring-restdocs-webtestclient'
testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock'
}
contracts {
failOnNoContracts = false
}
generateClientStubs.enabled = false
test {
useJUnitPlatform()
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")
}
}
}
}
task stubsJar(type: Jar, dependsOn: ['copySnippets', 'copySources', 'copyClasses']) {
baseName = project.name
classifier = 'stubs'
from project.file("${project.buildDir}/stubs")
}
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/"
}
publishing {
publications {
maven(MavenPublication) {
artifact bootJar
artifact stubsJar
// https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/273
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
clean.doFirst {
delete 'target/snippets/stubs'
delete "~/.m2/repository/com/example/http-server-webclient-gradle"
}
task resolveDependencies {
doLast {
project.rootProject.allprojects.each { subProject ->
subProject.buildscript.configurations.each { configuration ->
configuration.resolve()
}
subProject.configurations.each { configuration ->
configuration.resolve()
}
}
}
}