blob: d88d9e9ab785c5860911737e7391f1f76bb94bf7 [file] [log] [blame]
/*
* 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.apache.tools.ant.filters.ReplaceTokens
import org.gradle.build.docs.AssembleSamplesDocTask
import org.gradle.build.docs.Docbook2Xhtml
import org.gradle.build.docs.UserGuideTransformTask
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.*
evaluationDependsOn(':base:gradle-api')
evaluationDependsOn(':base:gradle-core')
evaluationDependsOn(':base:builder')
apply plugin: 'groovy'
apply plugin: 'base'
apply plugin: 'pegdown'
apply plugin: 'jsoup'
apply plugin: 'javascript-base'
def generatedResourcesDir = file("$buildDir/generated-resources/main")
version = rootProject.buildVersion
repositories {
maven { url 'https://repo.gradle.org/gradle/libs' }
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
fonts
}
dependencies {
userGuideTask 'xalan:xalan:2.7.1', 'org.codehaus.groovy:groovy-all:2.3.6'
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'
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",
"roboto:regular:14:zN7GBFwfMP4uA6AR0HCoLQ@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 'org.codehaus.groovy:groovy-all:2.3.6'
}
ext {
srcDocsDir = file('src/fromGradle/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')
docbookSrc = new File(project.buildDir, 'src')
}
tasks.withType(Docbook2Xhtml) {
dependsOn userguideStyleSheets
classpath = configurations.userGuideTask
stylesheetsDir = userguideStyleSheets.destinationDir
}
tasks.withType(UserGuideTransformTask) {
dependsOn dslDocbook
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').doLast {
def images = fileTree(dir: "$srcDocsDir/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 "$srcDocsDir/css"
include "*.css"
}
ext.cssFiles = fileTree(css.destinationDir) {
builtBy css
}
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 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
snippetsDir = buildDir
destFile = new File(docbookSrc, 'dsl-standalone.xml')
dsldocUrl = '.'
}
task dslHtml(type: Docbook2Xhtml) {
source dslStandaloneDocbook
destDir = new File(docsDir, 'dsl')
stylesheetName = 'dslHtml.xsl'
resources = cssFiles + fileTree(dslSrcDir) {
include '*.js'
}
}
task dslHtmlZip(type: Zip) {
dependsOn dslHtml
from dslHtml.destDir
destinationDir docsDir
baseName 'gradle-dsl'
}
def javaApiUrl = "http://docs.oracle.com/javase/8/docs/api/"
def groovyApiUrl = "http://groovy.codehaus.org/gapi/"
def publicGroovyProjects = [
project(":base:gradle-api"),
project(":base:gradle-core"),
project(":base:builder-model"),
project(":base:builder")
]
task groovydocAll(type: Groovydoc) {
// This task is never run (and it currently fails for some reason). We use it calculate the
// inputs to dslMetadata.
enabled = false
group = 'documentation'
source publicGroovyProjects.collect {project ->
def main = project.sourceSets.main
try {
main.groovy + main.java
} catch (MissingPropertyException e) {
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] })
include 'com/android/builder/model/*.java'
include 'com/android/build/gradle/*Extension.java'
include 'com/android/build/gradle/AndroidConfig.java'
include 'com/android/build/gradle/internal/CompileOptions.java'
include 'com/android/build/gradle/internal/coverage/JacocoOptions.java'
include 'com/android/build/gradle/api/AndroidSource*.java'
include 'com/android/build/gradle/api/VariantFilter.java'
include 'com/android/build/gradle/api/*Variant.java'
include 'com/android/build/gradle/internal/dsl/**'
include 'com/android/builder/core/Default*.java'
include 'com/android/builder/internal/BaseConfigImpl.java'
include 'com/android/builder/signing/DefaultSigningConfig.java'
include 'com/android/build/api/variant/VariantFilter.java'
exclude 'com/android/build/gradle/shrinker/parser/ProguardLexer*'
exclude 'com/android/builder/core/DefaultManifestParser.java'
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
}
}
// Make sure all the references are valid and up-to-date. Hopefully this will mark the build
// red in Jenkins if they get out of sync.
check.dependsOn dslHtmlZip