This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
/
build.gradle
276 lines (237 loc) · 10.6 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
def groovyVersion = System.getProperty('groovyVersion') ?: '1.7.8'
def spockDependency = "org.spockframework:spock-core:0.5-groovy-${groovyVersion[0..2]}"
def groovyProjects() {
subprojects.findAll { project -> isGroovyProject(project) }
}
def isGroovyProject(project) {
def isGrailsPlugin = project.name.contains("grails-plugins")
def isDocumentation = project.name.contains("documentation")
!isGrailsPlugin && !isDocumentation
}
apply plugin: 'idea'
subprojects {
releaseType = "BUILD-SNAPSHOT"
version = "1.0.0.${releaseType}"
def isSpringProject = project.name.contains("spring-datastore")
def isStandardGroovyMavenProject = isGroovyProject(project)
if (isStandardGroovyMavenProject) {
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'idea'
apply from: "file:${rootDir}/clover.gradle"
}
def isGormDatasource = project.name.startsWith("grails-datastore-gorm-") && !project.name.endsWith("tck")
repositories {
mavenRepo name:'mavenLocal',
urls:new File(System.getProperty("user.home"), ".m2/repository").toURL().toString()
mavenRepo name: "spock-snapshots", urls: ["http://m2repo.spockframework.org/snapshots"]
mavenRepo name: "springAWS", urls: 'http://maven.springframework.org/release'
mavenRepo name: "spring-milestone", urls: 'http://maven.springframework.org/milestone'
mavenRepo name: "spring-snapshot", urls: 'http://maven.springframework.org/snapshot'
mavenRepo name: "jboss", urls:'http://repository.jboss.org/maven2/'
mavenRepo name: "java.net", urls:"http://download.java.net/maven/2/"
mavenCentral()
}
dependencies {
if (isStandardGroovyMavenProject) {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: groovyVersion
testCompile 'junit:junit:4.8.1'
testCompile (spockDependency) {
transitive = false
}
}
if (project.name == "grails-datastore-gorm-tck") {
compile spockDependency
}
}
if (isGormDatasource) {
dependencies {
testCompile project(":grails-datastore-gorm-tck")
}
// We need to test against the TCK. Gradle cannot find/run tests from jars
// without a lot of plumbing, so here we copy the class files from the TCK
// project into this project's test classes dir so Gradle can find the test
// classes and run them. See grails.gorm.tests.GormDatastoreSpec for on the TCK.
// helper, used below.
def toBaseClassRelativePathWithoutExtension = { String base, String classFile ->
if (classFile.startsWith(base)) {
def sansClass = classFile[0 .. classFile.size() - ".class".size() - 1]
def dollarIndex = sansClass.indexOf('$')
def baseClass = dollarIndex > 0 ? sansClass[0..dollarIndex - 1] : sansClass
def relative = baseClass - base - '/'
relative
}
else {
null
}
}
test.doFirst {
def tckClassesDir = project(":grails-datastore-gorm-tck").sourceSets.main.classesDir
def thisProjectsTests = // surely there is a less hardcoded way to do this
copy {
from tckClassesDir
into sourceSets.test.classesDir
include "**/*.class"
exclude { details ->
// Do not copy across any TCK class (or nested classes of that class)
// If there is a corresponding source file in the particular modules
// test source tree. Allows a module to override a test/helper.
def candidatePath = details.file.absolutePath
def relativePath = toBaseClassRelativePathWithoutExtension(tckClassesDir.absolutePath, candidatePath)
if (relativePath == null) {
throw new IllegalStateException("$candidatePath does not appear to be in the TCK")
}
project.file("src/test/groovy/${relativePath}.groovy").exists()
}
}
}
}
if (project.name.startsWith("grails-")) {
group = "org.grails"
archivesBaseName = "grails-datastore"
}
else {
group = "org.springframework"
archivesBaseName = 'spring-datastore'
}
if (isStandardGroovyMavenProject) {
configure(install.repositories.mavenInstaller) {
pom.whenConfigured { pom ->
def dependency = pom.dependencies.find { dep -> dep.artifactId == 'slf4j-simple' }
dependency?.optional = true
}
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'http://github.com/SpringSource/spring-data-mapping/'
}
}
}
}
uploadArchives {
description = "Does a maven deploy of archives artifacts"
def isDav = System.getProperty("deploy.protocol") == 'dav'
def protocol = isDav ? 'dav:' : ''
// def releaseRepositoryUrl = "https://dav.codehaus.org/repository/grails/"
/* def milestoneRepositoryUrl = isSpringProject ? 's3://maven.springframework.org/milestone' :
"${protocol}https://dav.codehaus.org/repository/grails/"
def snapshotRepositoryUrl = isSpringProject ? 's3://maven.springframework.org/snapshot' :
"${protocol}https://dav.codehaus.org/snapshots.repository/grails/"
*/
def milestoneRepositoryUrl = 's3://maven.springframework.org/milestone'
def snapshotRepositoryUrl = 's3://maven.springframework.org/snapshot'
// add a configuration with a classpath that includes our s3 maven deployer
configurations { deployerJars }
dependencies {
deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
// NOTE!!!!!: Maven deployment over webdav is broken due to SHA1 checksum issues. To deploy
// you first need to run ./gradlew -Ddeploy.protocol=dav uploadArchives
// and then ./gradlew uploadArchives a second time to get a valid deployment
if (isDav) {
deployerJars "org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6"
}
else {
deployerJars "org.apache.maven.wagon:wagon-http-lightweight:1.0-beta-6"
}
}
repositories.mavenDeployer {
switch (releaseType) {
case 'RELEASE':
// TODO: Will need to update this when doing a non-snapshot/milestone release
// repository(url: releaseRepositoryUrl)
// description += releaseRepositoryUrl
break;
case ~/M[0-9]+/:
description += milestoneRepositoryUrl
// fall through and pick up config below
case 'BUILD-SNAPSHOT':
description += snapshotRepositoryUrl
def credentials
/* if (isSpringProject) {
*/ credentials = [userName: project.properties.s3AccessKey,
passphrase: project.properties.s3SecretAccessKey]
/* }
else {
credentials = [userName: project.properties['codehaus.username'],
password: project.properties['codehaus.password']]
}
*/ configuration = configurations.deployerJars
repository(url: milestoneRepositoryUrl) {
authentication(credentials)
}
snapshotRepository(url: snapshotRepositoryUrl) {
authentication(credentials)
}
break;
}
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
}
}
}
configurations {
build
}
repositories {
mavenCentral()
}
dependencies {
build "com.cenqua.clover:clover:3.0.2"
build "org.apache.ant:ant-junit:1.8.1"
build "org.apache.ant:ant-nodeps:1.8.1"
}
task test(dependsOn: getTasksByName("test", true)) << {
def reportsDir = "${buildDir}/reports"
// Aggregate the test results
ant.taskdef(
name: 'junitreport2',
classname: "org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator",
classpath: configurations.build.asPath
)
def testReportsDir = new File("${reportsDir}/tests")
if (testReportsDir.exists()) {
testReportsDir.deleteDir()
}
testReportsDir.mkdirs()
ant.junitreport2(todir: testReportsDir) {
subprojects.each {
def testResultsDir = "${it.buildDir}/test-results"
if (new File(testResultsDir).exists()) {
fileset(dir: testResultsDir) {
include(name: "TEST-*.xml")
}
}
}
report(todir: testReportsDir)
}
// Aggregate the coverage results
if (project.hasProperty("withClover")) {
def db = "clover/clover.db"
def mergedDb = "${buildDir}/${db}"
def cloverReportsDir = "${reportsDir}/clover"
ant.taskdef(resource: "cloverlib.xml", classpath: configurations.build.asPath)
ant."clover-merge"(initstring: mergedDb) {
subprojects.each {
def projectCloverDb = "${it.buildDir}/${db}"
if (new File(projectCloverDb).exists()) {
cloverdb(initstring: projectCloverDb)
}
}
}
ant."clover-report"(initstring: mergedDb) {
current(outfile:"${cloverReportsDir}/clover.xml")
}
ant."clover-html-report"(initstring: mergedDb, outdir:"${cloverReportsDir}/html")
}
}