forked from classmethod/gradle-aws-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
292 lines (257 loc) · 8.22 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
// -*- coding: utf-8; mode: groovy -*-
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.diffplug.gradle.spotless:spotless:1.3.3"
classpath "de.thetaphi:forbiddenapis:2.2"
classpath "de.aaschmid:gradle-cpd-plugin:1.0"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.8"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2"
classpath "com.gradle.publish:plugin-publish-plugin:0.9.1"
}
}
group = "com.salmon.aws"
ext.artifactId = "gradle-aws-plugin"
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
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'
eclipseFormatFile '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()
customReplaceRegex '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
}
// ======== library versions ========
ext {
lombokVersion = "1.16.2"
awsJavaSdkVersion = "1.11.116"
groovyVersion = "2.3.7"
junitVersion = "4.12"
hamcrestVersion = "1.3"
mockitoCoreVersion = "1.9.5"
guavaVersion = "18.0"
sparWingsVersion = "0.16"
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile gradleApi()
compile "com.google.guava:guava:$guavaVersion"
compile "commons-io:commons-io:1.4"
compile "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"
// 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 = "2.14"
}
// ======== IDE ========
eclipse {
project {
buildCommand 'org.eclipse.jdt.core.javabuilder'
buildCommand 'org.springframework.ide.eclipse.core.springbuilder'
buildCommand 'net.sf.eclipsecs.core.CheckstyleNature'
buildCommand 'edu.umd.cs.findbugs.plugin.eclipse.findbugsNature'
natures 'org.eclipse.jdt.core.javanature',
'org.springsource.ide.eclipse.gradle.core.nature',
'org.springframework.ide.eclipse.core.springnature',
'net.sf.eclipsecs.core.CheckstyleBuilder',
'edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder'
}
classpath {
defaultOutputDir = file('build/classes')
containers = [
'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8',
'org.springsource.ide.eclipse.gradle.classpathcontainer' // Gradle IDE classpath container
]
file {
// exclude jar entries from .classpath
whenMerged { classpath ->
classpath.configure classpath.entries.grep { entry ->
!(entry instanceof org.gradle.plugins.ide.eclipse.model.Library)
}
classpath.entries.findAll {
it instanceof org.gradle.plugins.ide.eclipse.model.SourceFolder && it.path.startsWith("src/test/")
}*.output = "build/test-classes"
}
}
downloadSources = true
downloadJavadoc = true
}
}