-
Notifications
You must be signed in to change notification settings - Fork 536
/
build.gradle
224 lines (185 loc) · 8.75 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
plugins {
id 'base'
id 'org.asciidoctor.jvm.convert' version '4.0.0-alpha.1'
id 'org.grails.grails-gdoc-to-asciidoc'
id 'groovy'
}
repositories {
maven { url = "https://repo.grails.org/grails/core" }
}
import org.apache.tools.ant.taskdefs.condition.Os
version = project.findProperty("grails.version")
archivesBaseName = "grails-docs"
ext.checkOutDir = project.layout.buildDirectory.dir('checkout').get().asFile.absolutePath
ext.outputDir = layout.buildDirectory.file("docs").get().asFile.absolutePath
ext.githubSlug = "grails/grails-doc"
ext.githubBranch = project.findProperty("githubBranch") ?: "7.0.x"
ext.guidePage = "/docs/guide/single.html"
ext.indexPage = "/docs/index.html"
ext.explicitGrailsHome = System.getProperty("grails.home") ?: project.findProperty('grails.home')
ext.grailsHome = explicitGrailsHome ? file(explicitGrailsHome).absolutePath : "${checkOutDir}/grails-src"
ext.projectVersion = project.version
configurations {
publish
configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if ((details.requested.group == 'org.codehaus.groovy' || details.requested.group == 'org.apache.groovy') && details.requested.name != 'groovy-bom') {
details.useTarget(group: 'org.apache.groovy', name: details.requested.name, version: "$groovyVersion")
details.because "The dependency coordinates are changed in Apache Groovy 4, plus ensure version"
}
}
}
}
gdoc2asciidoc {
apiLinks = ['org.hibernate' : 'https://docs.jboss.org/hibernate/orm/current/javadocs/',
'org.springframework.boot' : 'https://docs.spring.io/spring-boot/docs/2.5.2/api',
'org.springframework' : 'https://docs.spring.io/spring/docs/5.3.8/javadoc-api/',
'javax.servlet' : 'https://docs.oracle.com/javaee/1.4/api/',
'java.' : 'https://docs.oracle.com/javase/6/docs/api/',
'groovy.' : 'https://docs.groovy-lang.org/docs/latest/html/api/',
'org.codehaus.groovy.grails': "https://docs.grails.org/$githubBranch/api",
'grails.orm.' : 'https://gorm.grails.org/latest/api',
'grails.gorm.' : 'https://gorm.grails.org/latest/api',
'grails.' : "https://docs.grails.org/$githubBranch/api",
'org.grails.' : "https://docs.grails.org/$githubBranch/api"
]
resourcesDir = file("resources")
srcDir = file("src/en")
}
task buildscriptDependencies(type: DependencyReportTask) {
configurations = [buildscript.configurations.classpath]
}
// use jsoup in PdfBuilder for cleaning input html
System.setProperty('grails.docs.clean.html', 'true')
// creates single.html.before.xml and single.html.after.xml files for debugging pdf input when enabled
//System.setProperty('grails.docs.debug.pdf','true')
asciidoctor {
resources {
from('resources')
}
options template_dirs: ["${projectDir}/src/docs/templates"]
attributes 'experimental': 'true',
'compat-mode': 'true',
'icons': 'font',
'linkcss': 'true',
'docinfo1': '',
'toc': 'left',
'version': project.version,
'sourcedir': grailsHome
}
asciidoctor.dependsOn("apiDocs")
tasks.withType(org.gradle.api.tasks.javadoc.Groovydoc) {
configure {
access = GroovydocAccess.PRIVATE
processScripts = false
includeMainForScripts = false
}
}
task migrate(type: grails.doc.gradle.MigrateLegacyDocs)
tasks.register("dist", Zip) {
dependsOn "docs"
from outputDir
}
tasks.register("createReleaseDropdown", grails.doc.AddReleaseDropDown) {
dependsOn "publishGuide", "publishPdf"
inputFiles = [file("${buildDir.absolutePath}/manual/guide/single.html"), file("${buildDir.absolutePath}/manual/index.html")]
inputs.files(inputFiles)
outputs.dir(outputDir)
}
tasks.register('fetchGrailsSource', grails.doc.FetchGrailsSourceTask) {
onlyIf { !explicitGrailsHome }
}
tasks.register("editProjectArtificat", Exec) {
onlyIf { project.hasProperty("editGrailsVersion") }
dependsOn 'fetchGrailsSource'
executable Os.isFamily(Os.FAMILY_WINDOWS) ? "cmd" : "bash"
args Os.isFamily(Os.FAMILY_WINDOWS) ? "/c" : "-c", "sed -i 's/^projectVersion.*\$/projectVersion=$version/' ${grailsHome}/gradle.properties"
}
tasks.register("apiDocs", Exec) {
onlyIf { !System.getProperty("disable.groovydocs") }
dependsOn 'fetchGrailsSource'
inputs.files(fileTree(grailsHome) {
exclude '**/*.lock'
exclude '**/.gradle'
})
outputs.dir(grailsHome + "/doc")
String command = Os.isFamily(Os.FAMILY_WINDOWS) ? "gradlew.bat" : "./gradlew"
commandLine = [command, "groovydoc", "--quiet", "--no-daemon", "--console=plain", "--project-dir=${grailsHome}"]
workingDir = grailsHome
environment "GRADLE_OPTS", "-Xmx2048m -Xms256m -XX:+HeapDumpOnOutOfMemoryError"
}
tasks.register('downloadPom', grails.doc.DownloadPomTask) {
version = projectVersion
}
tasks.register('extractPomVersions', grails.doc.ExtractPomVersionsTask) {
dependsOn 'downloadPom'
pomFile = downloadPom.outputs.files.singleFile
}
tasks.register('publishGuide', grails.doc.gradle.PublishGuide) {
dependsOn(['apiDocs', 'extractPomVersions', 'jar'])
targetDir = project.layout.buildDirectory.dir("manual").get().asFile
doFirst {
def searchDirs = project.file(project.grailsHome).listFiles().findAll {
new File(it, "src/main/groovy/org/grails").exists()
}.collect {
new File(it, "src/main/groovy/org/grails")
}
// No language setting because we want the English guide to be
// generated with a 'en' in the path, but the source is in 'en'
// so that it's easy to track with git.
sourceRepo = "https://github.com/grails/grails-doc/edit/$githubBranch/src/en"
sourceDir = new File(projectDir, "src/en")
propertiesFiles = [new File(projectDir, "gradle.properties")]
asciidoc = true
properties = [
'javaee' : "https://docs.oracle.com/javaee/7/api/",
'javase' : "https://docs.oracle.com/en/java/javase/17/docs/api/",
'groovyapi' : "https://docs.groovy-lang.org/${groovyVersion}/html/gapi/",
'springapi' : "https://docs.spring.io/spring/docs/${springVersion}/javadoc-api/",
'springdocs' : "https://docs.spring.io/spring/docs/${springVersion}/",
'asyncdocs' : "https://async.grails.org/latest",
'asyncApiDocs' : "https://async.grails.org/latest/api/",
'gspdocs' : "https://gsp.grails.org/${gspVersion}",
'gspApiDocs' : "https://gsp.grails.org/${gspVersion}/api/",
'gormApiDocs' : "https://gorm.grails.org/${gormVersion}/api/",
'hibernateReference' : 'https://docs.jboss.org/hibernate/orm/5.6/userguide/html_single/Hibernate_User_Guide.html',
'springbootapi' : "https://docs.spring.io/spring-boot/docs/${springBootVersion}/api",
'springBootReference': "https://docs.spring.io/spring-boot/docs/${springBootVersion}/reference",
'springBootVersion' : project.springBootVersion,
'springVersion' : project.springVersion,
'gradleVersion' : project.gradleVersion
]
// Parse the string content into Properties object
def props = new Properties()
props.load(new StringReader(file(tasks.extractPomVersions.outputs.files.singleFile).text))
properties += props
macros = [new grails.doc.macros.GspTagSourceMacro(searchDirs)]
}
}
tasks.register('publishPdf', grails.doc.gradle.PublishPdf) {
dependsOn 'publishGuide'
outputDirectory = new File(project.buildDir, "/manual")
}
tasks.register("docs", Copy) {
dependsOn "apiDocs", "publishGuide", "createReleaseDropdown", "publishPdf"
def manualDocsDir = publishGuide.targetDir
def apiDocsDir = file(grailsHome + '/build/docs') // This is the output directory of the groovydoc task in the grails project.
def modifiedPagesDir = createReleaseDropdown.outputDir
def mergedDocsDir = project.layout.buildDirectory.dir('docs')
inputs.dir manualDocsDir
inputs.dir apiDocsDir
inputs.dir modifiedPagesDir
inputs.dir project.layout.projectDirectory.dir("src")
outputs.dir mergedDocsDir
from manualDocsDir, apiDocsDir, modifiedPagesDir
into mergedDocsDir
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
artifacts {
archives dist
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}