-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
144 lines (120 loc) · 3.8 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
buildscript {
}
apply plugin: "java"
apply plugin: "maven"
apply plugin: "maven-publish"
apply plugin: "jacoco"
group 'io.github.msangel'
version '1.0.3-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
// https://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-integration-testing/#comment-1197634
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8'
compile 'com.github.petitparser:petitparser-core:2.2.0'
testCompile 'org.hamcrest:hamcrest-core:2.1'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.+'
integrationTestCompile 'org.assertj:assertj-core:3.0.0'
}
wrapper {
doLast {
delete "${projectDir}/gradlew.bat"
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
def releasesRepoUrl = "${project.rootDir}/repos/releases"
def snapshotsRepoUrl = "${project.rootDir}/repos/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.8
}
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.8
}
}
}
}
test {
testLogging {
// Make sure output from
// standard out or error is shown
// in Gradle output.
showStandardStreams = true
// Or we use events method:
// events 'standard_out', 'standard_error'
// Or set property events:
// events = ['standard_out', 'standard_error']
// Instead of string values we can
// use enum values:
// events org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_OUT,
// org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_ERROR,
}
}
task integrationTest(type: Test) {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
// https://mrhaki.blogspot.com/2014/10/gradle-goodness-show-standard-out-or.html
events = [ /*"started", */"skipped", "passed", "failed" /*, 'standard_out', 'standard_error'*/]
showExceptions = true
showCauses = true
showStackTraces = true
}
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
// Makes integration tests not run by default.
check.dependsOn -= integrationTest
tasks.jacocoTestCoverageVerification.dependsOn(jacocoTestReport)
tasks.publish.dependsOn(jacocoTestCoverageVerification)
tasks.publish.dependsOn(build)
tasks.install.dependsOn(build)
defaultTasks 'install'
// make idea aware of it correctly
apply plugin: 'idea'
idea {
module {
testSourceDirs += project.sourceSets.integrationTest.java.srcDirs
testSourceDirs += project.sourceSets.integrationTest.resources.srcDirs
scopes.TEST.plus += [configurations.integrationTestCompile]
scopes.TEST.plus += [configurations.integrationTestRuntime]
}
}