-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
88 lines (68 loc) · 2.57 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
import grails.doc.*
import org.radeox.engine.context.*
import groovy.io.FileType
import grails.doc.macros.HiddenMacro
// usage: gradle -q -Dgrails.home=<GRAILS_HOME> -Dgrails.doc=<GRAILS_DOC_PROJECT_DIR> clean easyDocs_ja
//----------------------------
// System properties
// -Ddisable.groovydocs=true
System.properties['disable.groovydocs'] = 'true'
// -Dgrails.home=$GRAILS_HOME
ext._grailsHome = System.properties['grails.home'] ?: System.env['GRAILS_HOME'] ?: "${System.properties['user.home']}/.gvm/grails/current"
// -Dgrails.doc=$GRAILS_DOC_PROJECT_DIR
ext.grailsDocProjectDir = file(System.properties["grails.doc"] ?: System.env["GRAILS_DOC_PROJECT_DIR"] ?: "../grails-doc")
if (!grailsDocProjectDir.exists()) {
println "WARN: The directory of grails-doc ${grailsDocProjectDir.path} not found."
execCommand(["git", "clone", "https://github.com/jggug/grails-doc.git"], new File(".."))
ext.grailsDocProjectDir = file("../grails-doc")
}
//----------------------------
// Projct variables
ext.buildResourcesDir = file("${buildDir.path}/copied-resources")
//----------------------------
// Includes
apply from: "${grailsDocProjectDir.path}/build.gradle"
// for using grails.doc.gradle.PublishGuide
buildscript {
repositories {
mavenRepo url: "http://repo.grails.org/grails/core"
}
dependencies {
classpath "org.grails:grails-docs:2.2.0"
}
}
//----------------------------
// Tasks
task _copyResourcesDirFromGrailsDoc(type: Copy) {
from "${grailsDocProjectDir.path}/resources"
into buildResourcesDir
}
task _copyApiDocs(type: Copy) {
from "${_grailsHome}/doc/api"
into "${buildDir.path}/docs/api"
}
task _publishGuide_ja(type: grails.doc.gradle.PublishGuide, dependsOn: ['_copyResourcesDirFromGrailsDoc', '_copyApiDocs']) {
sourceDir = projectDir
resourcesDir = buildResourcesDir
propertiesFiles << new File("./doc_ja.properties")
propertiesFiles << new File(_grailsHome, "build.properties")
}
task easyDocs_ja {
dependsOn '_publishGuide_ja'
}
task syntaxChecker << {
def context = new BaseInitialRenderContext()
def engine = new DocEngine(context)
engine.addMacro(new HiddenMacro())
file("guide").traverse(type: FileType.FILES, nameFilter: ~/^.+\.gdoc$/) { File gdoc ->
println gdoc
engine.render(gdoc.text,context)
}
}
defaultTasks 'easyDocs_ja'
//----------------------------
// Helpers
def execCommand(List command, File currentDir = null) {
println "Executing '${command.join(' ')}' at ${currentDir?.canonicalPath ?: 'current dir'} ..."
println command.execute([], currentDir).text
}