-
Notifications
You must be signed in to change notification settings - Fork 312
/
build.gradle
121 lines (105 loc) · 3.41 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
plugins {
id 'groovy'
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'org.springframework.cloud.contract'
id 'maven-publish'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
repositories {
mavenCentral()
mavenLocal()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/release" }
}
ext {
set('springCloudVersion', "${BOM_VERSION}")
}
println "Boot Version [${bootVersion}], Cloud version [${BOM_VERSION}], Contract version [${verifierVersion}]"
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.cloud:spring-cloud-starter-stream-rabbit")
testImplementation('org.springframework.cloud:spring-cloud-stream-test-binder')
testImplementation('javax.inject:javax.inject:1')
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
testImplementation("org.springframework.cloud:spring-cloud-starter-contract-verifier")
testImplementation("org.springframework.cloud:spring-cloud-contract-wiremock")
// for compatibility
testImplementation('org.junit.jupiter:junit-jupiter-engine')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
contracts {
contractsDslDir = file("src/test/resources/contracts")
testFramework = "JUNIT5"
packageWithBaseClasses = 'com.example'
}
contractTest {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
afterSuite { desc, result ->
if (!desc.parent) {
println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
boolean skipTests = Boolean.parseBoolean(project.findProperty('SKIP_TESTS') ?: "false")
if (result.testCount == 0 && !skipTests) {
throw new IllegalStateException("No tests were found. Failing the build")
}
}
}
}
test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
afterSuite { desc, result ->
if (!desc.parent) {
println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
boolean skipTests = Boolean.parseBoolean(project.findProperty('SKIP_TESTS') ?: "false")
if (result.testCount == 0 && !skipTests) {
throw new IllegalStateException("No tests were found. Failing the build")
}
}
}
}
// we want to override the default Spring Cloud Contract behaviour and generate JAR in a custom way
task stubsJar(type: Jar) {
archiveClassifier = "stubs"
into('/') {
include('**/com/example/model/*.*')
from("${project.rootDir}/src/main/java/")
}
into('/') {
include('**/com/example/model/*.*')
from("${project.buildDir}/classes/main")
}
into("META-INF/${project.group}/${project.name}/${project.version}/mappings") {
include('**/*.*')
from("${project.rootDir}/target/snippets/stubs")
}
into("META-INF/${project.group}/${project.name}/${project.version}/contracts") {
include('**/*.groovy')
from("${project.rootDir}/src/test/resources/contracts")
}
}
// we need the tests to pass to build the stub jar
stubsJar.dependsOn(test)
publishing {
publications {
myPublicationName(MavenPublication) {
artifact stubsJar
}
}
}
clean.doFirst {
delete 'target/'
}