Skip to content

Commit

Permalink
refactor(build): update build configurations (#195)
Browse files Browse the repository at this point in the history
Move the Gradle documentation related configurations from the main `build.gradle` to a separate `gradle/docs.gradle` file for easy maintenance.
  • Loading branch information
puneetbehl committed Mar 19, 2024
1 parent f19e158 commit 338b337
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 48 deletions.
49 changes: 1 addition & 48 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ apply plugin: 'groovy'
apply plugin: "com.github.erdi.webdriver-binaries"
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.internal.grails-plugin-publish"
apply from: 'gradle/docs.gradle'

repositories {
mavenCentral()
Expand Down Expand Up @@ -108,49 +109,6 @@ tasks.withType(Test) {
}
}

task publishGuide(type: grails.doc.gradle.PublishGuide) {
group = 'documentation'
description = 'Generate Guide'

targetDir = project.file("${buildDir}/docs")
sourceRepo = "https://github.com/${githubSlug}/edit/${githubBranch}/src/main/docs"
sourceDir = new File(projectDir, "src/main/docs")
propertiesFiles = [ new File(rootProject.projectDir, "gradle.properties") ]
asciidoc = true
properties = [
'safe':'UNSAFE',
'version': project.version,
'subtitle': project.projectDesc,
'api': '../api',
'sourceDir':rootProject.projectDir.absolutePath,
'sourcedir':rootProject.projectDir.absolutePath,
'javaee': 'https://docs.oracle.com/javaee/7/api/',
'javase': 'https://docs.oracle.com/javase/7/docs/api/',
'groovyapi': 'https://docs.groovy-lang.org/latest/html/gapi/',
'grailsapi': 'https://docs.grails.org/latest/api/',
'gormapi': 'https://gorm.grails.org/latest/api/',
'springapi': 'https://docs.spring.io/spring/docs/current/javadoc-api/'
]
doLast {
ant.move(file:"${project.buildDir}/docs/guide/single.html",
tofile:"${project.buildDir}/docs/guide/index.html", overwrite:true)
new File(project.buildDir, "docs/index.html").text = '''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:https://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="refresh" content="0; url=guide/index.html" />
</head>
</body>
</html>
'''
}
}

task docs(dependsOn:[groovydoc, publishGuide]) {
group = 'documentation'
}

bootRun {
jvmArgs(
'-Dspring.output.ansi.enabled=always',
Expand Down Expand Up @@ -187,8 +145,3 @@ jar {
includeEmptyDirs = false
exclude 'com/demo/**'
}

tasks.named("build") {
finalizedBy("docs")
}

65 changes: 65 additions & 0 deletions gradle/docs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
buildscript {
repositories {
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-docs:${project.ext.properties.grailsDocsVersion ?: grailsVersion}"
}
}

repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}

configurations {
documentation.extendsFrom(compileClasspath)
}

task publishGuide(type: grails.doc.gradle.PublishGuide) {
group = 'documentation'
description = 'Generate Guide'

targetDir = project.file("${buildDir}/docs")
sourceRepo = "https://github.com/${githubSlug}/edit/${githubBranch}/src/main/docs"
sourceDir = new File(projectDir, "src/main/docs")
resourcesDir = new File(projectDir, "src/main/docs/resources")
propertiesFiles = [ new File(rootProject.projectDir, "gradle.properties") ]
asciidoc = true
properties = [
'safe':'UNSAFE',
'version': project.version,
'subtitle': project.projectDesc,
'api': '../api',
'sourceDir':rootProject.projectDir.absolutePath,
'sourcedir':rootProject.projectDir.absolutePath,
'javaee': 'https://docs.oracle.com/javaee/7/api/',
'javase': 'https://docs.oracle.com/javase/7/docs/api/',
'groovyapi': 'https://docs.groovy-lang.org/latest/html/gapi/',
'grailsapi': 'https://docs.grails.org/latest/api/',
'gormapi': 'https://gorm.grails.org/latest/api/',
'springapi': 'https://docs.spring.io/spring/docs/current/javadoc-api/'
]
doLast {
ant.move(file:"${project.buildDir}/docs/guide/single.html",
tofile:"${project.buildDir}/docs/guide/index.html", overwrite:true)
new File(project.buildDir, "docs/index.html").text = '''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:https://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="refresh" content="0; url=guide/index.html" />
</head>
</body>
</html>
'''
}
}

task docs(dependsOn:[groovydoc, publishGuide]) {
group = 'documentation'
}

tasks.named("build") {
finalizedBy("docs")
}

0 comments on commit 338b337

Please sign in to comment.