forked from greghaskins/spectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
207 lines (177 loc) · 5.23 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
plugins {
id "com.cinnober.gradle.semver-git" version "2.2.2"
id "com.jfrog.bintray" version "1.3.1"
id "com.diffplug.gradle.spotless" version "1.3.3"
}
apply plugin: 'maven-publish'
apply plugin: 'checkstyle'
allprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
repositories { jcenter() }
}
dependencies {
compile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testCompile group: 'org.springframework', name:'spring-test', version: '4.3.4.RELEASE'
testCompile group: 'org.springframework', name:'spring-core', version: '4.3.4.RELEASE'
testCompile group: 'org.springframework', name:'spring-context', version: '4.3.4.RELEASE'
}
compileJava { sourceCompatibility = 1.8 }
compileTestJava { sourceCompatibility = 1.8 }
test { finalizedBy jacocoTestReport }
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all"
}
jacocoTestReport {
dependsOn subprojects*.test
sourceSets sourceSets.main
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled = true
html.enabled = true
}
}
task wrapper(type: Wrapper) { gradleVersion = '2.14.1' }
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
from sourceSets.test.allSource
}
artifacts { archives sourcesJar, javadocJar, testJar }
spotless {
java {
eclipseFormatFile 'config/eclipse-java-google-style.xml'
importOrderFile 'config/spectrum.importorder'
custom 'separate return from previous statements', {
it.replaceAll(/([^\s\{])\n( *)return /, '$1\n\n$2return ')
}
}
format 'text', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
freshmark {}
}
classes { dependsOn 'spotlessApply' }
checkstyle {
toolVersion = '6.18'
configFile = rootProject.file('config/google_checks.xml')
}
def verifyCheckstyleWarningsTask (name, warningsFileName) {
task(name) {
doFirst {
def warningsFile = file("build/reports/checkstyle/$warningsFileName")
if (warningsFile.exists() && warningsFile.text.contains('<error ')) {
throw new GradleException("There are Checkstyle warnings!\nSee $warningsFile for more info.")
}
}
}
}
checkstyleMain {
finalizedBy verifyCheckstyleWarningsTask('strictCheckstyleMain', 'main.xml')
}
checkstyleTest {
finalizedBy verifyCheckstyleWarningsTask('strictCheckstyleTest', 'test.xml')
}
def pomConfig = {
licenses {
license {
name 'MIT License'
url 'http://www.opensource.org/licenses/mit-license.php'
distribution 'repo'
}
}
developers {
developer {
id 'greghaskins'
name 'Gregory Haskins'
email 'greg@greghaskins.com'
organization 'SpectrumBDD'
organizationUrl 'https://github.com/spectrumbdd/'
}
}
scm {
connection 'scm:git:https://github.com/greghaskins/spectrum.git'
developerConnection 'scm:git:ssh://github.com:greghaskins/spectrum.git'
url 'https://github.com/greghaskins/spectrum/tree/master'
}
}
def description = 'A colorful BDD-style test runner for Java'
def url = 'https://github.com/greghaskins/spectrum'
publishing {
publications {
bintrayPublication(MavenPublication) {
from components.java
groupId 'com.greghaskins'
artifactId 'spectrum'
version project.version
artifact sourcesJar
artifact javadocJar
artifact testJar
pom.withXml {
def root = asNode()
root.appendNode('description', description)
root.appendNode('name', 'Spectrum')
root.appendNode('url', url)
// Make sure compile dependencies don't get marked as "runtime"
root.dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each { it.scope*.value = 'compile'}
root.children().last() + pomConfig
}
}
}
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
publish = true
dryRun = System.getenv("CI") == null
publications = ['bintrayPublication']
pkg {
repo = 'maven'
name = 'Spectrum'
licenses = ['MIT']
desc = description
websiteUrl = url
issueTrackerUrl = 'https://github.com/greghaskins/spectrum/issues'
vcsUrl = 'https://github.com/greghaskins/spectrum.git'
labels = [
'java',
'junit',
'bdd',
'spec',
'testing',
'unit testing',
'java8',
'lambda'
]
version {
name = project.version
released = new Date()
mavenCentralSync {
sync = true
user = System.getenv('SONATYPE_USER')
password = System.getenv('SONATYPE_PASSWORD')
close = '1'
}
}
}
}