Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
executable file 509 lines (442 sloc) 17.377 kB
/*
* Copyright 2010 the original author or authors.
*
* Licensed 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
*
* http://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.gradle.build.docs.UserGuideTransformTask
import org.gradle.build.docs.ExtractSnippetsTask
import org.gradle.build.docs.AssembleSamplesDocTask
import org.gradle.build.docs.Docbook2Xhtml
import org.gradle.build.docs.dsl.source.GenerateDefaultImportsTask
import org.gradle.build.docs.dsl.docbook.AssembleDslDocTask
import org.gradle.build.docs.dsl.source.ExtractDslMetaDataTask
import org.gradle.build.docs.releasenotes.*
import org.gradle.build.docs.releasenotes.checks.*
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'base'
apply plugin: 'pegdown'
apply plugin: 'jsoup'
apply plugin: 'javascript-base'
repositories {
javaScript.googleApis()
ivy {
name "Google Fonts"
url "http://themes.googleusercontent.com/static/fonts/"
layout 'pattern', {
artifact '[organisation]/v[revision](/[classifier])(.[ext])'
ivy '[organisation]/v[revision]/ivy(.[ext])'
}
}
maven { url 'https://repo.gradle.org/gradle/gradle-build-internal' }
}
configurations {
groovydocGroovy {}
userGuideStyleSheets
userGuideTask
jquery
jqueryTipTip
fonts
}
dependencies {
userGuideTask 'xalan:xalan:2.7.1', libraries.xerces
userGuideTask module('xhtmlrenderer:xhtmlrenderer:R8rc1') {
dependency 'itext:itext:2.0.8@jar'
}
userGuideTask 'xslthl:xslthl:2.0.1@jar'
userGuideStyleSheets 'docbook:docbook-xsl:1.75.2@zip'
jquery "jquery:jquery.min:1.8.0@js"
jqueryTipTip "com.drewwilson.code:jquery.tipTip:1.3:minified@js"
fonts \
"lato:regular:6:v0SdcGFAl2aezM9Vq_aFTQ@ttf",
"lato:regular-italic:6:LqowQDslGv4DmUBAfWa2Vw@ttf",
"lato:bold:6:DvlFBScY1r-FMtZSYIYoYw@ttf",
"lato:bold-italic:6:HkF_qI1x_noxlxhrhMQYEKCWcynf_cDxXwCLxiixG1c@ttf",
"ubuntumono:regular:3:ViZhet7Ak-LRXZMXzuAfkZ0EAVxt0G0biEntp43Qt6E@ttf",
"ubuntumono:regular-italic:3:KAKuHXAHZOeECOWAHsRKA-LrC4Du4e_yfTJ8Ol60xk0@ttf",
"ubuntumono:bold:3:ceqTZGKHipo8pJj4molytp_TkvowlIOtbR7ePgFOpF4@ttf",
"ubuntumono:bold-italic:3:n_d8tv_JOIiYyMXR4eaV9WsGzsqhEorxQDpu60nfWEc@ttf"
groovydocGroovy libraries.groovy
testCompile libraries.groovy
testCompile "org.pegdown:pegdown:1.1.0"
testCompile libraries.jsoup
testCompile "org.gebish:geb-spock:0.9.3"
testCompile 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.42.2'
testCompile project(":core")
}
ext {
srcDocsDir = file('src/docs')
userguideSrcDir = new File(srcDocsDir, 'userguide')
dslSrcDir = new File(srcDocsDir, 'dsl')
docsDir = file("$buildDir/docs")
userguideDir = new File(docsDir, 'userguide')
distDocsDir = new File(buildDir, 'distDocs')
samplesDir = file("$buildDir/samples")
docbookSrc = new File(project.buildDir, 'src')
samplesSrcDir = file('src/samples')
}
ext.outputs = [:]
outputs.samples = files(samplesDir) {
builtBy 'samples'
}
outputs.distDocs = files(distDocsDir) {
builtBy 'distDocs'
}
outputs.docs = files(docsDir) {
builtBy 'javadocAll', 'groovydocAll', 'userguide', 'dslHtml', 'releaseNotes'
}
tasks.withType(Docbook2Xhtml) {
dependsOn userguideStyleSheets
classpath = configurations.userGuideTask
stylesheetsDir = userguideStyleSheets.destinationDir
}
tasks.withType(UserGuideTransformTask) {
dependsOn samples, dslDocbook
snippetsDir = samples.snippetsDir
linksFile = dslDocbook.linksFile
websiteUrl = 'http://www.gradle.org'
if (name in ["pdfUserguideDocbook", "userguideFragmentSrc"]) {
// These will only be valid for releases, but that's ok
javadocUrl = "http://www.gradle.org/docs/${->version}/javadoc"
groovydocUrl = "http://www.gradle.org/docs/${->version}/groovydoc"
dsldocUrl = "http://www.gradle.org/docs/${->version}/dsl"
} else {
javadocUrl = '../javadoc'
groovydocUrl = '../groovydoc'
dsldocUrl = '../dsl'
}
}
tasks.withType(AssembleDslDocTask) {
classDocbookDir = dslSrcDir
}
task configureCss << {
def images = fileTree(dir: "src/docs/css/images", include: "*.*").files.collectEntries {
[it.name, it.bytes.encodeBase64().toString()]
}
def fonts = configurations.fonts.resolvedConfiguration.resolvedArtifacts.collectEntries {
def id = it.moduleVersion.id
["${id.group}-${id.name}".toString(), it.file.bytes.encodeBase64().toString()]
}
ext.tokens = images + fonts
css.inputs.property 'tokens', tokens
css.filter ReplaceTokens, tokens: tokens
}
task css(type: Sync, dependsOn: configureCss) {
into "$buildDir/css"
from "src/docs/css"
include "*.css"
}
ext.cssFiles = fileTree(css.destinationDir) {
builtBy css
}
task samples(type: ExtractSnippetsTask) {
source samplesSrcDir
exclude 'userguideOutput/**'
exclude '**/readme.xml'
exclude '**/build/**'
exclude '**/.gradle/**'
// Resources that should not be filtered
exclude 'userguide/tutorial/antLoadfileResources/**'
exclude 'native-binaries/cunit/libs/**'
exclude 'native-binaries/google-test/libs/**'
destDir = samplesDir
snippetsDir = new File(buildDir, 'snippets')
doLast {
copy {
from samplesSrcDir
into samplesDir
include 'userguide/tutorial/antLoadfileResources/**'
include 'native-binaries/cunit/libs/**'
include 'native-binaries/google-test/libs/**'
}
}
}
task userguideStyleSheets(type: Copy) {
File stylesheetsDir = new File(srcDocsDir, 'stylesheets')
into new File(buildDir, 'stylesheets')
from(stylesheetsDir) {
include '*.xsl'
}
from(cssFiles)
from({ zipTree(configurations.userGuideStyleSheets.singleFile) }) {
// Remove the prefix
eachFile { fcd -> fcd.path = fcd.path.replaceFirst('^docbook-xsl-[0-9\\.]+/', '') }
}
}
task samplesDocbook(type: AssembleSamplesDocTask) {
source samplesSrcDir
include '**/readme.xml'
destFile = new File(docbookSrc, 'samplesList.xml')
}
task samplesDocs(type: Docbook2Xhtml) {
source samplesDocbook
destFile = new File(samples.destDir, 'readme.html')
stylesheetName = 'standaloneHtml.xsl'
}
task dslMetaData(type: ExtractDslMetaDataTask) {
source { groovydocAll.source }
destFile = new File(docbookSrc, 'dsl-meta-data.bin')
}
task dslDocbook(type: AssembleDslDocTask, dependsOn: [dslMetaData]) {
inputs.files fileTree(dir: dslSrcDir, includes: ['*.xml'])
sourceFile = new File(dslSrcDir, 'dsl.xml')
classMetaDataFile = dslMetaData.destFile
pluginsMetaDataFile = new File(dslSrcDir, 'plugins.xml')
destFile = new File(docbookSrc, 'dsl.xml')
linksFile = new File(docbookSrc, 'api-links.bin')
}
task dslStandaloneDocbook(type: UserGuideTransformTask, dependsOn: [dslDocbook]) {
sourceFile = dslDocbook.destFile
destFile = new File(docbookSrc, 'dsl-standalone.xml')
dsldocUrl = '.'
}
task defaultImports(type: GenerateDefaultImportsTask, dependsOn: dslMetaData) {
metaDataFile = dslMetaData.destFile
destFile = new File(generatedResourcesDir, "default-imports.txt")
// These are part of the API, but not the DSL
excludePackage 'org.gradle.tooling.**'
excludePackage 'org.gradle.testfixtures.**'
// Tweak the imports due to some inconsistencies introduced before we automated the default-imports generation
excludePackage 'org.gradle.plugins.ide.eclipse.model'
excludePackage 'org.gradle.plugins.ide.idea.model'
excludePackage 'org.gradle.api.tasks.testing.logging'
extraPackage 'org.gradle.util'
// TODO - rename some incubating types to remove collisions and then remove these exclusions
excludePackage 'org.gradle.plugins.binaries.model'
excludePackage 'org.gradle.ide.cdt.model'
}
task dslHtml(type: Docbook2Xhtml) {
source dslStandaloneDocbook
destDir = new File(docsDir, 'dsl')
stylesheetName = 'dslHtml.xsl'
resources = cssFiles + fileTree(dslSrcDir) {
include '*.js'
}
ext.entryPoint = "$destDir/index.html"
}
// This is used in the distribution and for the online version
task userguideDocbook(type: UserGuideTransformTask, dependsOn: [samples, samplesDocbook, defaultImports]) {
destFile = new File(docbookSrc, 'userguide.xml')
}
// This is used for the PDF, where we need absolute links to the javadoc etc.
task pdfUserguideDocbook(type: UserGuideTransformTask, dependsOn: [samples, samplesDocbook, defaultImports]) {
destFile = new File(docbookSrc, 'remoteUserguide.xml')
}
configure([userguideDocbook, pdfUserguideDocbook]) {
// The master userguide.xml pulls these files in via xi:include, making them input
inputs.files fileTree(dir: userguideSrcDir, includes: ['*.xml'])
sourceFile new File(userguideSrcDir, 'userguide.xml')
websiteUrl 'http://www.gradle.org'
}
task userguideHtml(type: Docbook2Xhtml) {
source userguideDocbook
destDir = userguideDir
stylesheetName = 'userGuideHtml.xsl'
resources = fileTree(userguideSrcDir) {
include 'img/*.png'
} + cssFiles
ext.entryPoint = "$destDir/userguide.html"
}
task userguideSingleHtml(type: Docbook2Xhtml) {
source userguideDocbook
destFile = new File(userguideDir, 'userguide_single.html')
stylesheetName = 'userGuideSingleHtml.xsl'
resources = fileTree(userguideSrcDir) {
include 'img/*.png'
} + cssFiles
ext.entryPoint = destFile
}
task pdfUserguideXhtml(type: Docbook2Xhtml) {
source pdfUserguideDocbook
destFile = new File(buildDir, 'tmp/userguidePdf/userguidePdf.html')
stylesheetName = 'userGuidePdf.xsl'
resources = fileTree(userguideSrcDir) {
include 'img/*.png'
} + cssFiles
ext.entryPoint = destFile
}
task userguidePdf(type: Xhtml2Pdf, dependsOn: pdfUserguideXhtml) {
inputs.files fileTree(userguideSrcDir) {
include 'img/*.png'
} + cssFiles
sourceFile = pdfUserguideXhtml.destFile
destFile = new File(userguideDir, 'userguide.pdf')
classpath = configurations.userGuideTask
}
def javaApiUrl = "https://docs.oracle.com/javase/6/docs/api"
def groovyApiUrl = "http://docs.groovy-lang.org/docs/groovy-${versions.groovy}/html/gapi"
task javadocAll(type: Javadoc) {
ext.stylesheetFile = file("src/docs/css/javadoc.css")
inputs.file stylesheetFile
group = 'documentation'
options.encoding = 'utf-8'
options.docEncoding = 'utf-8'
options.charSet = 'utf-8'
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption 'Xdoclint:none', '-quiet'
}
options.addStringOption "stylesheetfile", stylesheetFile.absolutePath
source publicGroovyProjects.collect {project -> project.sourceSets.main.allJava }
destinationDir = new File(docsDir, 'javadoc')
classpath = files(publicGroovyProjects.collect {project -> [project.sourceSets.main.compileClasspath, project.sourceSets.main.output] })
include 'org/gradle/*'
include 'org/gradle/api/**'
include 'org/gradle/buildinit/**'
include 'org/gradle/external/javadoc/**'
include 'org/gradle/ide/**'
include 'org/gradle/ivy/**'
include 'org/gradle/jvm/**'
include 'org/gradle/language/**'
include 'org/gradle/maven/**'
include 'org/gradle/nativeplatform/**'
include 'org/gradle/platform/**'
include 'org/gradle/play/**'
include 'org/gradle/plugin/use/*'
include 'org/gradle/plugins/**'
include 'org/gradle/process/**'
include 'org/gradle/testfixtures/**'
include 'org/gradle/testing/jacoco/**'
include 'org/gradle/sonar/runner/**'
include 'org/gradle/tooling/**'
include 'org/gradle/model/**'
include 'org/gradle/testkit/functional/*'
exclude '**/internal/**'
options.links(javaApiUrl, groovyApiUrl, "http://maven.apache.org/ref/2.2.1/maven-core/apidocs",
"http://maven.apache.org/ref/2.2.1/maven-model/apidocs")
doFirst {
title = "Gradle API $version"
}
ext.entryPoint = "$destinationDir/index.html"
}
task configureGroovydocAll {
doFirst {
project.configure(groovydocAll) {
[javaApiUrl].each {
// [javaApiUrl, groovyApiUrl].each {
link(it, *(new URL("$it/package-list").text.tokenize("\n")))
}
docTitle = "Gradle API $version"
windowTitle = "Gradle API $version"
footer = "Gradle API $version"
}
}
}
task groovydocAll(type: Groovydoc, dependsOn: configureGroovydocAll) {
group = 'documentation'
source publicGroovyProjects.collect {project -> project.sourceSets.main.groovy + project.sourceSets.main.java }
destinationDir = new File(docsDir, 'groovydoc')
// Groovydoc runs static initializers, and at least ProjectBuilder's initializers depend on runtime classes
// http://jira.codehaus.org/browse/GROOVY-7096
classpath = files(publicGroovyProjects.collect {project -> [project.sourceSets.main.runtimeClasspath, project.sourceSets.main.output] })
includes = javadocAll.includes
excludes = javadocAll.excludes
doFirst {
windowTitle = "Gradle API $version"
docTitle = windowTitle
}
groovyClasspath = configurations.groovydocGroovy
doLast {
def index = new File(destinationDir, "index.html")
index.text = index.text.replace("{todo.title}", windowTitle) // workaround groovydoc bug
}
ext.entryPoint = "$destinationDir/index.html"
}
task checkstyleApi(type: Checkstyle) {
source javadocAll.source
configFile = file("$checkstyleConfigDir/checkstyle-api.xml")
classpath = files()
reports.xml.destination = file("$checkstyle.reportsDir/checkstyle-api.xml")
}
task userguideFragmentSrc(type: UserGuideTransformTask, dependsOn: [userguideStyleSheets]) {
tags << 'standalone'
sourceFile = new File(userguideSrcDir, 'installation.xml')
destFile = new File(docbookSrc, 'installation.xml')
}
task distDocs(type: Docbook2Xhtml) {
source userguideFragmentSrc
destFile = new File(distDocsDir, 'getting-started.html')
stylesheetName = 'standaloneHtml.xsl'
}
task userguide {
dependsOn userguideHtml, userguideSingleHtml, userguidePdf
description = 'Generates the userguide'
group = 'documentation'
}
import org.gradle.plugins.pegdown.PegDown
task editReleaseNotes() {
group = "release notes"
doLast {
Class.forName("java.awt.Desktop").newInstance().edit(file("src/docs/release/notes.md"))
}
}
task releaseNotesMarkdown(type: PegDown) {
group = "release notes"
source "src/docs/release/notes.md"
destination "$buildDir/release-notes-raw/release-notes.html"
}
task releaseNotes(type: Copy) {
group = "release notes"
ext.fileName = "release-notes.html"
into "$docsDir"
from releaseNotesMarkdown
jsoup.plugins "src/transforms/release-notes.gradle"
filter(ReplaceTokens, tokens: [version: project.version.toString(), versionBase: rootProject.versionBase])
ext.entryPoint = file("$docsDir/$fileName")
}
tasks.addRule("view«Doc Task Name» - Opens entry point") { String taskName ->
if (taskName.startsWith("view")) {
def realTaskName = (taskName - "view")
realTaskName = realTaskName[0].toLowerCase() + realTaskName[1..-1]
def task = tasks.findByName(realTaskName)
if (task && task.hasProperty("entryPoint")) {
tasks.create(taskName) {
dependsOn task
doLast {
Class.forName("java.awt.Desktop").newInstance().browse(file(task.entryPoint).toURI())
}
}
}
}
}
sourceSets.main.output.dir generatedResourcesDir, builtBy: defaultImports
test {
dependsOn releaseNotes
systemProperty "org.gradle.docs.releasenotes.source", releaseNotesMarkdown.source.singleFile
systemProperty "org.gradle.docs.releasenotes.rendered", new File(releaseNotes.destinationDir, releaseNotes.fileName)
}
task docs {
dependsOn javadocAll, groovydocAll, userguide, distDocs, samplesDocs, dslHtml, releaseNotes
description = 'Generates all documentation'
group = 'documentation'
}
task docsZip(type: Zip) {
from project.outputs.docs
}
class Xhtml2Pdf extends DefaultTask {
@InputFile
File sourceFile
@OutputFile
File destFile
@InputFiles
FileCollection classpath
@TaskAction
def transform() {
def uris = classpath.files.collect {it.toURI().toURL()}
def classloader = new URLClassLoader(uris as URL[], getClass().classLoader)
def renderer = classloader.loadClass('org.xhtmlrenderer.pdf.ITextRenderer').newInstance()
renderer.setDocument(sourceFile)
renderer.layout()
destFile.withOutputStream {
renderer.createPDF(it)
}
}
}
Jump to Line
Something went wrong with that request. Please try again.