forked from cwensel/cascading.multitool
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.gradle
More file actions
218 lines (189 loc) · 6.51 KB
/
build.gradle
File metadata and controls
218 lines (189 loc) · 6.51 KB
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
/*
* Copyright (c) 2007-2015 Concurrent, Inc. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
*
* This file is part of the Cascading project.
*
* Licensed 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.
*/
import java.security.MessageDigest
import java.text.SimpleDateFormat
import org.apache.tools.ant.filters.ReplaceTokens
apply from: 'etc/version.gradle'
apply from: 'etc/s3Upload.gradle'
apply from: 'etc/dependencyVersions.gradle'
apply plugin: 'java'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.1'
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:2.2.1'
}
}
ext.buildTimestamp = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format( new Date() )
ext.buildDate = new SimpleDateFormat( "yyyyMMdd" ).format( new Date() )
ext.tarBaseName = "${rootProject.name}-${buildDate}"
ext.finalTarName = "${tarBaseName}.tgz"
ext.assemblyDirName = "build/assemble"
subprojects {
ext.jarName = "${project.name}-${buildDate}.jar"
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'provided-base'
apply plugin: 'com.github.johnrengelman.shadow'
repositories{
mavenLocal()
mavenCentral()
maven{ url 'http://conjars.org/repo/' }
}
dependencies {
testCompile group: 'junit', name: 'junit', version: "4.12"
}
configurations {
testArtifacts
}
task testJar (type: Jar) {
baseName = "${project.name}-test"
from sourceSets.test.output
}
artifacts {
archives jar
archives shadowJar
testArtifacts testJar
}
shadowJar {
baseName = "${project.name}-${buildDate}"
classifier = ''
configurations = []
from {
project.configurations.runtime.minus( [ project.configurations.provided ] )
}
mergeServiceFiles()
exclude 'LICENSE'
exclude 'META-INF/*.DSA'
exclude 'META-INF/LICENSE*'
into( "multitool" ) {
from( "version.properties" ) {
filter( ReplaceTokens, tokens: [
'releasedate': "${buildDate}".toString(),
'commit': "${commit}".toString()
] )
}
if( !System.properties[ 'multitool.release.final' ] )
from "${rootProject.buildDir}/build.number.properties"
}
manifest {
attributes "Main-Class": "multitool/Main",
'Build-Time': "${buildTimestamp}"
}
}
}
task assembleTarballStructure( ) << {
def targetDirName = "${assemblyDirName}/${rootProject.name}-${buildDate}"
copy {
from( "src/main/shell" )
filter( ReplaceTokens, tokens: [
'location': project.s3Bucket.toString(),
'majorVersion': majorVersion.toString()
] )
into( "${targetDirName}/bin" )
}
copy {
from( "src/main/resources/data" )
into( "${targetDirName}/data" )
}
copy {
from( "." )
include( "apl.txt", "README.md" )
into( targetDirName )
}
copy {
from( project ( ":multitool-local" ).shadowJar )
into( "${targetDirName}/platform/local" )
}
copy {
from( project ( ":multitool-hadoop" ).shadowJar )
into( "${targetDirName}/platform/hadoop" )
}
copy {
from( project ( ":multitool-hadoop2-mr1" ).shadowJar )
into( "${targetDirName}/platform/hadoop2-mr1" )
}
copy {
from( project ( ":multitool-hadoop2-tez" ).shadowJar )
into( "${targetDirName}/platform/hadoop2-tez" )
}
copy {
from ( "multitool-docs/build/asciidoc" )
into( "${targetDirName}/docs" )
include( "*.html" )
}
}
assembleTarballStructure.dependsOn( [":multitool-docs:asciidoctor", subprojects.shadowJar ] )
task buildTarball( type: Tar, dependsOn: assembleTarballStructure ) {
baseName = "${tarBaseName}"
destinationDir = new File( "${s3UploadArtifacts.source}" )
compression = Compression.GZIP
from( assemblyDirName )
}
task checksums( dependsOn: buildTarball ) << {
generateChecksumFiles( buildTarball.archivePath, [ "sha1", "md5" ] )
}
task assembleDist( dependsOn: checksums ) << {
file( "${s3UploadArtifacts.source}/latest.txt" ).write( "http://${s3UploadArtifacts.destination}${finalTarName}" )
file( "${s3UploadArtifacts.source}/latest-sha1.txt" ).write( "http://${s3UploadArtifacts.destination}${finalTarName}.sha1" )
file( "${s3UploadArtifacts.source}/latest-md5.txt" ).write( "http://${s3UploadArtifacts.destination}${finalTarName}.md5" )
file( "${s3UploadArtifacts.source}/latest-hadoop-jar.txt" ).write( "http://${s3UploadArtifacts.destination}${project( 'multitool-hadoop').jarName}" )
file( "${s3UploadArtifacts.source}/latest-hadoop2-mr1-jar.txt" ).write( "http://${s3UploadArtifacts.destination}${project( 'multitool-hadoop2-mr1').jarName}" )
file( "${s3UploadArtifacts.source}/latest-hadoop2-tez-jar.txt" ).write( "http://${s3UploadArtifacts.destination}${project( 'multitool-hadoop2-tez').jarName}" )
copy {
from ( project( ":multitool-hadoop" ).shadowJar )
into( "${s3UploadArtifacts.source}" )
}
copy {
from ( project( ":multitool-hadoop2-mr1" ).shadowJar )
into( "${s3UploadArtifacts.source}" )
}
copy {
from ( project( ":multitool-hadoop2-tez" ).shadowJar )
into( "${s3UploadArtifacts.source}" )
}
copy {
from( "src/main/shell/util/install-multitool.sh" )
filter( ReplaceTokens, tokens: [
'location': project.s3Bucket.toString(),
'majorVersion': majorVersion.toString()
] )
into( "${s3UploadArtifacts.source}" )
}
}
assembleDist.dependsOn( [ subprojects.test, subprojects.shadowJar ] )
def generateChecksumFiles( filePath, algorithms ){
def mb = 1024 * 1024
def digests = algorithms.collect{ it -> MessageDigest.getInstance( it ) }
def inputFile = file( filePath )
inputFile.eachByte( mb ) { byte[] buf, int bytesRead ->
digests.each{ it -> it.update( buf, 0 , bytesRead ) }
}
algorithms.eachWithIndex(){ it, index ->
file( "${filePath}.${it}" ).write(
new BigInteger( 1, digests.get( index ).digest() ).toString( 16 ) +
" " + file( filePath ).name + "\n" )
}
}