-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
278 lines (227 loc) · 9.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*
* Copyright (c) 2007-2016 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.
*/
ext.cascadingVersion = '3.1.0'
apply from: 'etc/publish.gradle'
// uncomment if testing a local build of Cascading via
// > cd $CASCADING_HOME; gradle clean install
//cascadingVersion = "${cascadingVersion}-wip-dev"
import groovy.json.JsonBuilder
import java.text.SimpleDateFormat
import org.apache.tools.ant.filters.ReplaceTokens
// use human readable date format
ext.testDate = new SimpleDateFormat( "MMMM dd, yyyy" ).format( new Date() )
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
repositories {
//mavenLocal()
mavenCentral()
maven{ url 'http://conjars.org/repo/' }
}
// core dependencies - see {platform}-settings.gradle for platform specific dependencies
dependencies {
runtime( group: 'cascading', name: 'cascading-core', version: cascadingVersion, classifier: 'tests' )
runtime( group: 'cascading', name: 'cascading-platform', version: cascadingVersion, classifier: 'tests' )
testCompile group: 'junit', name: 'junit', version: '4.12'
}
}
subprojects {
ext.cascadingPlatform = null
task unarchiveTest {
outputs.dir "$buildDir/classes/test/"
}
task buildHadoopJar(type: Jar, dependsOn: unarchiveTest) {
archiveName = "${rootProject.name}-${cascadingVersion}-remote-test.jar"
from sourceSets.test.output
doFirst {
into( 'lib' ) {
from configurations.testCompile
from configurations.runtime
}
}
}
unarchiveTest {
mkdir "$buildDir/classes/test/"
doLast {
// we only want the jars with test classifier
def jars = configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies.findAll { dep ->
dep.name.contains( 'cascading' )
}.collect { dep ->
dep.moduleArtifacts.collect { it.file }
}.flatten().findAll { file ->
file.toString().endsWith( '-tests.jar' )
}
jars.each { jarFile ->
def jar = zipTree( jarFile )
copy {
from jar
into "$buildDir/classes/test/"
}
}
}
}
// make properties available to sub-project
ext.distProps = new Properties()
if( file( "distribution.properties" ).exists() )
{
file( "distribution.properties" ).withReader { reader ->
distProps.load( reader )
}
}
task createResultFile {
description = "creates a result.json file for the test run"
if( file( "distribution.properties" ).exists() )
{
doLast {
file( "${buildDir}/compat/${cascadingPlatform}" ).mkdirs()
def result = [
distributionName: distProps[ "distribution.name" ],
distributionVersion: distProps[ "distribution.version" ],
distributionDisplayName: distProps[ "distribution.displayname" ],
distributionURL: distProps[ "distribution.url" ],
distributionDownloadURL: distProps[ "distribution.downloadurl" ],
distributionReleaseURL: distProps[ "distribution.releaseurl" ],
distributionMavenRepo: distProps[ "distribution.mavenrepo" ],
includesSDK: distProps[ "distribution.includessdk" ],
distributionSupportURL: distProps[ "distribution.supporturl" ],
// TODO make these dynamic
isBinaryCompatible: "yes",
isSourceCompatible: "yes",
// this assumes that the gradle jvm vendor and version are
// the same that is used to run the tests. If that is not the
// case in your build, you have to modify this line.
jvmVersion: System.properties[ "java.version" ],
// use java.vm.vendor, not java.vendor to see if it is OpenJDK
jvmName: System.properties[ "java.vm.vendor" ],
testDate: "${rootProject.testDate}",
cascadingVersion: actualCascadingVersion,
cascadingPlatform: cascadingPlatform
]
if( distProps.get( "distribution.yarnversion" ) != null )
result.put( "yarnVersion", distProps.get( "distribution.yarnversion" ) )
if( distProps.get( "distribution.platformurl" ) != null )
result.put( "platformUrl", distProps.get( "distribution.platformurl" ) )
if( distProps.get( "distribution.platformversion" ) != null )
result.put( "platformVersion", distProps.get( "distribution.platformversion" ) )
if( distProps.get( "distribution.platformdisplayname" ) != null )
result.put( "platformDisplayName", distProps.get( "distribution.platformdisplayname" ) )
def bldr = new JsonBuilder( result )
file( "${buildDir}/compat/${cascadingPlatform}/${result.distributionName}-${result.distributionVersion}.json" ).write( bldr.toString() )
}
}
}
task killChildVms( type: Exec ) {
commandLine "bash", "-c", 'pids="`jps | grep DAGApp | cut -d\" \" -f1`"; if [ -n "$pids" ] ; then kill -9 $pids ; fi'
}
test {
beforeTest { descriptor ->
systemProperties[ 'platform.cascading.app.name' ] = descriptor.getName()
}
afterTest {
killChildVms.execute()
}
dependsOn << buildHadoopJar
dependsOn << cleanTest
forkEvery = 1
jvmArgs '-Xmx756m', '-XX:MaxPermSize=128M'
//jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
ignoreFailures = !rootProject.tasks[ "uploadResults" ].enabled
include '**/*PlatformTest.class'
systemProperties[ 'test.cluster.enabled' ] = 'true'
systemProperties[ 'test.data.path' ] = new String( "${buildDir}/classes/test/data/" )
systemProperties[ 'test.output.root' ] = new String( "${buildDir}/test/output/" )
for( propertyName in System.getProperties().stringPropertyNames() ) {
if( propertyName.startsWith( "platform" ) ) {
systemProperties[ propertyName ] = System.getProperty( propertyName )
}
}
doLast {
createResultFile.execute()
tarTestResults.execute()
}
}
task testInfo() << {
sourceSets.test.runtimeClasspath.each{ entry ->
println entry
}
}
task tarTestResults( type: Tar) {
// can't read the result.json file, since it does not exist yet in the
// config phase of the task.
def distProps = null
file( "${projectDir}/distribution.properties" ).withReader { reader ->
distProps = new Properties()
distProps.load( reader )
}
def distName = distProps[ "distribution.name" ]
def distVersion = distProps[ "distribution.version" ]
assert distName
assert distVersion
compression = Compression.GZIP
from( testReportDir )
destinationDir = buildDir
archiveName = "${distName}-${distVersion}-test-results.tgz"
}
afterEvaluate {
def cascadingArtifacts = project.configurations.testRuntime.resolvedConfiguration.resolvedArtifacts.findAll { artifact ->
artifact.name.contains( "cascading-" ) }.asList()
for( ccArtifact in cascadingArtifacts ) {
FileTree zip = zipTree( ccArtifact.file )
def propertiesFiles = zip.findAll{ f -> f.name.endsWith( "platform.properties" ) }
if( !propertiesFiles.isEmpty() ) {
def testPlatformProperties = new Properties()
file(propertiesFiles[0]).withReader{ reader -> testPlatformProperties.load( reader ) }
def name = testPlatformProperties[ "platform.name" ]
if( name != null ) {
cascadingPlatform = name
break
}
}
}
// this allows to run all projects for a certain platform
def testPlatform = System.getProperty( "platform.name" )
if( testPlatform != null && testPlatform != cascadingPlatform )
tasks[ "test" ].enabled = false
}
}
ext.actualCascadingVersion = null
ext.actualCascadingRelease = null
project.afterEvaluate {
// this interesting construct is responsible for fetching the actual version of
// cascading that the build will use. What this means is, that it will set a
// property on the project that contains the 2.1.6 and not the 2.1.+
// version. We want to have this in order to have proper reporting about
// compatibility.
// Please note, that this property is not usable in the configuration phase
// of other tasks, since it is only set after those have been configured.
// if there is an easier way to do this, please send us a patch.
def resolvedDependency = project.configurations.runtime.resolvedConfiguration.resolvedArtifacts.findAll { artifact ->
artifact.name.contains( "cascading-core" ) }.asList()[ 0 ]
def version = resolvedDependency.moduleVersion.id.version
project.ext.actualCascadingVersion = version
def versionParts = version.toString().split( "\\." ).toList()
project.ext.actualCascadingRelease = versionParts[ 0 ] + "." + versionParts[ 1 ]
}
test.enabled = false; // disable root project tests
if( project.properties[ 'teamcity' ] ) // make them system properties
System.properties.putAll( project.properties[ 'teamcity' ] )
if ( System.properties[ "cascading.management.document.service.hosts" ] ) {
apply from: "etc/driven.gradle"
}