-
Notifications
You must be signed in to change notification settings - Fork 131
/
build.gradle
242 lines (210 loc) · 6.75 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
// -*- coding: utf-8; mode: groovy -*-
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.10.0"
classpath "de.thetaphi:forbiddenapis:2.5"
classpath "de.aaschmid:gradle-cpd-plugin:1.0"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.14"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2"
classpath "com.gradle.publish:plugin-publish-plugin:0.9.10"
}
}
group = "jp.classmethod.aws"
ext.artifactId = "gradle-aws-plugin"
apply plugin: "java"
apply plugin: "jacoco"
apply plugin: "com.gradle.plugin-publish"
// gradle configuration
apply from: 'gradle/version.gradle'
apply from: 'gradle/resolveDependencies.gradle'
defaultTasks "clean", "build"
// ======== code quality ========
apply plugin: "checkstyle"
apply plugin: "findbugs"
apply plugin: "pmd"
apply plugin: "cpd"
apply plugin: "jacoco"
apply plugin: "de.thetaphi.forbiddenapis"
apply plugin: "com.diffplug.gradle.spotless"
// compiler
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(AbstractCompile) each {
it.options.encoding = "UTF-8"
}
compileJava {
options.compilerArgs << "-Werror"
options.compilerArgs << "-Xlint:all" << "-Xlint:-processing" << "-Xlint:-deprecation"
}
// jacoco
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
}
}
// checkstyle
checkstyle {
toolVersion = "7.1.2"
showViolations = true
configFile = project.file('config/checkstyle/checkstyle.xml')
}
checkstyleTest {
configFile = file("config/checkstyle/checkstyle-test.xml")
}
// workaround: see https://issues.gradle.org/browse/GRADLE-2888
task verifyNoCheckstyleWarningsInMain {
group = "verification"
description = "Fail if checkstyleMain result contains warnings"
doLast {
File warningsFile = file('build/reports/checkstyle/main.xml')
if (warningsFile.exists() && warningsFile.text.contains("<error ")) {
throw new GradleException("There were checkstyle warnings! For more info check $warningsFile")
}
}
}
checkstyleMain.finalizedBy verifyNoCheckstyleWarningsInMain
task verifyNoCheckstyleWarningsInTest {
group = "verification"
description = "Fail if checkstyleTest result contains warnings"
doLast {
File warningsFile = file('build/reports/checkstyle/test.xml')
if (warningsFile.exists() && warningsFile.text.contains("<error ")) {
throw new GradleException("There were checkstyle warnings! For more info check $warningsFile")
}
}
}
checkstyleTest.finalizedBy verifyNoCheckstyleWarningsInTest
// findbugs
findbugs {
toolVersion = "3.0.1"
effort = "max"
includeFilter = file("config/findbugs/includeFilter.xml")
excludeFilter = file("config/findbugs/excludeFilter.xml")
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
// pmd
pmd {
consoleOutput = true
toolVersion = '5.5.2'
}
pmdMain {
ruleSetFiles = files("config/pmd/pmd-settings.xml")
ruleSets = [] // To apply only the custom rules
}
pmdTest {
ruleSetFiles = files("config/pmd/pmd-settings-test.xml")
ruleSets = [] // To apply only the custom rules
}
cpdCheck {
reports {
text.enabled = true
xml.enabled = false
}
source = sourceSets.main.allJava // only main source
ignoreFailures = true
}
// forbiddenapis
forbiddenApisMain {
bundledSignatures += [
'jdk-system-out',
'jdk-unsafe-' + project.sourceCompatibility,
'jdk-internal-' + project.sourceCompatibility
]
signaturesFiles = fileTree(dir: "config/forbiddenapis", include: "*.txt")
ignoreFailures = false
}
forbiddenApisTest {
bundledSignatures += [
'jdk-system-out',
'jdk-internal-' + project.sourceCompatibility
]
signaturesFiles = fileTree(dir: "config/forbiddenapis-test", include: "*.txt")
ignoreFailures = false
}
// spotless
spotless {
java {
licenseHeaderFile 'config/spotless/spotless.license.java'
importOrderFile 'config/spotless/spotless.importorder'
eclipse().configFile 'config/spotless/spotless.eclipseformat.xml'
// Eclipse formatter screws up long literals with underscores inside of annotations (see issue #14)
// @Max(value = 9_999_999 L) // what Eclipse does
// @Max(value = 9_999_999L) // what I wish Eclipse did
custom 'Long literal fix', { it.replaceAll('([0-9_]+) [Ll]', '$1L') }
// Eclipse formatter puts excess whitespace after lambda blocks
// funcThatTakesLambdas(x -> {} , y -> {} ) // what Eclipse does
// funcThatTakesLambdas(x -> {}, y -> {}) // what I wish Eclipse did
custom 'Lambda fix', { it.replace('} )', '})').replace('} ,', '},') }
indentWithTabs()
endWithNewline()
replaceRegex 'Add space before comment asterisk', '^(\\t*)\\*', '$1 *'
// customReplaceRegex 'Remove indent before line comment', '^\\t*//', '//'
}
}
// ======== create source and javadoc bundles ========
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}
javadoc {
failOnError = false
}
artifacts {
archives sourcesJar
archives javadocJar
}
configurations {
deployerJars
}
// ======== libraries ========
repositories {
mavenCentral()
}
dependencies {
compile gradleApi()
compile "com.google.guava:guava:$guavaVersion"
compile "commons-io:commons-io:1.4"
compileOnly "org.projectlombok:lombok:$lombokVersion"
compile "com.amazonaws:aws-java-sdk-sts:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-s3:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-ec2:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-rds:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-route53:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-elasticloadbalancing:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-elasticbeanstalk:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-cloudformation:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-lambda:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-iam:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-sqs:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-sns:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-ecr:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-ssm:$awsJavaSdkVersion"
compile "com.amazonaws:aws-java-sdk-cloudwatch:$awsJavaSdkVersion"
// tests
testCompile "junit:junit:$junitVersion"
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
testCompile "org.mockito:mockito-core:$mockitoCoreVersion"
deployerJars "org.springframework.build:aws-maven:4.7.0.RELEASE"
}
// ======== deploy artifacts ========
// Allows forks of the plugin to define their own deployment mechanisms
// in separate files named according to their maven group name
apply from: "deploy/${group}.gradle"
// ======== wrapper ========
task wrapper(type: Wrapper) {
gradleVersion = "4.6"
}