-
Notifications
You must be signed in to change notification settings - Fork 71
/
build.gradle
256 lines (227 loc) · 8.67 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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
group 'NNA'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
buildscript {
repositories {
maven { url = "https://jcenter.bintray.com" }
maven { url = "https://repo.maven.apache.org/maven2" }
}
dependencies {
classpath 'com.netflix.nebula:gradle-ospackage-plugin:2.2.4'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
classpath "net.nemerosa:versioning:2.7.1"
}
}
apply plugin: 'idea'
apply plugin: "eclipse"
apply plugin: 'os-package'
apply plugin: 'license'
apply plugin: 'com.diffplug.gradle.spotless'
apply plugin: 'net.nemerosa.versioning'
eclipse {
classpath {
defaultOutputDir = file('build/eclipse')
}
}
ext {
mainClass = (properties.get("mainClass") == null) ? "" : "${mainClass}"
hadoopVersion = (properties.get("hadoopVersion") == null) ? "2.7.0" : "${hadoopVersion}"
println("Building with hadoopVersion: ${hadoopVersion}")
}
versioning {
full = { scmInfo -> ("${scmInfo.tag}" == "null" ? "${scmInfo.lastTag}." : "${scmInfo.tag}.") + hadoopVersion }
dirty = { version -> "${version}" }
}
checkstyle {
toolVersion "7.8.2"
configFile file("config/checkstyle/checkstyle.xml")
sourceSets = [project.sourceSets.main]
}
spotless {
java {
googleJavaFormat('1.3')
licenseHeaderFile file('license.header.spotless')
removeUnusedImports()
trimTrailingWhitespace()
}
}
license {
header = file('license.header')
excludePatterns = [ "**/bootstrap*",
"**/Chart*",
"**/cycle.js",
"**/jquery*",
"**/sweetalert*",
"**/datatables*",
"**/jszip.min.js",
"**/dataTables.buttons.min.js",
"**/buttons.html5.min.js",
"**/css/*datatables*",
"**/npm.js",
"**/*.blank.xml",
"**/*.md" ].toSet()
}
findbugs {
findbugsTest.enabled = false
}
jacoco {
toolVersion = "0.8.1"
}
task(execute, dependsOn: 'testClasses', type: JavaExec) {
main = "${mainClass}"
classpath = sourceSets.test.runtimeClasspath
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
jacocoTestReport {
reports {
xml.enabled true
xml.destination "${buildDir}/reports/jacoco/report.xml"
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
test {
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
finalizedBy jacocoTestReport
}
sourceSets.main.java.srcDirs "src/main/java", "src/main/${hadoopVersion}"
sourceSets.test.java.srcDirs "src/test/java", "src/test/${hadoopVersion}"
compileJava {
dependsOn versionDisplay
dependsOn versionFile
}
repositories {
maven { url = "https://jcenter.bintray.com" }
maven { url = "https://repo.maven.apache.org/maven2" }
}
configurations {
compile.extendsFrom(outboundDep)
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
all*.exclude group: 'org.mortbay.jetty', module: 'servlet-api'
all*.exclude group: 'javax.servlet', module: 'servlet-api'
}
dependencies {
compile 'commons-lang:commons-lang:2.6'
outboundDep files('lib/airconcurrentmap.jar')
outboundDep group: 'org.pac4j', name: 'spark-pac4j', version: '1.2.3'
outboundDep group: 'org.pac4j', name: 'pac4j-ldap', version: '1.9.4'
outboundDep group: 'org.pac4j', name: 'pac4j-jwt', version: '1.9.4'
outboundDep group: 'com.sparkjava', name: 'spark-core', version: '2.5'
outboundDep group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
outboundDep group: 'org.mortbay.jetty', name: 'jetty', version: '6.1.26'
outboundDep group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
outboundDep group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21'
outboundDep group: 'log4j', name: 'log4j', version: '1.2.17'
outboundDep group: 'javax.mail', name: 'mail', version: '1.4.7'
outboundDep group: 'org.hsqldb', name: 'hsqldb', version: '2.4.0'
outboundDep group: 'org.mapdb', name: 'mapdb', version: '3.0.5'
outboundDep(group: 'com.google.guava', name: 'guava', version: '11.0.2') {
force = true
}
outboundDep(group: 'commons-io', name: 'commons-io', version: '2.4') {
force = true
}
outboundDep group: 'com.github.jsqlparser', name: 'jsqlparser', version: '2.1'
outboundDep group: 'com.boundary', name: 'high-scale-lib', version: '1.0.6'
outboundDep group: 'org.eclipse.collections', name: 'eclipse-collections-api', version: '10.1.0'
outboundDep group: 'org.eclipse.collections', name: 'eclipse-collections', version: '10.1.0'
outboundDep group: 'org.apache.hadoop', name: 'hadoop-common', version: "${hadoopVersion}"
outboundDep group: 'org.apache.hadoop', name: 'hadoop-hdfs', version: "${hadoopVersion}"
testCompile group: 'org.apache.hadoop', name: 'hadoop-common', version: "${hadoopVersion}", classifier: 'tests'
testCompile group: 'org.apache.hadoop', name: 'hadoop-hdfs', version: "${hadoopVersion}", classifier: 'tests'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'org.openjdk.jmh', name: 'jmh-core', version: '1.19'
testCompile group: 'org.openjdk.jmh', name: 'jmh-generator-annprocess', version: '1.19'
if (hadoopVersion.startsWith("3.")) {
outboundDep group: 'org.apache.hadoop', name: 'hadoop-hdfs-client', version: "${hadoopVersion}"
}
}
buildRpm {
postInstall 'mkdir -p -m 0755 /usr/local/nn-analytics/dfs/name/current && ' +
'mkdir -p -m 0755 /usr/local/nn-analytics/dfs/name/legacy && ' +
'chown -R hdfs: /usr/local/nn-analytics/dfs && ' +
'mkdir -p -m 0755 /usr/local/nn-analytics/db && ' +
'chown -R hdfs: /usr/local/nn-analytics/db &&' +
'mkdir -p -m 0755 /var/log/nn-analytics && ' +
'chown hdfs: /var/log/nn-analytics && ' +
'cp /usr/local/nn-analytics/bin/nn-analytics /etc/init.d/ && ' +
'chkconfig --add nn-analytics'
}
buildDeb {
postInstall 'mkdir -p -m 0755 /usr/local/nn-analytics/dfs/name/current && ' +
'mkdir -p -m 0755 /usr/local/nn-analytics/dfs/name/legacy && ' +
'chown -R hdfs: /usr/local/nn-analytics/dfs && ' +
'mkdir -p -m 0755 /usr/local/nn-analytics/db && ' +
'chown -R hdfs: /usr/local/nn-analytics/db &&' +
'mkdir -p -m 0755 /var/log/nn-analytics && ' +
'chown hdfs: /var/log/nn-analytics && ' +
'cp /usr/local/nn-analytics/bin/nn-analytics /etc/init.d/ && ' +
'update-rc.d nn-analytics defaults'
}
ospackage {
packageName = 'nn-analytics'
version = versioning.info.full.startsWith("null") ? "1.2." + hadoopVersion : versioning.info.full
release = 0
os = LINUX
user 'root'
permissionGroup 'root'
into '/usr/local/nn-analytics/'
from('build/version.properties') {
fileMode = 0444
}
from(jar.outputs.files) {
into 'lib'
}
from(configurations.outboundDep.files) {
into 'lib'
}
from('src/main/resources/bin') {
into 'bin'
fileMode = 0755
}
from('src/main/resources/env') {
fileType CONFIG | NOREPLACE
into 'bin'
fileMode = 0755
}
from('src/main/resources/config') {
fileType CONFIG | NOREPLACE
into 'config'
}
from('src/main/resources/webapps') {
fileType CONFIG | NOREPLACE
into 'webapps'
fileMode = 0755
}
}