From 2bab8f3c0b27a7aca9372c0a4183f9b700a602a0 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Mon, 16 Jan 2012 22:28:06 +0100 Subject: [PATCH] Generate -docs, -schema and -dist zips - Add 'api' gradle task to generate project-wide API Javadoc results in /build/api - Add docsZip task including api and reference documentation suitable for publication to http://static.springframework.org/docs/spring-framework - Add schemaZip task including all spring-* XSD files suitable for publication to http://static.springframework.org/schema - Add distZip task to include all libs, docs and schema - filter src/dist/*.txt for ${copyright} and ${version} - copy legal (notice, license) dynamically into individual jar files - copy legal and readme files into root of distribution zip - Refactor location of 'wrapper' task Each of the zip tasks (docsZip, schemaZip, distZip) have been added to the 'archives' configuration, meaning that (a) they will be built automatically with `gradle build` and (b) will be published automatically to artifactory when using the Artifactory Gradle plugin and/or Artifactory Bamboo integration. --- build.gradle | 166 +++++++++++++++++++++++++++++++++--------- src/api/overview.html | 5 ++ 2 files changed, 135 insertions(+), 36 deletions(-) create mode 100644 src/api/overview.html diff --git a/build.gradle b/build.gradle index cc243638a6..eb19b31b84 100644 --- a/build.gradle +++ b/build.gradle @@ -41,26 +41,6 @@ configure(allprojects) { } } -configure(rootProject) { - description = 'Spring Framework' - - apply plugin: 'docbook-reference' - - reference { - sourceDir = file('src/reference/docbook') - } - - // don't publish the default jar for the root project - configurations.archives.artifacts.clear() - - dependencies { // for integration tests - testCompile project(":spring-test") - testCompile project(":spring-webmvc-portlet") - testCompile "org.hibernate:hibernate-core:4.0.0.CR7" - testCompile "javax.servlet:servlet-api:2.5" - } -} - configure(subprojects) { apply plugin: 'maven' group = 'org.springframework' @@ -403,26 +383,140 @@ project('spring-aspects') { } } -task apidocs(type: Javadoc) { - subprojects.each { project -> - source project.sourceSets.main.allJava +configure(rootProject) { + description = 'Spring Framework' + + apply plugin: 'docbook-reference' + + reference { + sourceDir = file('src/reference/docbook') } - subprojects.each { subproject -> - if(classpath) { - classpath += subproject.sourceSets.main.classes + subproject.sourceSets.main.compileClasspath + + // don't publish the default jar for the root project + configurations.archives.artifacts.clear() + + dependencies { // for integration tests + testCompile project(":spring-test") + testCompile project(":spring-webmvc-portlet") + testCompile "org.hibernate:hibernate-core:4.0.0.CR7" + testCompile "javax.servlet:servlet-api:2.5" + } + + task api(type: Javadoc) { + group = 'Documentation' + description = 'Generates aggregated Javadoc API documentation.' + title = "${rootProject.description} ${version} API" + options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED + options.author = true + options.header = rootProject.description + options.overview = 'src/api/overview.html' + options.links( + 'http://docs.jboss.org/jbossas/javadoc/4.0.5/connector' + ) + source subprojects.collect { project -> + project.sourceSets.main.allJava + } + destinationDir = new File(buildDir, "api") + classpath = files(subprojects.collect { project -> + project.sourceSets.main.compileClasspath + }) + maxMemory = '1024m' + } + + task docsZip(type: Zip) { + group = 'Distribution' + classifier = 'docs' + description = "Builds -${classifier} archive containing api and reference " + + "for deployment at static.springframework.org/spring-framework/docs." + + from('src/dist') { + include 'changelog.txt' + } + + from (api) { + into 'api' + } + + from (reference) { + into 'reference' } - else { - classpath = subproject.sourceSets.main.classes + subproject.sourceSets.main.compileClasspath + } + + task schemaZip(type: Zip) { + group = 'Distribution' + classifier = 'schema' + description = "Builds -${classifier} archive containing all " + + "XSDs for deployment at static.springframework.org/schema." + + subprojects.each { subproject -> + def Properties schemas = new Properties(); + + subproject.sourceSets.main.resources.find { + it.path.endsWith('META-INF/spring.schemas') + }?.withInputStream { schemas.load(it) } + + for (def key : schemas.keySet()) { + def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1') + assert shortName != key + File xsdFile = subproject.sourceSets.main.resources.find { + it.path.endsWith(schemas.get(key)) + } + assert xsdFile != null + into (shortName) { + from xsdFile.path + } + } } } - destinationDir = file('build/docs/javadoc') - maxMemory = '1024m' -} -task wrapper(type: Wrapper) { - description = 'Generates gradlew[.bat] scripts' - gradleVersion = '1.0-milestone-8' - distributionUrl = 'http://repo.gradle.org/gradle/distributions-snapshots/gradle-1.0-milestone-8-20120112000036+0100-bin.zip' - jarFile = '.wrapper/gradle-wrapper.jar' + task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) { + group = 'Distribution' + classifier = 'dist' + description = "Builds -${classifier} archive, containing all jars and docs, " + + "suitable for community download page." + + baseDir = "${project.name}-${project.version}"; + + from('src/dist') { + include 'readme.txt' + include 'license.txt' + include 'notice.txt' + into "${baseDir}" + expand(copyright: new Date().format('yyyy'), version: project.version) + } + + from(zipTree(docsZip.archivePath)) { + into "${baseDir}/docs" + } + + from(zipTree(schemaZip.archivePath)) { + into "${baseDir}/schema" + } + + subprojects.each { subproject -> + into ("${baseDir}/libs") { + from subproject.jar + if (subproject.tasks.findByPath('sourcesJar')) { + from subproject.sourcesJar + } + if (subproject.tasks.findByPath('javadocJar')) { + from subproject.javadocJar + } + } + } + } + + artifacts { + archives docsZip + archives schemaZip + archives distZip + } + + task wrapper(type: Wrapper) { + description = 'Generates gradlew[.bat] scripts' + gradleVersion = '1.0-milestone-8' + distributionUrl = 'http://repo.gradle.org/gradle/distributions-snapshots/gradle-1.0-milestone-8-20120112000036+0100-bin.zip' + jarFile = '.wrapper/gradle-wrapper.jar' + } } diff --git a/src/api/overview.html b/src/api/overview.html new file mode 100644 index 0000000000..41c4086d0d --- /dev/null +++ b/src/api/overview.html @@ -0,0 +1,5 @@ + + + This is the public API documentation for the Spring Framework. + +