-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
216 lines (158 loc) · 5.38 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
/*
* Copyright (c) 2007-2015 Concurrent, Inc. All Rights Reserved.
*
* Project and contact information: http://www.concurrentinc.com/
*/
import org.apache.tools.ant.filters.ReplaceTokens
import java.text.SimpleDateFormat
import com.monochromeroad.gradle.plugin.aws.s3.S3Sync
import com.monochromeroad.gradle.plugin.aws.s3.ACL
if( project.properties[ 'teamcity' ] ) // make them system properties
System.properties.putAll( project.properties[ 'teamcity' ] )
if( System.properties[ 'aws.properties' ] )
{
file( System.properties[ 'aws.properties' ] ).withReader { reader ->
def awsProperties = new Properties()
awsProperties.load( reader )
System.properties.putAll( awsProperties )
}
}
ext.majorVersion = 2.7
ext.applicationGroup = "sdk"
ext.applicationName = "Cascading-${majorVersion}-SDK"
ext.timestamp = new SimpleDateFormat( "yyyyMMdd" ).format( new Date() )
ext.archiveBaseName = "${applicationName}-${timestamp}"
ext.distDir = "${buildDir}/dist/${archiveBaseName}"
ext.distributionDir = "${buildDir}/distribution"
ext.sourceBucket = System.getProperty("source.bucket") ?: "files.concurrentinc.com"
ext.docSourceBucket = System.getProperty("doc.source.bucket") ?: "docs.concurrentinc.com"
ext.publishBucket = System.properties[ 'publish.bucket' ] ?: "files.concurrentinc.com"
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven{ url 'http://repository-monochromeroad.forge.cloudbees.com/release/' }
maven{ url 'http://conjars.org/repo/' }
}
dependencies {
classpath group: 'com.monochromeroad.gradle', name: "gradle-aws-s3-sync", version: '0.5'
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven{ url 'http://conjars.org/repo/' }
}
}
task copyDriven( type: Copy ) {
from 'driven'
into "${distDir}/driven"
}
task copyEnv( type: Copy, dependsOn: copyDriven) {
from 'etc/setenv.sh'
fileMode 0755
into "${distDir}/etc"
}
task copyEMRScript(type: Copy){
from fileTree("etc/emr")
into distributionDir
filter( ReplaceTokens, tokens: [ 'SOURCE_BUCKET' : publishBucket ] )
}
copyEnv.doFirst() {
mkdir "${distDir}/etc"
def binPaths = [ ]
fileTree( distDir ) {
include '*/*/bin/'
}.visit { element ->
if( element.isDirectory() && element.getName().equals( 'bin' ) )
binPaths << element.getRelativePath()
}
def pathString = binPaths.collect { path -> "\${CASCADING_SDK_HOME}/${path}" }.join( ':' )
filter( ReplaceTokens, tokens: [ BIN_PATHS: pathString ] )
}
task copySupport( type: Copy, dependsOn: copyEnv ) {
from 'README.md'
into distDir
}
task packageDist( type: Tar, dependsOn: copySupport ) {
description = 'Creates the sdk archive.'
baseName = applicationName
version = timestamp
compression = "GZIP"
destinationDir = file( distributionDir )
from "${buildDir}/dist/"
}
allprojects {
task clean( type: Delete ) {
delete buildDir
}
}
subprojects {
ext.distDir = "${buildDir}/dist"
task fetchLatest {
ext.latestURL = null
ext.distroURL = null
ext.isArchive = true
ext.typePath = ''
outputs.dir distDir
}
fetchLatest.onlyIf { fetchLatest.latestURL != null || fetchLatest.distroURL != null }
fetchLatest << {
mkdir buildDir
mkdir distDir
if( distroURL == null )
{
def latestFile = new File( buildDir, 'LATEST.TXT' )
ant.get( src: latestURL, dest: latestFile.absolutePath, skipexisting: false )
distroURL = latestFile.readLines()[ 0 ]
}
def distroZip = new File( buildDir, distroURL.substring( distroURL.lastIndexOf( '/' ) ) )
ext.typeDir = new File( distDir, typePath )
mkdir typeDir
if (isArchive)
ant.get( src: distroURL, dest: distroZip.absolutePath, skipexisting: true )
else
ant.get( src: distroURL, dest: typeDir, skipexisting: true )
if( distroURL.endsWith( 'zip' ) || distroURL.contains( 'zipball' ) )
ant.unzip( src: distroZip, dest: typeDir )
else if( distroURL.endsWith( 'tgz' ) || distroURL.endsWith( 'tar.gz' ) || distroURL.contains( 'tarball' ))
nativeUntar( distroZip, typeDir )
}
task distCopy( type: Copy, dependsOn: fetchLatest ) {
from( distDir )
into( rootProject.distDir )
rootProject.tasks[ 'packageDist' ].dependsOn << distCopy
rootProject.tasks[ 'copyEnv' ].dependsOn << distCopy
}
}
// we shell out to tar to preserve symlinks from the tarballs.
def nativeUntar( src, dest ) {
def command = "tar xf ${src} -C ${dest} "
def proc = command.execute()
proc.waitFor()
}
// publishing code
task createArchiveLatest( dependsOn: packageDist ) {
ext.latestArchivePath = null
}
createArchiveLatest << {
def releaseTar = packageDist.archiveName
assert publishBucket
latestArchivePath = new File( distributionDir, 'latest.txt' )
latestArchivePath.write( "http://${publishBucket}/${applicationGroup}/${majorVersion}/${releaseTar}" )
}
task s3Upload(type: S3Sync, dependsOn: [copyEMRScript, createArchiveLatest] ){
accessKey = System.properties[ 'publish.aws.accessId' ]
secretKey = System.properties[ 'publish.aws.secretKey' ]
acl ACL.PublicRead
def s3Bucket = publishBucket
// XXX this should probably be enabled, but it is off for now to ease development
//assert accessKey
//assert secretKey
//assert s3Bucket
keepFiles = true
configFile = "${rootProject.projectDir}/etc/synchronizer.properties"
into "${s3Bucket}/${applicationGroup}/${majorVersion}/"
from distributionDir
}