-
-
Notifications
You must be signed in to change notification settings - Fork 971
Expand file tree
/
Copy pathbuild.gradle
More file actions
174 lines (152 loc) · 7.26 KB
/
build.gradle
File metadata and controls
174 lines (152 loc) · 7.26 KB
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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
* https://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.
*/
import org.asciidoctor.gradle.jvm.AsciidoctorTask
plugins {
id 'groovy'
id 'org.asciidoctor.jvm.convert'
}
version = projectVersion
ext {
isReleaseVersion = !version.endsWith('SNAPSHOT')
coreProjects = ['grails-datastore-core', 'grails-datamapping-core']
}
configurations {
documentation {
canBeConsumed = false
canBeResolved = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
}
}
}
tasks.register('resolveMongodbVersion').configure { Task docTask ->
docTask.group = 'documentation'
docTask.description = 'Resolve MongoDB Version from the BOM'
ext.resolved = configurations.compileClasspath
.resolvedConfiguration
.resolvedArtifacts
.find {
it.moduleVersion.id.group == 'org.mongodb' &&
it.moduleVersion.id.name.contains('mongodb-driver-sync')
}.moduleVersion.id.version
logger.lifecycle('Resolved MongoDB Driver version for Guide links: {}', resolved)
}
dependencies {
documentation platform(project(':grails-bom'))
documentation 'org.fusesource.jansi:jansi'
documentation 'org.apache.groovy:groovy'
documentation 'org.apache.groovy:groovy-templates'
documentation 'org.apache.groovy:groovy-dateutil'
documentation 'com.github.javaparser:javaparser-core'
coreProjects.each {
documentation "org.apache.grails.data:$it"
}
rootProject.subprojects
.findAll { it.findProperty('gormApiDocs') }
.each { documentation project(":$it.name") }
// These are added to be able to resolve the mongo version from grails-bom
// in the resolveMongodbVersion task
implementation platform(project(':grails-bom'))
implementation 'org.mongodb:mongodb-driver-sync'
}
tasks.named('asciidoctor', AsciidoctorTask) { AsciidoctorTask it ->
dependsOn('resolveMongodbVersion')
it.inputs.dir(project.layout.projectDirectory.dir('src/docs/asciidoc')).withPropertyName('docsSrcDir').withPathSensitivity(PathSensitivity.RELATIVE)
it.outputs.dir layout.buildDirectory.dir('asciidoc/manual')
it.jvm {
jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED")
}
it.baseDirFollowsSourceFile()
it.sourceDir layout.projectDirectory.dir('src/docs/asciidoc')
it.outputDir = layout.buildDirectory.dir('asciidoc/manual')
it.attributes = [
'experimental' : 'true',
'compat-mode' : 'true',
'toc' : 'left',
'icons' : 'font',
'reproducible' : '',
'version' : projectVersion,
'pluginVersion' : projectVersion,
'mongoDriverVersion' : resolveMongodbVersion.resolved,
'grailsTestExamplesMongodbBaseDir' : project.layout.projectDirectory.dir('src/docs/asciidoc').asFile.relativePath(rootProject.findProject(':grails-test-examples-mongodb-base').layout.projectDirectory.asFile),
'grailsTestExamplesMongodbHibernate5Dir' : project.layout.projectDirectory.dir('src/docs/asciidoc').asFile.relativePath(rootProject.findProject(':grails-test-examples-mongodb-hibernate5').layout.projectDirectory.asFile),
'grailsDataMongodbCoreDir' : project.layout.projectDirectory.dir('src/docs/asciidoc/querying').asFile.relativePath(rootProject.findProject(':grails-data-mongodb-core').layout.projectDirectory.asFile)
]
}
tasks.withType(Groovydoc).configureEach { Groovydoc groovydoc ->
groovydoc.dependsOn(rootProject.subprojects
.findAll { it.findProperty('gormApiDocs') }
.collect { ":${it.name}:groovydoc" })
groovydoc.docTitle = "GORM for MongoDB - $project.version"
groovydoc.footer = '''<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setDoNotTrack", true]);
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '79']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->'''
def sourceFiles = coreProjects.collect {
layout.projectDirectory.files("$it/src/main/groovy")
}.sum()
rootProject.subprojects
.findAll { it.findProperty('gormApiDocs') }
.each { sourceFiles += it.files('src/main/groovy') }
groovydoc.source = sourceFiles
groovydoc.destinationDir = layout.buildDirectory.dir('combined-api/api').get().asFile
groovydoc.access = GroovydocAccess.PROTECTED
groovydoc.processScripts = false
groovydoc.includeMainForScripts = false
groovydoc.includeAuthor = true
groovydoc.classpath = configurations.documentation
groovydoc.groovyClasspath += configurations.documentation
groovydoc.noVersionStamp = false
}
tasks.register('docs', Sync).configure { Sync docTask ->
docTask.group = 'documentation'
docTask.dependsOn('asciidoctor', 'groovydoc')
def apiDir = layout.buildDirectory.dir('combined-api')
def resourceDir = layout.projectDirectory.dir('src/docs/resources')
def guideDir = layout.buildDirectory.dir('asciidoc')
docTask.from apiDir, resourceDir, guideDir
docTask.into layout.buildDirectory.dir('docs')
docTask.finalizedBy('assembleDocsDist')
}
tasks.register('assembleDocsDist', Zip).configure { Zip it ->
it.dependsOn('docs')
it.from(layout.buildDirectory.dir('docs'))
it.archiveFileName = "${project.name}-${project.version}.zip"
it.destinationDirectory = project.layout.buildDirectory.dir('distributions')
}
// the groovy plugin is applied to this project, but we do not build a jar file since
// the dependencies are only used for resolving versions from the bom
tasks.withType(Jar).configureEach {
enabled = false
}