-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
126 lines (108 loc) · 4.96 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
//apply plugin: "groovy"
apply plugin: "base"
archivesBaseName = "grails-doc-ja"
outputDir = "${buildDir.path}/docs"
checkOutDir = "${buildDir.path}/checkout"
explicitGrailsHome = System.getProperty("grails.home")
grailsHome = explicitGrailsHome ? file(explicitGrailsHome).absolutePath : "$checkOutDir/grails-src"
configurations {
publish
}
repositories {
mavenRepo urls: "http://download.java.net/maven/2/"
mavenCentral()
mavenRepo urls: "http://snapshots.repository.codehaus.org/"
}
dependencies {
publish "org.grails:grails-gdoc-engine:1.0-SNAPSHOT", "org.codehaus.groovy:groovy:1.8.0"
publish "org.slf4j:slf4j-log4j12:1.5.8",
"org.xhtmlrenderer:core-renderer:R8",
"org.yaml:snakeyaml:1.8"
}
task apiDocs(type: GradleBuild) {
def deps = [":grails-docs:install"]
if (!System.getProperty("disable.groovydocs")) {
deps << 'groovydoc'
}
tasks = deps
buildFile = "${project.grailsHome}/build.gradle"
}
task copyApiDocs(type: Copy) {
from "${project.grailsHome}/doc/api"
into "${outputDir}/api"
}
task createPublishClassLoader << {
// Create a class loader for the publication stuff.
def classpath = project.configurations.publish
classpath = classpath.files.collect { it.toURI().toURL() }
// Add the grails-docs JAR.
def distDir = project.file("${project.grailsHome}/dist")
def grailsDocJars = distDir.listFiles({ dir, name -> name ==~ /grails-docs-.*\.jar/ } as FilenameFilter)
if (grailsDocJars.size() > 1) {
log.error "Found multiple grails-doc JARs in ${distDir}"
return 1
}
else if (grailsDocJars.size() == 0) {
log.error "No grails-doc JAR found in ${distDir}"
return 2
}
classpath << grailsDocJars[0].toURI().toURL()
project.publishClassLoader = new URLClassLoader(
classpath as URL[],
buildscript.classLoader)
}
task publishGuide(dependsOn:['apiDocs','copyApiDocs','createPublishClassLoader']){
sourceDir = projectDir.path + "/src/ja"
targetDir = outputDir
workDir = buildDir
doLast {
def props = new Properties()
new File("${projectDir}/grails-doc/resources/doc.properties").withInputStream {input ->
props.load(input)
}
new File("${project.grailsHome}/build.properties").withInputStream {input ->
props.load(input)
}
//loading props for translation
def langProp = new ConfigSlurper().parse(new File("./src/ja/titles.groovy").getText('UTF-8'))
props.title = langProp.props.title
props.authors = props.authors + langProp.props.authors + langProp.props.translatorMessage
props.footer = props.footer + langProp.props.footer
props.copyright = props.copyright + langProp.props.copyright
def publisher = publishClassLoader.loadClass("grails.doc.DocPublisher").newInstance(file(sourceDir), file(targetDir))
publisher.ant = ant
publisher.workDir = workDir
publisher.images = file("${projectDir}/grails-doc/resources/img")
publisher.css = file("${projectDir}/grails-doc/resources/css")
publisher.js = file("${projectDir}/grails-doc/resources/js")
publisher.style = file("${projectDir}/resources/style")
publisher.title = props.title
publisher.version = props."grails.version"
publisher.authors = props.authors
publisher.copyright = props.copyright
publisher.footer = props.footer
publisher.logo = '<a href="http://grails.org" target="_blank"><img alt="Grails Logo" title="The Grails Framework" src="${path}/img/grails.png" border="0"/></a>'
publisher.sponsorLogo = '<a href="http://springsource.com" target="_blank"><img alt="SpringSource Logo" title="SpringSource - Weapons for the War on Java Complexity" src="${path}/img/springsource-logo.png" border="0"/></a>'
publisher.engineProperties = props
// Add support for displaying the source code for GSP tags.
def sourceMacro = publishClassLoader.loadClass("grails.doc.macros.GspTagSourceMacro")
def searchDirs = file(project.grailsHome).listFiles().findAll {
new File(it, "src/main/groovy/org/codehaus/groovy/grails").exists()
}.collect {
new File(it, "src/main/groovy/org/codehaus/groovy/grails")
}
publisher.registerMacro(sourceMacro.newInstance(searchDirs))
//hidden macro
def hiddenMacro = publishClassLoader.loadClass("macros.HiddenMacro")
publisher.registerMacro(hiddenMacro.newInstance())
// Radeox loads its bundles off the context class loader, which
// unfortunately doesn't contain the grails-docs JAR. So, we
// temporarily switch the DocPublisher class loader into the
// thread so that the Radeox bundles can be found.
def oldClassLoader = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = publisher.getClass().classLoader
publisher.publish()
// Restore the old context class loader.
Thread.currentThread().contextClassLoader = oldClassLoader
}
}