-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle
258 lines (223 loc) · 7.12 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.junit.platform:junit-platform-gradle-plugin:1.0.2")
}
}
plugins {
id 'com.gradle.build-scan' version '1.11'
id "com.jfrog.bintray" version "1.8.0"
id "org.sonarqube" version "2.6.1"
id 'org.unbroken-dome.test-sets' version '1.4.2'
id "info.solidsoft.pitest" version "1.2.4"
}
ext {
JUNIT_JUPITER_VERSION = "5.0.2"
JUNIT_PLATFORM_VERSION = "1.0.2"
MOCKITO_VERSION = "2.12.0"
POWER_MOCK_UTILS_VERSION = "1.6.6"
ASSERTJ_CORE_VERSION = "3.8.0"
JACOCO_VERSION = "0.7.9"
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'maven-publish'
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
publishAlways()
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
configurations {
integrationTest
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
testSets {
integrationTest
}
project.integrationTest {
outputs.upToDateWhen { false }
}
idea {
module {
testSourceDirs += file('src/integrationTest/java')
scopes.TEST.plus += [configurations.integrationTestCompile]
scopes.TEST.plus += [configurations.integrationTestRuntime]
inheritOutputDirs = false
outputDir = compileJava.destinationDir
testOutputDir = compileTestJava.destinationDir
}
}
tasks.withType(Test) {
reports.html.destination file("${reporting.baseDir}/${name}")
}
junitPlatform {
enableStandardTestTask true
}
dependencies {
compile("org.slf4j:slf4j-api:1.7.25")
compile("org.apache.commons:commons-lang3:3.7")
compile("org.apache.commons:commons-collections4:4.1")
compile("com.googlecode.combinatoricslib:combinatoricslib:2.1")
compile("org.javassist:javassist:3.22.0-GA")
testCompile("org.projectlombok:lombok:1.16.18")
testCompile("org.junit.jupiter:junit-jupiter-api:${JUNIT_JUPITER_VERSION}") { changing = true }
testRuntime("org.junit.jupiter:junit-jupiter-engine:${JUNIT_JUPITER_VERSION}") { changing = true }
testCompile("org.junit.platform:junit-platform-runner:${JUNIT_PLATFORM_VERSION}") { changing = true }
testCompile("org.assertj:assertj-core:${ASSERTJ_CORE_VERSION}")
testCompile("org.mockito:mockito-core:${MOCKITO_VERSION}")
testCompile("org.powermock.tests:powermock-tests-utils:${POWER_MOCK_UTILS_VERSION}")
testCompileOnly("org.apiguardian:apiguardian-api:1.0.0")
}
afterEvaluate {
jacoco {
toolVersion JACOCO_VERSION
applyTo junitPlatformTest
}
task junit5CodeCoverageReport(type: JacocoReport) {
executionData junitPlatformTest
sourceSets sourceSets.main
sourceDirectories = files(project.sourceSets.main.allSource.srcDirs)
classDirectories = files(project.sourceSets.main.output)
reports {
xml.enabled = false
html.destination file("${buildDir}/reports/jacoco/html")
}
}
}
pitest {
exportLineCoverage = true
timestampedReports = false
targetClasses = ['pl.pojo.tester.*']
threads = 4
outputFormats = ['XML', 'HTML']
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
def pomConfig = {
licenses {
license {
name "GNU Lesser General Public License version 3"
url "https://opensource.org/licenses/lgpl-3.0.html"
}
}
developers {
developer {
id "sta-szek"
name "Piotr Joński"
email "p.jonski@pojo.pl"
}
}
scm {
url "https://github.com/sta-szek/pojo-tester"
connection "scm:git:git://github.com:sta-szek/pojo-tester.git"
developerConnection "scm:git:ssh://github.com:sta-szek/pojo-tester.git"
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'pl.pojo'
artifactId 'pojo-tester'
version rootProject.version
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('description', 'Java pojo-methods testing library.')
root.appendNode('name', 'pojo-tester')
root.appendNode('url', 'http://www.pojo.pl')
root.children().last() + pomConfig
}
}
}
}
publishing.publications.all {
pom.withXml {
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each { it.scope*.value = 'compile' }
}
}
bintray {
user = 'sta-szek'
key = System.getenv('BINTRAY_API_KEY')
publish = true
pkg {
repo = 'maven'
name = 'pojo-tester'
desc = 'Java pojo-methods testing library.'
websiteUrl = 'http://www.pojo.pl'
issueTrackerUrl = 'https://github.com/sta-szek/pojo-tester/issues'
vcsUrl = 'https://github.com/sta-szek/pojo-tester.git'
licenses = ['LGPL-3.0']
publications = ['mavenJava']
version {
name = rootProject.version
desc = 'Java pojo-methods testing library.'
released = new Date();
vcsTag = rootProject.version
}
}
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
}
jar {
manifest.attributes(createManifestAttributes())
}
def createManifestAttributes() {
Map attributes = new HashMap<>();
attributes.put('Manifest-Version', 1.0,)
attributes.put('Implementation-Title', rootProject.name,)
attributes.put('Implementation-Version', version,)
attributes.put('Implementation-Vendor', 'pojo.pl',)
attributes.put('Created-By', System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')',)
attributes.put('Built-With', "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",)
attributes.put('Build-Time', ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_ZONED_DATE_TIME),)
attributes.put('Built-By', gitUser())
attributes
}
static gitUser() {
def username = ""
def useremail = ""
def userNameProc = "git config user.name".execute()
userNameProc.in.eachLine { line -> username = line }
userNameProc.waitFor()
def userEmailProc = "git config user.email".execute()
userEmailProc.in.eachLine { line -> useremail = line }
userEmailProc.waitFor()
username + " " + useremail
}
build.dependsOn publishToMavenLocal
check.dependsOn integrationTest
integrationTest.mustRunAfter test