-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
329 lines (286 loc) · 11.9 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
// GPars - Groovy Parallel Systems
//
// Copyright © 2008-10 The original author or authors
//
// 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.
// Author: Václav Pech
// Author: Russel Winder
// Author: Dierk König
// Author: Hans Dockter
// Author: Hamlet D'Arcy - Updated OSGi configuration
// gradle imports these by default, but IDEA doesn't know
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'osgi'
defaultTasks 'test'
archivesBaseName = 'gpars'
group = 'org.codehaus.gpars'
version = '0.11-beta-1'
bundleVersion = version
sourceCompatibility = 5
targetCompatibility = 5
def theVendor = 'gpars.org'
def theTitle = 'GPars: Groovy Parallel Systems'
jar {
manifest {
name = 'gpars'
version = this.version
symbolicName = 'gpars.org'
instruction 'Bundle-Vendor', theVendor
instruction 'Bundle-Description', group
instruction 'Bundle-DocURL', 'http://gpars.codehaus.org'
instruction 'Built-By', System.properties.'user.name'
instruction 'Extension-Name', archivesBaseName
instruction 'Specification-Title', theTitle
instruction 'Specification-Version', version
instruction 'Specification-Vendor', theVendor
instruction 'Implementation-Title', theTitle
instruction 'Implementation-Version', version
instruction 'Implementation-Vendor', theVendor
instruction 'provider', theVendor
instruction 'Export-Package', "*;version=${version}"
instruction 'Import-Package', '*;resolution:=optional'
}
}
repositories {
mavenCentral()
mavenRepo urls: ['http://repository.jboss.org/maven2/']
//mavenRepo urls: ["http://snapshots.repository.codehaus.org"]
mavenRepo urls: ["http://repository.codehaus.org"]
}
configurations {
deployerJars
docs
cover
}
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: hasProperty('groovyVersion') ? groovyVersion : '1.6.9'
testCompile group: 'junit', name: 'junit', version: hasProperty('junitVersion') ? junitVersion : '4.8.2'
testCompile group: 'org.spockframework', name: 'spock-core', version: hasProperty('spockVersion') ? spockVersion : '0.4-groovy-1.6'
compile group: 'org.coconut.forkjoin', name: 'jsr166y', version: hasProperty('jsr166yVersion') ? jsr166yVersion : '070108'
compile group: 'org.jboss.netty', name: 'netty', version: hasProperty('nettyVersion') ? nettyVersion : '3.1.5.GA'
// compile group: 'org.jboss.netty', name: 'netty', version: hasProperty('nettyVersion') ? nettyVersion : '3.1.5.GA' {maven.optional = true}
//compile files('lib/jcsp.jar', 'lib/jcsp-demos-util.jar')
compile group: 'org.codehaus.jcsp', name: 'jcsp', version: '1.1-rc5'
docs group: 'org.grails', name: 'grails-docs', version: '1.3.5'
docs group: 'radeox', name: 'radeox', version: '1.0-b2'
docs group: 'commons-logging', name: 'commons-logging', version: '1.1.1'
deployerJars 'org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6'
cover 'net.sourceforge.cobertura:cobertura:1.9.4.1'
testRuntime 'net.sourceforge.cobertura:cobertura:1.9.4.1'
}
// To get the details of the "unchecked" issues.
compileGroovy.options.compilerArgs = ['-Xlint']
[compileGroovy, compileTestGroovy]*.groovyOptions*.fork(memoryInitialSize: '128M', memoryMaximumSize: '320M')
gradle.taskGraph.whenReady {taskGraph ->
if (!taskGraph.hasTask(':release')) {
version += '-SNAPSHOT'
}
if (taskGraph.hasTask(':test') && taskGraph.hasTask(':withCoverage')) {
new Coverage(this).setup()
}
}
task release(dependsOn: ['build']) << {
println 'We release now'
}
task withCoverage { // only here such that it can be put on the command line for enabling coverage
description = "prepare the test task to use code coverage if needed"
}
test {
forkEvery = 600
maxParallelForks = hasProperty('gpars_maxTestForks') ? gpars_maxTestForks : 1
}
try {
uploadArchives {
repositories.mavenDeployer {
uniqueVersion = false
configuration = configurations.deployerJars
repository(url: "dav:https://dav.codehaus.org/repository/gpars/") {
authentication(userName: gpars_repoUserName, password: gpars_repoPassword)
}
snapshotRepository(url: "dav:https://dav.codehaus.org/snapshots.repository/gpars/") {
authentication(userName: gpars_repoUserName, password: gpars_repoPassword)
}
// In the future Gradle will allow to use dynamic props for dependencies to deal with optionals
pom.whenConfigured {pom ->
// dependency is a native Maven dependency object (With properties artifactId, groupId, ...)
pom.dependencies.each {dependency ->
def optionalDependencies = ['netty', 'jcsp']
if (dependency.artifactId in optionalDependencies) {
dependency.optional = true
}
}
}
}
}
}
catch (Exception e) {
// It may be that gpars_repoUserName and/or gpars_repoPassword are not defined in which case an exception
// will be thrown. As it is impossible to do an upload if these are not defined then we don't really
// care that the uploadArchives specification hasn't completed.
}
def titleForDocumentation = archivesBaseName + ' ' + version
def copyrightString = 'Copyright © 2008–2010 Václav Pech. All Rights Reserved.'
def packageTitle = group
javadoc {
options.overview('overview.html')
options.showAll()
options.encoding('UTF-8')
options.setUse(true)
options.author(true)
options.version(true)
options.windowTitle(titleForDocumentation)
options.docTitle(titleForDocumentation)
options.footer(copyrightString)
}
javadoc.doFirst {
javadoc.title = titleForDocumentation
javadoc.options.docTitle = javadoc.title
}
groovydoc {
dependsOn(classes)
includePrivate = true
use = true
windowTitle = packageTitle
docTitle = packageTitle
header = packageTitle
footer = copyrightString
include 'groovyx/gpars/**'
overview = new File('overview.html')
}
task documentation(dependsOn: ['javadoc', 'groovydoc', 'docs'], description: 'Create the API documentation.')
task docs << {
ant.taskdef(name: 'docs', classname: 'grails.doc.ant.DocPublisherTask', classpath: configurations.docs.asPath)
ant.docs(src: "grails-doc/src", dest: "build/docs/guide", properties: "grails-doc/src/doc.properties", styleDir: new File('grails-doc/resources/style'), cssDir: new File('grails-doc/resources/css'), imagesDir: new File('grails-doc/resources/img'))
}
task zipDoc(type: Zip, dependsOn: 'documentation') {
appendix = 'docs'
from(docsDir)
}
task zipSrc(type: Zip) {
appendix = 'src'
from sourceSets.main.allSource
}
//task zipSamples(dependsOn: 'demo', type: Zip) {
task zipSamples(type: Zip) {
appendix = 'samples'
from sourceSets.test.allSource.matching {
include 'groovyx/gpars/samples/**'
}
}
task zipJavaDemo(type: Zip) {
appendix = 'mvn-java-demo'
from('java-demo') {
include 'src/**'
include 'pom.xml'
}
}
task copyThirdPartyLibs(type: Copy) {
from('lib')
into('build/dist')
exclude('junit-4.7.jar', 'netty-3.1.5.GA-sources.jar')
}
task copyLibs(type: Copy) {
from('build/libs')
into('build/dist')
}
task copyDists(type: Copy) {
from('build/distributions')
into('build/dist')
}
task copyLicense(type: Copy) {
from('src/main/resources/META-INF/')
into('build/dist')
include('LICENSE.txt', 'NOTICE.txt')
}
task zipDist(dependsOn: ['jar', 'copyThirdPartyLibs', 'copyLibs', 'copyDists', 'copyLicense'], type: Zip) {
appendix = 'all'
from 'build/dist'
}
zipDist << {
ant.delete(dir: file('build/dist'), failonerror: true)
}
task wrapper(type: Wrapper) {
jarPath = 'wrapper'
gradleVersion = '0.9-rc-3'
}
task demo(type: DemoTask, dependsOn: 'compileGroovy') {
excludedDemos = [
'DemoPotentialDeadlock', // may deadlock (on purpose)
'DemoNonDeterministicDeadlockWithDataFlows', // may deadlock (on purpose)
'DemoDeadLock', // deadlock (on purpose)
'DemoRemote', // doesn't work in an automated environment
'DemoSwing', // maybe we don't want these to run on the CI ..
'DemoSwingMashup', // but they can be run locally
'DemoSwingCollectionProcessing',
'DemoSwingActors',
'DemoSwingDataFlowOperators',
'DemoSwingFancyDataFlow', // Shows UI
'DemoSwingDataFlowProgress', // Shows UI
'DemoMapReduce', // Relies on internet connection
'DemoNumbers', //Never stops
'FibonacciV1', //Never stops
'FibonacciV2', //Never stops
'DemoSieveEratosthenesCSP', //Never stops
'DemoSieveEratosthenesTheGoWay', //Never stops
'DemoSieveEratosthenesTheGoWayWithOperators', //Never stops
'DemoThreading', //Never stops
'DemoFibonacci1', //Needs classes from its source folder
'DemoFibonacci2', //Needs classes from its source folder
'DemoNumbers', //Needs classes from its source folder
'DemoActor_4_4', //Specifies absolute paths
'RunReset', //Starts UI
]
classpath = sourceSets.main.runtimeClasspath
demoFiles = sourceSets.test.allGroovy.matching {
include '**/*Demo*.groovy'
exclude excludedDemos.collect {name -> "**/${name}.groovy" }
}
}
class DemoTask extends DefaultTask {
@org.gradle.api.tasks.InputFiles
FileCollection classpath
@org.gradle.api.tasks.InputFiles
FileCollection demoFiles
List excludedDemos
@org.gradle.api.tasks.TaskAction
def runDemos() {
def shell = createShell()
def failed = []
def ok = 0
demoFiles.files.each {File file ->
println "*** starting demo $file.name"
try {
shell.evaluate(file)
ok += 1
} catch (Exception ex) {
failed << [file: file, exception: ex]
}
println "*** done"
}
println "*** cleaning up"
shell.evaluate("groovyx.gpars.dataflow.DataFlow.DATA_FLOW_GROUP.shutdown()")
println "=== demos: $ok ok, ${failed.size()} failed"
failed.each { println "${it.file}\n ${it.exception}" }
}
private GroovyShell createShell() {
URLClassLoader classloader = new URLClassLoader(
classpath.files.collect {File classpathElement -> classpathElement.toURL()} as URL[],
Thread.currentThread().contextClassLoader
)
System.metaClass.static.exit = {int returnCode -> println ">>> System.exit($returnCode) suppressed." }
System.in.metaClass.read = {-> println ">>> System.in.read() suppressed"; 'Automated build' }
System.in.metaClass.readLines = {-> println ">>> System.in.read() suppressed"; ['Automated build'] }
new GroovyShell(classloader)
}
}