forked from grails/gorm-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
381 lines (322 loc) · 14.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.JSON
buildscript {
repositories {
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.2"
classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.6.1'
classpath "gradle.plugin.com.energizedwork.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
classpath "org.grails.plugins:views-gradle:2.1.1"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}
logger.lifecycle "GORM VERSION = ${project.datastoreVersion}"
group "org.grails"
version project.projectVersion
ext {
isTravisBuild = System.getenv().get("TRAVIS") == 'true'
hibernatePluginVersion = project.hibernatePluginVersion
isCiBuild = project.hasProperty("isCiBuild")
isBuildSnapshot = project.version.endsWith("-SNAPSHOT")
isReleaseVersion = !isBuildSnapshot
servletApiVersion = "4.0.1"
nexusUsername = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
nexusPassword = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
}
ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY')
ext."signing.password" = project.hasProperty("signing.password") ? project.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE')
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg"
if (isReleaseVersion) {
apply plugin: 'maven-publish'
apply plugin: "io.github.gradle-nexus.publish-plugin"
nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : ''
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
}
}
}
}
subprojects { project ->
repositories {
maven { url "https://repo.grails.org/grails/core" }
if(groovyVersion && groovyVersion.endsWith('-SNAPSHOT')) {
maven {
name 'JFrog OSS snapshot repo'
url 'https://oss.jfrog.org/oss-snapshot-local/'
}
}
}
ext['h2.version'] = h2Version
ext['gorm.version'] = datastoreVersion
ext['gorm.hibernate5.version'] = hibernatePluginVersion
ext['junit-jupiter.version'] = junitJupiterVersion
ext['spock.version'] = spockVersion
if (project.name.startsWith("examples")) {
apply plugin: 'groovy'
if(project.name.contains('grails3')) {
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
}
boolean usesGeb = project.name.contains('grails3-hibernate5-mongodb') || project.name.contains('grails3-mongodb') || project.name.contains('grails3-mongodb-database-per-tenant')|| project.name.contains('grails3-rxmongodb')
if (usesGeb) {
apply plugin:"com.energizedwork.webdriver-binaries"
}
if (project.name == "examples-test-data-service") {
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.plugins.views-json"
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name.startsWith('groovy')) {
details.useVersion(groovyVersion)
} else if (details.requested.group == 'org.mongodb' && details.requested.module.name != 'mongodb-driver-rx') {
details.useVersion(mongodbDriverVersion)
} else if (details.requested.group == 'org.springframework') {
details.useVersion(springVersion)
} else if (details.requested.group == "org.springframework.boot") {
details.useVersion(springBootVersion)
}
}
}
dependencies {
testImplementation "org.hibernate:hibernate-validator:$hibernateValidatorVersion"
testImplementation "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "org.spockframework:spock-core:$spockVersion", { transitive = false }
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testImplementation "org.junit.platform:junit-platform-runner:1.8.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
return
}
boolean isPluginProject = project.name.endsWith("-plugin") && (project.name.startsWith("grails") || project.name.startsWith("rx-"))
boolean isGrails3PluginProject = project.name.endsWith("-plugin")
ext {
projectInfo = new PublishingConvention(project)
pomInfo = {
delegate.name projectInfo.projectName
delegate.description projectInfo.projectDescription
delegate.url projectInfo.projectURL
delegate.licenses {
delegate.license {
delegate.name 'The Apache Software License, Version 2.0'
delegate.url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
delegate.distribution 'repo'
}
}
delegate.scm {
delegate.url projectInfo.projectVcsUrl
delegate.connection projectInfo.projectVcsUrl
delegate.developerConnection projectInfo.projectVcsUrl
}
delegate.developers {
delegate.developer {
delegate.id 'graemerocher'
delegate.name 'Graeme Rocher'
}
delegate.developer {
delegate.id 'jeffscottbrown'
delegate.name 'Jeff Brown'
}
delegate.developer {
delegate.id 'burtbeckwith'
delegate.name 'Burt Beckwith'
}
}
}
}
configurations.all {
resolutionStrategy {
cacheDynamicVersionsFor 0, 'hours'
cacheChangingModulesFor 0, 'hours'
}
}
configurations.create('documentation') {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
}
}
if(isPluginProject) {
group "org.grails.plugins"
version( rootProject.version )
}
else {
group "org.grails"
version rootProject.version
}
if(project.name == 'docs') {
return
}
if(isGrails3PluginProject) {
apply plugin: "org.grails.grails-plugin"
} else {
apply plugin:"groovy"
}
apply plugin: "java-library"
apply plugin: 'maven-publish'
apply plugin: 'signing'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def dependencyName = details.requested.name
if (dependencyName.startsWith('mongodb-driver') && !dependencyName.contains('-rx')) {
details.useVersion(mongodbDriverVersion)
} else if( details.requested.group == 'org.grails' &&
details.requested.name in ['grails-datastore-core',
'grails-datastore-async',
'grails-datastore-gorm',
'grails-datastore-gorm-async',
'grails-datastore-gorm-rx',
'grails-datastore-gorm-support',
'grails-datastore-gorm-tck',
'grails-datastore-gorm-test',
'grails-datastore-gorm-validation',
'grails-datastore-web']
) {
details.useVersion(datastoreVersion)
} else if (details.requested.group == 'org.mongodb' && details.requested.module.name != 'mongodb-driver-rx') {
details.useVersion(mongodbDriverVersion)
} else if(details.requested.group == 'org.springframework') {
details.useVersion(springVersion)
} else if (details.requested.group == 'org.springframework.boot') {
details.useVersion(springBootVersion)
}
}
}
dependencies {
api "org.codehaus.groovy:groovy:$groovyVersion"
api "org.codehaus.groovy:groovy-templates:$groovyVersion"
testImplementation "org.codehaus.groovy:groovy-json:$groovyVersion"
testImplementation "org.codehaus.groovy:groovy-templates:$groovyVersion"
documentation "org.fusesource.jansi:jansi:$jansiVersion"
documentation "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
documentation 'info.picocli:picocli:4.6.1'
documentation ("com.github.javaparser:javaparser-core:$javaParserCoreVersion")
testImplementation "org.codehaus.groovy:groovy-test-junit5:$groovyVersion"
testImplementation "org.spockframework:spock-core:$spockVersion", { transitive = false }
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1"
testImplementation "org.junit.platform:junit-platform-runner:1.8.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.2"
}
groovydoc.classpath += configurations.documentation
configurations {
all {
resolutionStrategy {
force "org.codehaus.groovy:groovy:$groovyVersion"
force "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
force "org.codehaus.groovy:groovy-xml:$groovyVersion"
force "org.codehaus.groovy:groovy-templates:$groovyVersion"
}
}
}
Task sourcesJar = project.tasks.findByName("sourcesJar")
if (!sourcesJar) {
sourcesJar = tasks.create("sourcesJar", Jar) {
classifier = 'sources'
group = BasePlugin.BUILD_GROUP
description = 'Assembles a jar archive containing the main sources of this project.'
from project.sourceSets.main.allSource
}
}
Task javadocJar = project.tasks.findByName("javadocJar")
if (!javadocJar) {
javadocJar = tasks.create("javadocJar", Jar) {
classifier = 'javadoc'
group = BasePlugin.BUILD_GROUP
description = 'Assembles a jar archive containing the generated Javadoc API documentation of this project.'
from project.plugins.hasPlugin(GroovyPlugin) ? project.tasks.getByName(GroovyPlugin.GROOVYDOC_TASK_NAME) : project.tasks.getByName(JavaPlugin.JAVADOC_TASK_NAME)
}
}
tasks.findByName("assemble").finalizedBy(sourcesJar, javadocJar)
publishing {
if (isBuildSnapshot) {
repositories {
maven {
credentials {
def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : ''
def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : ''
username = u
password = p
}
if (isGrails3PluginProject) {
url "https://repo.grails.org/grails/plugins3-snapshots-local"
} else {
url "https://repo.grails.org/grails/libs-snapshots-local"
}
}
}
}
publications {
maven(MavenPublication) {
artifactId projectInfo.projectArtifactId
from components.java
afterEvaluate {
artifact source: sourcesJar, classifier: "sources"
artifact source: javadocJar, classifier: "javadoc"
if (isGrails3PluginProject) {
artifact source:"${sourceSets.main.groovy.outputDir}/META-INF/grails-plugin.xml",
classifier:"plugin",
extension:'xml'
}
}
pom.withXml {
def xml = asNode()
def dependency = xml.dependencies.find { dep -> dep.artifactId == 'slf4j-simple' }
dependency?.optional = true
xml.children().last() + pomInfo
}
}
}
}
afterEvaluate {
signing {
required { isReleaseVersion }
sign publishing.publications.maven
}
}
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}
//do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
shouldRunAfter(tasks.withType(Sign))
}
}
class PublishingConvention {
Project project
String projectArtifactId
String projectName = 'GORM for MongoDB'
String projectDescription = 'Provides a GORM Object Mapping implementations for the MongodB Document Database'
String projectURL = 'https://gorm.grails.org/latest/mongodb'
String projectIssueTrackerUrl = 'https://github.com/grails/gorm-mongodb/issues'
String projectVcsUrl = 'https://github.com/grails/gorm-mongodb'
PublishingConvention(Project project) {
this.project = project
def name = project.name
if(name.startsWith('grails') && name.endsWith('-plugin')) {
name = 'mongodb'
}
if(name.startsWith('rx') && name.endsWith('-plugin')) {
name = 'rx-mongodb'
projectName = 'RxGORM for MongoDB'
}
projectArtifactId = name
}
}