-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
257 lines (223 loc) · 8.61 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
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'jetty'
sourceCompatibility = 1.6
configurations {
tools
}
//
// Dependency on gradle-git to download juds to download juds
// @see https://github.com/ajoberstar/gradle-git
//
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'org.ajoberstar:gradle-git:0.2.3' }
}
import org.ajoberstar.gradle.git.tasks.*;
//
// Retrieve/Configure/Build JUDS
//
task clonejuds(type: GitClone) {
def destination = file('juds')
uri = 'https://github.com/mcfunley/juds.git'
destinationPath = destination
bare = false
enabled = !destination.exists() //to clone only once
}
task confjuds(type: Exec, dependsOn: 'clonejuds') {
workingDir './juds'
if (!new File('./juds/juds-0.94.jar').exists()) {
commandLine './configure','CFLAGS=-I' + System.getProperty('java.home') + '/include'
} else {
commandLine 'ls', 'juds-0.94.jar'
}
}
task buildjuds(type: Exec, dependsOn: 'confjuds') {
workingDir './juds'
if (!new File('./juds/juds-0.94.jar').exists()) {
commandLine 'make'
} else {
commandLine 'ls', 'juds-0.94.jar'
}
}
//
// Repositories for dependency resolution
//
repositories {
mavenCentral()
}
//
// Project dependencies
//
dependencies {
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.47'
compile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.47'
compile group: 'org.bouncycastle', name: 'bcpg-jdk15on', version: '1.47'
compile group: 'javax.servlet', name: 'servlet-api', version: '2.5'
compile group: 'com.google.inject', name: 'guice', version: '3.0'
compile group: 'com.google.inject.extensions', name: 'guice-servlet', version: '3.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.2.2'
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.2.5'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.2.5'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.6'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.6'
compile group: 'org.apache.pig', name: 'pig', version: '0.8.0', transitive: false
compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.3.5', transitive: false
compile group: 'org.apache.hadoop', name: 'hadoop-core', version: '0.20.2', transitive: false
compile group: 'log4j', name: 'log4j', version: '1.2.15', transitive: false
compile files('juds/juds-0.94.jar')
tools files('tools/jarjar-1.4.jar')
testCompile group: 'junit', name: 'junit', version: '4.+'
}
war {
ext.clspth = []
for (f in classpath) {
if (!f.toString().endsWith('juds-0.94.jar')) {
ext.clspth.add(f)
}
}
classpath = ext.clspth
}
test {
scanForTestClasses = true
//makes the standard streams (err and out) visible at console when running tests
testLogging.showStandardStreams = true
//listening to test execution events
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
}
}
build.dependsOn {
'buildjuds'
}
//
// Handly tasks to interact with an OSS
//
task(OSSGenMasterSecret, dependsOn: 'build', type: JavaExec) {
doFirst {
ext.props = ['oss.url', 'oss.pubring', 'oss.keyid', 'oss.k']
for (prop in ext.props) {
if (null == System.getProperty(prop)) {
throw new RuntimeException('Usage: gradle -Doss.url=OSS_URL -Doss.pubring=PUBRING0,PUBRING1,... -Doss.keyid=KEYID0,KEYID1,... -Doss.k=K OSSGenMasterSecret')
}
}
}
main = 'com.geoxp.oss.client.OSSGenMasterSecret'
classpath = sourceSets.main.runtimeClasspath
args System.getProperty('oss.url',''), System.getProperty('oss.pubring',''), System.getProperty('oss.keyid',''), System.getProperty('oss.k','')
}
task(OSSInit, dependsOn: 'build') {
doFirst {
ext.props = ['oss.url']
for (prop in ext.props) {
if (null == System.getProperty(prop)) {
throw new RuntimeException('Usage: gradle -Doss.url=OSS_URL [-Doss.sshkey=SSH_KEY_FINGERPRINT] OSSInit\nPassing the raw init secret via stdin.')
}
}
ext.cp = ''
for(f in sourceSets.main.runtimeClasspath) {
ext.cp = ext.cp + ':' + f
}
println 'To initialize OSS run the following command:'
println ''
println 'gpg -d XXXXXXXX.oss | java -cp build/libs/oss-client.jar com.geoxp.oss.client.OSSInit ' + System.getProperty('oss.url','') + ' ' + System.getProperty('oss.sshkey','')
}
}
task(OSSPutSecret, dependsOn: 'build') {
doFirst {
ext.props = ['oss.url','oss.secret']
for (prop in ext.props) {
if (null == System.getProperty(prop)) {
throw new RuntimeException('Usage: gradle -Doss.url=OSS_URL -Doss.secret=SECRET_NAME [-Doss.sshkey=SSH_KEY_FINGERPRINT] OSSPutSecret\nPassing the secret to store via stdin.')
}
}
println 'To store a secret, run the following command:'
println ''
println 'cat SECRET | java -cp build/libs/oss-client.jar com.geoxp.oss.client.OSSPutSecret ' + System.getProperty('oss.url','') + ' ' + System.getProperty('oss.secret','') + ' ' + System.getProperty('oss.sshkey','')
}
}
task(OSSWrap, dependsOn: 'build') {
doFirst {
ext.props = ['oss.url','oss.secret']
for (prop in ext.props) {
if (null == System.getProperty(prop)) {
throw new RuntimeException('Usage: gradle -Doss.url=OSS_URL -Doss.secret=SECRET_NAME [-Doss.sshkey=SSH_KEY_FINGERPRINT] OSSWrap\nPassing data to wrap via stdin.\nSecret must be of length 128, 192 or 256 bits.')
}
}
println 'To wrap data, run the following command:'
println ''
println 'cat DATA | java -cp build/libs/oss-client.jar com.geoxp.oss.client.OSSWrap ' + System.getProperty('oss.url','') + ' ' + System.getProperty('oss.secret','') + ' ' + System.getProperty('oss.sshkey','')
}
}
task(OSSGenSecret, dependsOn: 'build', type: JavaExec) {
doFirst {
ext.props = ['oss.url', 'oss.secret']
for (prop in ext.props) {
if (null == System.getProperty(prop)) {
throw new RuntimeException('Usage: gradle -Doss.url=OSS_URL -Doss.secret=SECRET_NAME [-Doss.sshkey=SSH_KEY_FINGERPRINT] OSSGenSecret')
}
}
}
main = 'com.geoxp.oss.client.OSSGenSecret'
classpath = sourceSets.main.runtimeClasspath
args System.getProperty('oss.url',''), System.getProperty('oss.secret',''), System.getProperty('oss.sshkey','')
}
task(OSSGetSecret, dependsOn: 'build', type: JavaExec) {
doFirst {
ext.props = ['oss.url', 'oss.secret']
for (prop in ext.props) {
if (null == System.getProperty(prop)) {
throw new RuntimeException('Usage: gradle -Doss.url=OSS_URL -Doss.secret=SECRET_NAME [-Doss.sshkey=SSH_KEY_FINGERPRINT] OSSGetSecret')
}
}
}
main = 'com.geoxp.oss.client.OSSGetSecret'
classpath = sourceSets.main.runtimeClasspath
args System.getProperty('oss.url',''), System.getProperty('oss.secret',''), System.getProperty('oss.sshkey', '')
}
task ossClientJar(type: Jar, dependsOn: jar) {
inputs.files jar.archivePath
appendix = 'client'
doLast {
project.ant {
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.tools.asPath
jarjar(jarfile: archivePath) {
zipfileset(src: jar.archivePath) {
exclude(name: 'com/geoxp/oss/servlet/**')
exclude(name: 'com/geoxp/oss/OSS.class')
exclude(name: 'com/geoxp/oss/OSS$*.class')
exclude(name: 'com/geoxp/oss/KeyStore.class')
exclude(name: 'com/geoxp/oss/DirectoryHierarchyKeyStore.class')
}
//sourceSets.main.allSource.findAll { file -> println 'FILE >>> ' + file }
//
// Iterate over .jar files
//
configurations.runtime.files.findAll {file ->
['log4', 'hadoop-', 'pig-', 'slf4j-', 'servlet-api', 'guice-servlet', 'guice', 'javax.inject', 'aopalliance', 'asm'].every { !file.name.startsWith(it) }
}.each {jarjarFile ->
zipfileset(src: jarjarFile) {
exclude(name: 'META-INF/**')
}
}
rule pattern: "com.geoxp.oss.**", result: "@0"
rule pattern: "com.etsy.net.**", result: '@0'
rule pattern: "org.apache.pig.**", result: "@0"
rule pattern: "org.apache.hadoop.**", result: "@0"
rule pattern: "org.w3c.**", result: "@0"
rule pattern: "org.xml.**", result: "@0"
rule pattern: "org.apache.log4j.**", result: "@0"
rule pattern: "org.**", result: "com.geoxp.oss.jarjar.@0"
rule pattern: "net.**", result: "com.geoxp.oss.jarjar.@0"
rule pattern: "com.**", result: "com.geoxp.oss.jarjar.@0"
}
}
}
}
assemble {
dependsOn ossClientJar
}