adding basic gradle config

This commit is contained in:
Mark Fisher
2010-10-25 19:18:49 -04:00
parent 1fc8980869
commit 8025f72d00
14 changed files with 1403 additions and 0 deletions

214
build.gradle Normal file
View File

@@ -0,0 +1,214 @@
/*
* Copyright 2002-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.
*/
// -----------------------------------------------------------------------------
// Main gradle build file for Spring Integration
//
// - run `./gradlew(.bat) build` to kick off a complete compile-test-package
//
// - the imports above are from groovy and/or java classes in buildSrc/
// or from jars on 'buildscript' classpath (in our case, it's all buildSrc)
// sources in buildSrc are compiled and placed on the classpath automatically
//
// @author cbeams
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Configuration for all projects including this one (the root project)
//
// @see settings.gradle for list of all subprojects
// -----------------------------------------------------------------------------
apply from: "$rootDir/gradle/version.gradle"
apply plugin: 'idea'
allprojects {
// group will translate to groupId during pom generation and deployment
group = 'org.springframework.integration'
// version will be used in maven pom generation as well as determining
// where artifacts should be deployed, based on release type of snapshot,
// milestone or release.
// @see org.springframework.build.Version under buildSrc/ for more info
// @see gradle.properties for the declaration of this property.
version = createVersion(springIntegrationVersion)
// default set of maven repositories to be used when resolving dependencies
repositories {
mavenRepo urls: 'http://maven.springframework.org/snapshot'
mavenCentral()
mavenRepo urls: 'http://maven.springframework.org/release'
mavenRepo urls: 'http://maven.springframework.org/milestone'
mavenRepo urls: 'http://repository.springsource.com/maven/bundles/external'
mavenRepo urls: 'http://repository.springsource.com/maven/bundles/release'
mavenRepo urls: 'http://repository.springsource.com/maven/bundles/milestone'
}
}
// -----------------------------------------------------------------------------
// Create collections of subprojects - each will receive their own configuration
// - all subprojects that start with spring-integration-* are 'java projects'
// - documentation-related subprojects are not collected here
//
// @see configure(*) sections below
// -----------------------------------------------------------------------------
javaprojects = subprojects.findAll { project ->
project.path.startsWith(':spring-integration-')
}
// -----------------------------------------------------------------------------
// Configuration for all java subprojects
// -----------------------------------------------------------------------------
configure(javaprojects) {
apply plugin: 'java' // tasks for conventional java lifecycle
apply plugin: 'maven' // `gradle install` to push jars to local .m2 cache
apply plugin: 'eclipse' // `gradle eclipse` to generate .classpath/.project
apply plugin: 'idea' // `gradle idea` to generate .ipr/.iml
// all core projects should be OSGi-compliant bundles
// add the bundlor task to ensure proper manifests
apply from: "$rootDir/gradle/bundlor.gradle"
apply from: "$rootDir/gradle/maven-deployment.gradle"
springVersion = '3.0.5.RELEASE'
// dependencies that are common across all java projects
dependencies {
testCompile 'junit:junit:4.7'
testCompile "log4j:log4j:1.2.12"
}
// enable all compiler warnings (GRADLE-1077)
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all']
// generate .classpath files without GRADLE_CACHE variable (GRADLE-1079)
eclipseClasspath.variables = [:]
}
// -----------------------------------------------------------------------------
// Configuration for each individual core java subproject
//
// @see configure(javaprojects) above for general config
// -----------------------------------------------------------------------------
project('spring-integration-core') {
description = 'Spring Integration Core'
dependencies {
compile "org.codehaus.jackson:jackson-mapper-asl:1.4.3"
compile "org.springframework:spring-aop:3.0.5.RELEASE"
compile "org.springframework:spring-context:3.0.5.RELEASE"
compile "org.springframework:spring-tx:3.0.5.RELEASE"
testCompile "org.hamcrest:hamcrest-all:1.1"
testCompile "org.easymock:easymock:2.3"
testCompile "org.mockito:mockito-all:1.8.4"
testCompile "org.springframework:spring-test:3.0.5.RELEASE"
testCompile "org.aspectj:aspectjrt:1.6.5"
testCompile "org.aspectj:aspectjweaver:1.6.5"
testCompile "cglib:cglib-nodep:2.2"
}
}
/*
project('spring-integration-event') {
}
project('spring-integration-feed') {
}
project('spring-integration-file') {
}
project('spring-integration-ftp') {
}
project('spring-integration-groovy') {
}
project('spring-integration-http') {
}
project('spring-integration-httpinvoker') {
}
project('spring-integration-ip') {
}
project('spring-integration-jdbc') {
}
project('spring-integration-jms') {
}
project('spring-integration-jmx') {
}
project('spring-integration-mail') {
}
project('spring-integration-rmi') {
}
project('spring-integration-security') {
}
project('spring-integration-sftp') {
}
project('spring-integration-stream') {
}
project('spring-integration-test') {
}
project('spring-integration-twitter') {
}
project('spring-integration-ws') {
}
project('spring-integration-xml') {
}
project('spring-integration-xmpp') {
}
*/
// add basic tasks like 'clean' and 'assemble' to the root project. e.g.: allows
// running `gradle clean` from the root project and deleting the build directory
apply plugin: 'base'
// add tasks like 'distArchive'
//apply from: "$rootDir/gradle/dist.gradle"
// add tasks like 'snapshotDependencyCheck'
apply from: "${rootDir}/gradle/checks.gradle"
// -----------------------------------------------------------------------------
// Import tasks related to releasing and managing the project
// depending on the role played by the current user.
//
// @see gradle.properties for more information on roles
// -----------------------------------------------------------------------------
// add management tasks like `wrapper` for generating the gradlew* scripts
apply from: "$rootDir/gradle/wrapper.gradle"

43
gradle.properties Normal file
View File

@@ -0,0 +1,43 @@
# Copyright 2002-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.
# ------------------------------------------------------------------------------
# version to be applied to all projects in this multi-project build. this is
# the one and only location version changes need to be made.
# ------------------------------------------------------------------------------
springIntegrationVersion=2.0.0.BUILD-SNAPSHOT
# ------------------------------------------------------------------------------
# build system user roles
# role may be either 'developer' or 'buildmaster'
# ------------------------------------------------------------------------------
role=developer
# ------------------------------------------------------------------------------
# for buildmasters: create a $HOME/.gradle/gradle.properties with the following
# properties. They'll be necessary uploading artifacts to s3, maven repos, and
# static.springframework.org. By placing them in your home directory, there's
# no need to change/check in this file. Remember that properties can also be
# specified at the gradle command line with -P, e.g.: -Prole=buildmaster
# ------------------------------------------------------------------------------
# role = buildmaster # overrides default 'role = developer' above
# s3AccessKey=<springsource s3 access key>
# s3SecretAccessKey=<springsource s3 secret access key>
# docsHost=static.springsource.org
# sshHost=static.springsource.org
# sshUsername=<your user id>
# sshPrivateKey=<path to your ssh private key used for logging into sshHost
# remoteSiteDir=/var/www/domains/springframework.org/static/htdocs/<project>
# mavenSyncRepoDir=<path to sourceforge cvs checkout for maven central sync>

91
gradle/bundlor.gradle Normal file
View File

@@ -0,0 +1,91 @@
/*
* Copyright 2002-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.
*/
// -----------------------------------------------------------------------------
// Task definitions and configuration relating to the SpringSource 'bundlor'
// OSGi manifest generation utility.
//
// @author cbeams
// see: http://www.springsource.org/bundlor
// -----------------------------------------------------------------------------
/**
* Generate an OSGi manifest using the ant bundlor task.
*
* @author ltaylor
* @author cbeams
* @see http://static.springsource.org/s2-bundlor/1.0.x/user-guide/html/ch04s02.html
*/
task bundlor(dependsOn: compileJava) {
description = 'Generates an OSGi-compatibile MANIFEST.MF file.'
def template = new File(projectDir, 'template.mf')
def bundlorDir = new File("${project.buildDir}/bundlor")
def manifest = file("${bundlorDir}/META-INF/MANIFEST.MF")
// inform gradle what directory this task writes so that
// it can be removed when issuing `gradle cleanBundlor`
outputs.dir bundlorDir
// incremental build configuration
// if the $manifest output file already exists, the bundlor
// task will be skipped *unless* any of the following are true
// * template.mf has been changed
// * main classpath dependencies have been changed
// * main java sources for this project have been modified
outputs.files manifest
inputs.files template, project.sourceSets.main.runtimeClasspath
// tell the jar task to use bundlor manifest instead of the default
jar.manifest.from manifest
// the bundlor manifest should be evaluated as part of the jar task's
// incremental build
jar.inputs.files manifest
// configuration that will be used when creating the ant taskdef classpath
configurations { bundlorconf }
dependencies {
bundlorconf 'com.springsource.bundlor:com.springsource.bundlor.ant:1.0.0.RELEASE',
'com.springsource.bundlor:com.springsource.bundlor:1.0.0.RELEASE',
'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RELEASE'
}
doFirst {
ant.taskdef(resource: 'com/springsource/bundlor/ant/antlib.xml',
classpath: configurations.bundlorconf.asPath)
// the bundlor ant task writes directly to standard out
// redirect it to INFO level logging, which gradle will
// deal with gracefully
logging.captureStandardOutput(LogLevel.INFO)
// the ant task will throw unless this dir exists
if (!bundlorDir.isDirectory())
bundlorDir.mkdir()
// execute the ant task, and write out the $manifest file
ant.bundlor(inputPath: sourceSets.main.classesDir,
outputPath: bundlorDir, manifestTemplatePath: template) {
property(name: 'version', value: project.version)
property(name: 'spring.version', value: project.springVersion)
}
}
}
// ensure that the bundlor task runs prior to the jar task
jar.dependsOn bundlor

90
gradle/checks.gradle Normal file
View File

@@ -0,0 +1,90 @@
/*
* Copyright 2002-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.
*/
/**
* Issue a snapshot dependency report across all Java projects. Detects not
* only direct snapshot dependencies, but transitive as well.
*
* @author cbeams
* @see snapshotDependencyCheck
*/
task snapshotDependencyReport {
description = 'Issues a snapshot dependency report across all Java projects'
doFirst() {
def snapshotDependencies = new HashMap<Project, List<Dependency>>()
javaprojects.each { project ->
project.sourceSets.main.compileClasspath.allDependencies.each { dep ->
if (dep.version.endsWith('SNAPSHOT')) {
if (snapshotDependencies[project] == null)
snapshotDependencies[project] = new ArrayList<Dependency>()
snapshotDependencies[project].add(dep)
}
}
}
project.hasSnapshotDependencies = snapshotDependencies.size() > 0
if (project.hasSnapshotDependencies) {
println "The following snapshot dependencies were found:"
snapshotDependencies.each { entry ->
println "${entry.key} depends on:"
entry.value.each { dep ->
println " ${dep}"
}
}
}
}
}
/**
* Abort the build if any Java projects have snapshot dependencies. It important
* that any non-snapshot release be checked for snapshot dependencies before
* final publication, as snapshot dependencies may change and thus make the
* release unstable and/or unreproducable.
*
* This task will be added to the build lifecycle automatically if the release
* is non-snapshot.
*
* -PignoreSnapshotDependencies will bypass aborting the build. A use case for
* this option would be if a transitive dependency out of your control is a
* snapshot release and you wish to proceed with releasing anyway.
*
* @author cbeams
* @see snapshotDependencyReport
*/
task snapshotDependencyCheck(dependsOn: snapshotDependencyReport) {
group = 'Verification'
description = 'Aborts the build if any Java project has snapshot dependencies.'
// bind to build lifecycle if we're a non-snapshot release
if (version.releaseType != 'SNAPSHOT') {
check.dependsOn snapshotDependencyCheck
}
onlyIf {
project.hasSnapshotDependencies &&
!project.hasProperty('ignoreSnapshotDependencies')
}
doFirst {
throw new GradleException(
"aborting '${name}' task due to snapshot dependencies. "
+ "supply -PignoreSnapshotDependencies to override")
}
}

133
gradle/dist.gradle Normal file
View File

@@ -0,0 +1,133 @@
/*
* Copyright 2002-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.
*/
// -----------------------------------------------------------------------------
// Task definitions related to releasing the project
//
// @author cbeams
// -----------------------------------------------------------------------------
// ensure that every project has been evaluated before this script
// this allows us to look up tasks below and dereference dynamically
// assigned properties like 'docsSpec' below
project.subprojects.each { project ->
evaluationDependsOn project.path
}
task check {
group = 'Verification'
}
task build(dependsOn: [check, assemble]) {
group = 'Build'
}
/**
* Build the distribution zip file.
*
* @author cbeams
*/
task distArchive(type: Zip) {
group = 'Build'
destinationDir = buildDir
archiveName = "${project.name}-${project.version}.zip"
checksumPath = "${destinationDir}/${archiveName}.sha1"
def zipRootDir = "${project.name}-${project.version}"
description = "Builds the distribution zip file at ${project.relativePath(destinationDir)}/${archiveName}"
// depend on all projects with an assemble task
dependsOn subprojects*.tasks*.matching { task -> task.name == 'assemble' }
// we need the docsSpec to be defined before evaluating this task
project.evaluationDependsOn(':docs')
// set up outputs for use by incremental build and by tasks like 'cleanDist'
// the archive zip file will be added automatically to outputs.files
// but we must add the sha1 checksum ourselves
outputs.files file(checksumPath)
// configure the contents of the zip file. remember that this is a
// configuration phase event. no zip is being created yet. the Zip
// task we extend will do that for us during the execution phase.
into(zipRootDir) {
with(project(':docs').docsSpec)
// add each subproject, but only add the 'src' dir and 'pom.xml'
project('spring-amqp-samples').subprojects.each { sample ->
into("${zipRootDir}/samples/${sample.name}") {
from(sample.projectDir) {
include 'src/**/*'
include 'pom.xml'
}
}
}
// add all jars and source jars from all core java projects
// (i.e.: don't include sample project jars!)
into('dist') {
from coreprojects.collect { project -> project.libsDir }
}
}
// once the zip has been written, create a sha1 hash for it
// this will write out the file at ${checksumPath}
doLast {
ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
assert file(checksumPath).isFile(): "${checksumPath} was not created"
}
}
/**
* Upload the distribution zip file.
*
* @author ltaylor
* @author cbeams
*/
task uploadArchives(overwrite: true, dependsOn: distArchive) { // base plugin adds one we need to overwrite
group = 'Buildmaster'
description = 'Uploads the distribution zip file.'
configurations { antlibs }
dependencies {
antlibs "org.springframework.build:org.springframework.build.aws.ant:3.0.3.RELEASE",
"net.java.dev.jets3t:jets3t:0.6.1"
}
def releaseType = version.releaseType.toString().toLowerCase()
doLast() {
println "Uploading: ${distArchive.archivePath} to s3"
project.ant {
taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml',
classpath: configurations.antlibs.asPath)
s3(accessKey: s3AccessKey, secretKey: s3SecretAccessKey) {
upload(bucketName: 'dist.springframework.org', file: distArchive.archivePath,
toFile: releaseType + "/AMQP/${distArchive.archiveName}", publicRead: 'true') {
metadata(name: 'project.name', value: 'Spring AMQP')
metadata(name: 'release.type', value: releaseType)
metadata(name: 'bundle.version', value: version)
metadata(name: 'package.file.name', value: distArchive.archiveName)
}
upload(bucketName: 'dist.springframework.org', file: "${distArchive.archivePath}.sha1",
toFile: releaseType + "/AMQP/${distArchive.archiveName}.sha1", publicRead: 'true')
}
}
}
}

315
gradle/docbook.gradle Normal file
View File

@@ -0,0 +1,315 @@
/*
* Copyright 2002-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.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.apache.xml.resolver.CatalogManager;
import org.apache.xml.resolver.tools.CatalogResolver;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.*;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.util.zip.*;
import org.apache.fop.apps.*;
import org.gradle.api.logging.LogLevel;
import com.icl.saxon.TransformerFactoryImpl;
import ch.qos.logback.classic.Level;
import org.slf4j.LoggerFactory;
buildscript {
repositories {
mavenCentral()
mavenRepo name: 'Shibboleth Repo', urls: 'http://shibboleth.internet2.edu/downloads/maven2'
}
dependencies {
def fopDeps = ['org.apache.xmlgraphics:fop:0.95-1@jar',
'org.apache.xmlgraphics:xmlgraphics-commons:1.3',
'org.apache.xmlgraphics:batik-bridge:1.7@jar',
'org.apache.xmlgraphics:batik-util:1.7@jar',
'org.apache.xmlgraphics:batik-css:1.7@jar',
'org.apache.xmlgraphics:batik-dom:1.7',
'org.apache.xmlgraphics:batik-svg-dom:1.7@jar',
'org.apache.avalon.framework:avalon-framework-api:4.3.1']
classpath 'org.apache.xerces:resolver:2.9.1',
'saxon:saxon:6.5.3',
'org.apache.xerces:xercesImpl:2.9.1',
fopDeps,
'net.sf.xslthl:xslthl:2.0.1',
'net.sf.docbook:docbook-xsl:1.75.2:resources@zip'
}
}
/**
* Gradle Docbook plugin implementation.
* <p>
* Creates three tasks: docbookHtml, docbookHtmlSingle and docbookPdf.
* Each task takes a single File on which it operates.
*
* @author ltaylor
*/
// Add the plugin tasks to the project
task docbookHtml(type: DocbookHtml) {
setDescription('Generates chunked docbook html output.')
xdir = 'html'
classpath = buildscript.configurations.classpath
}
task docbookHtmlSingle(type: Docbook) {
setDescription('Generates single page docbook html output.')
xdir = 'htmlsingle'
classpath = buildscript.configurations.classpath
}
task docbookPdf(type: DocbookFoPdf) {
setDescription('Generates PDF docbook output.')
extension = 'fo'
xdir = 'pdf'
classpath = buildscript.configurations.classpath
}
/**
*/
public class Docbook extends DefaultTask {
@Input
String extension = 'html';
@Input
boolean XIncludeAware = true;
@Input
boolean highlightingEnabled = true;
String admonGraphicsPath;
@InputDirectory
File sourceDirectory = new File(project.getProjectDir(), "build/reference-work");
@Input
String sourceFileName;
@InputFile
File stylesheet;
@OutputDirectory
File docsDir = new File(project.getBuildDir(), "reference");
@InputFiles
Configuration classpath
@TaskAction
public final void transform() {
// the docbook tasks issue spurious content to the console. redirect to INFO level
// so it doesn't show up in the default log level of LIFECYCLE unless the user has
// run gradle with '-d' or '-i' switches -- in that case show them everything
switch (project.gradle.startParameter.logLevel) {
case LogLevel.DEBUG:
case LogLevel.INFO:
break;
default:
logging.captureStandardOutput(LogLevel.INFO)
logging.captureStandardError(LogLevel.INFO)
}
SAXParserFactory factory = new org.apache.xerces.jaxp.SAXParserFactoryImpl();
factory.setXIncludeAware(XIncludeAware);
docsDir.mkdirs();
File srcFile = new File(sourceDirectory, sourceFileName);
String outputFilename = srcFile.getName().substring(0, srcFile.getName().length() - 4) + '.' + extension;
File oDir = new File(getDocsDir(), xdir)
File outputFile = new File(oDir, outputFilename);
Result result = new StreamResult(outputFile.getAbsolutePath());
CatalogResolver resolver = new CatalogResolver(createCatalogManager());
InputSource inputSource = new InputSource(srcFile.getAbsolutePath());
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.setEntityResolver(resolver);
TransformerFactory transformerFactory = new TransformerFactoryImpl();
transformerFactory.setURIResolver(resolver);
URL url = stylesheet.toURL();
Source source = new StreamSource(url.openStream(), url.toExternalForm());
Transformer transformer = transformerFactory.newTransformer(source);
if (highlightingEnabled) {
File highlightingDir = new File(getProject().getBuildDir(), "highlighting");
if (!highlightingDir.exists()) {
highlightingDir.mkdirs();
extractHighlightFiles(highlightingDir);
}
transformer.setParameter("highlight.xslthl.config", new File(highlightingDir, "xslthl-config.xml").toURI().toURL());
if (admonGraphicsPath != null) {
transformer.setParameter("admon.graphics", "1");
transformer.setParameter("admon.graphics.path", admonGraphicsPath);
}
}
preTransform(transformer, srcFile, outputFile);
transformer.transform(new SAXSource(reader, inputSource), result);
postTransform(outputFile);
}
private void extractHighlightFiles(File toDir) {
File docbookZip = classpath.files.find { file -> file.name.contains('docbook-xsl-')};
if (docbookZip == null) {
throw new GradleException("Docbook zip file not found");
}
ZipFile zipFile = new ZipFile(docbookZip);
Enumeration e = zipFile.entries();
while (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry) e.nextElement();
if (ze.getName().matches(".*/highlighting/.*\\.xml")) {
String filename = ze.getName().substring(ze.getName().lastIndexOf("/highlighting/") + 14);
copyFile(zipFile.getInputStream(ze), new File(toDir, filename));
}
}
}
private void copyFile(InputStream source, File destFile) {
destFile.createNewFile();
FileOutputStream to = null;
try {
to = new FileOutputStream(destFile);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = source.read(buffer)) > 0) {
to.write(buffer, 0, bytesRead);
}
} finally {
if (source != null) {
source.close();
}
if (to != null) {
to.close();
}
}
}
protected void preTransform(Transformer transformer, File sourceFile, File outputFile) {
}
protected void postTransform(File outputFile) {
}
private CatalogManager createCatalogManager() {
CatalogManager manager = new CatalogManager();
manager.setIgnoreMissingProperties(true);
ClassLoader classLoader = this.getClass().getClassLoader();
StringBuilder builder = new StringBuilder();
String docbookCatalogName = "docbook/catalog.xml";
URL docbookCatalog = classLoader.getResource(docbookCatalogName);
if (docbookCatalog == null) {
throw new IllegalStateException("Docbook catalog " + docbookCatalogName + " could not be found in " + classLoader);
}
builder.append(docbookCatalog.toExternalForm());
Enumeration enumeration = classLoader.getResources("/catalog.xml");
while (enumeration.hasMoreElements()) {
builder.append(';');
URL resource = (URL) enumeration.nextElement();
builder.append(resource.toExternalForm());
}
String catalogFiles = builder.toString();
manager.setCatalogFiles(catalogFiles);
return manager;
}
}
/**
*/
class DocbookHtml extends Docbook {
@Override
protected void preTransform(Transformer transformer, File sourceFile, File outputFile) {
String rootFilename = outputFile.getName();
rootFilename = rootFilename.substring(0, rootFilename.lastIndexOf('.'));
transformer.setParameter("root.filename", rootFilename);
transformer.setParameter("base.dir", outputFile.getParent() + File.separator);
}
}
/**
*/
class DocbookFoPdf extends Docbook {
/**
* <a href="http://xmlgraphics.apache.org/fop/0.95/embedding.html#render">From the FOP usage guide</a>
*/
@Override
protected void postTransform(File foFile) {
FopFactory fopFactory = FopFactory.newInstance();
OutputStream out = null;
final File pdfFile = getPdfOutputFile(foFile);
logger.debug("Transforming 'fo' file " + foFile + " to PDF: " + pdfFile);
try {
out = new BufferedOutputStream(new FileOutputStream(pdfFile));
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source src = new StreamSource(foFile);
Result res = new SAXResult(fop.getDefaultHandler());
switch (project.gradle.startParameter.logLevel) {
case LogLevel.DEBUG:
case LogLevel.INFO:
break;
default:
// only show verbose fop output if the user has specified 'gradle -d' or 'gradle -i'
LoggerFactory.getILoggerFactory().getLogger('org.apache.fop').level = Level.ERROR
}
transformer.transform(src, res);
} finally {
if (out != null) {
out.close();
}
}
if (!foFile.delete()) {
logger.warn("Failed to delete 'fo' file " + foFile);
}
}
private File getPdfOutputFile(File foFile) {
String name = foFile.getAbsolutePath();
return new File(name.substring(0, name.length() - 2) + "pdf");
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright 2002-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.
*/
// -----------------------------------------------------------------------------
// Tasks related to deploying Maven artifacts.
//
// @author cbeams
// -----------------------------------------------------------------------------
// check that upload-related properties are defined and fail early if not
// these properties ('s3AccessKey', etc) should be defined in
// 'gradle.properties' in $HOME/.gradle/gradle.properties
def requiredProps = version.releaseType == 'RELEASE' ? ['mavenSyncRepoDir'] : ['s3AccessKey', 's3SecretAccessKey']
checkForProps(taskPath: project.path + ':uploadArchives', requiredProps: requiredProps)
/**
* Builds a source jar artifact for all main java sources.
*
* @author ltaylor
*/
task sourceJar(type: Jar) {
description = 'Builds a source jar artifact suitable for maven deployment.'
classifier = 'sources'
from sourceSets.main.java
}
build.dependsOn sourceJar
// Add the source jar archive to the set of artifacts for this project.
// Note that the regular 'jar' archive is already added by default.
artifacts {
archives sourceJar
}
/**
* Deploy gradle-built artifacts to a remote maven repository. Overrides and
* further customizes the 'uploadArchives' task contributed by the 'maven'
* plugin.
*
* The repository that artifacts are deployed to is determined conditionally
* based on the release type of the project version. Snapshot builds will
* be deployed via s3 to the springframework maven snapshot repository;
* milestone builds will happen via s3 as well; release builds will be deployed
* to the local filesystem to be sync'd via sourceforge CVS and ultimately
* deployed to maven central.
*
* Gradle will generate Maven poms on-the-fly during the deployment process.
* This process is customized to add ASL license information, and for projects
* that have the erlangLicense property set to true, the Erlang License will be
* added to the pom as well.
*
* @author cbeams
* @see 'mavenSyncRepoDir' in gradle.properties
* @see `gradle install` for deploying artifacts to the local .m2 cache
* @see http://maven.apache.org/guides/mini/guide-central-repository-upload.html
*/
uploadArchives {
group = 'Buildmaster'
description = "Does a maven deploy of archives artifacts to " // url appended below
def releaseRepositoryUrl = "file://${project.properties.mavenSyncRepoDir}"
def milestoneRepositoryUrl = 's3://maven.springframework.org/milestone'
def snapshotRepositoryUrl = 's3://maven.springframework.org/snapshot'
// add a configuration with a classpath that includes our s3 maven deployer
configurations { deployerJars }
dependencies {
deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
}
repositories.mavenDeployer {
switch (version.releaseType) {
case 'RELEASE':
repository(url: releaseRepositoryUrl)
description += releaseRepositoryUrl
break;
case 'MILESTONE':
description += milestoneRepositoryUrl
// fall through and pick up config below
case 'SNAPSHOT':
description += snapshotRepositoryUrl
s3credentials = [userName: project.properties.s3AccessKey, passphrase: project.properties.s3SecretAccessKey]
configuration = configurations.deployerJars
repository(url: milestoneRepositoryUrl) {
authentication(s3credentials)
}
snapshotRepository(url: snapshotRepositoryUrl) {
authentication(s3credentials)
}
break;
default:
throw new GradleException("unknown ReleaseType")
}
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
}

69
gradle/version.gradle Normal file
View File

@@ -0,0 +1,69 @@
class Version {
/**
* Indicates whether a version is a release, milestone, or snapshot
*/
static final String RELEASE = 'RELEASE'
static final String MILESTONE = 'MILESTONE'
static final String SNAPSHOT = 'SNAPSHOT'
String value
String releaseType
/**
* @param dotted -quad version spec, e.g.: 1.0.0.RELEASE
*/
public Version(String value) {
this.value = value;
this.releaseType = releaseTypeFor(value);
}
/**
* @return 1.0.x style
*/
public String getWildcardValue() {
return "1.0.x";
}
/**
* @return the version string returned by {@link getValue ( )}
*/
public String toString() {
return this.getValue();
}
/**
* @param dotted -quad version spec, e.g.: 1.0.0.RELEASE
*/
public static String releaseTypeFor(String version) {
if (version.endsWith("RELEASE")) return RELEASE;
if (version.endsWith("SNAPSHOT")) return SNAPSHOT;
if (version.matches(".*\\.M[0-9]+\$")) return MILESTONE;
throw new InvalidUserDataException("unknown version scheme: " +
"versions must end in (RELEASE|SNAPSHOT|M[0-9]+), " +
"but got (" + version + ")");
}
}
project.createVersion = { value ->
new Version(value)
}
def requiredPropSets = []
gradle.taskGraph.whenReady { graph ->
requiredPropSets.each { args ->
if (graph.hasTask(args.taskPath)) {
def missingProps = args.requiredProps.findAll { prop ->
!project.hasProperty(prop)
}
if (missingProps) {
throw new GradleException("For executing the ${args.taskPath} task you need to set all ${missingProps} properties")
}
}
}
}
project.checkForProps = { Map args ->
requiredPropSets.add args
}

32
gradle/wrapper.gradle Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright 2002-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.
*/
/**
* Generate gradlew and gradlew.bat scripts and associated files. These
* convenience scripts allow users to operate the build without being forced to
* download and install gradle.
*
* @author cbeams
* @see http://gradle.org/0.9-preview-3/docs/userguide/userguide_single.html#gradle_wrapper
*/
task wrapper(type: Wrapper) {
group = 'Buildmaster'
description = "Generates gradlew and gradlew.bat bootstrap scripts"
gradleVersion = '0.9-preview-3'
// place jar file and properties into a
// subdirectory to avoid root dir clutter
jarPath = 'gradle/wrapper'
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,9 @@
#Mon Oct 25 10:36:50 EDT 2010
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
distributionVersion=0.9-build-daemon-20101025155230+1100
zipStorePath=wrapper/dists
urlRoot=http\://gradle.artifactoryonline.com/gradle/distributions/gradle-snapshots
distributionName=gradle
distributionClassifier=bin

142
gradlew vendored Executable file
View File

@@ -0,0 +1,142 @@
#!/bin/bash
##############################################################################
## ##
## Gradle wrapper script for UN*X ##
## ##
##############################################################################
# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
# GRADLE_OPTS="$GRADLE_OPTS -Xmx512"
# JAVA_OPTS="$JAVA_OPTS -Xmx512"
GRADLE_APP_NAME=Gradle
warn ( ) {
echo "${PROGNAME}: $*"
}
die ( ) {
warn "$*"
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set JAVA_HOME if it's not already set.
if [ -z "$JAVA_HOME" ] ; then
if $darwin ; then
[ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
[ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
else
javaExecutable="`which javac`"
[ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
[ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
javaExecutable="`readlink -f \"$javaExecutable\"`"
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
export JAVA_HOME="$javaHome"
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar
WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties
# Determine the Java command to use to start the JVM.
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="java"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD"
fi
if [ -z "$JAVA_HOME" ] ; then
warn "JAVA_HOME environment variable is not set"
fi
# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
if $darwin; then
JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
# we may also want to set -Xdock:image
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
"$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
-classpath "$CLASSPATH" \
-Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
$STARTER_MAIN_CLASS \
"$@"

126
gradlew.bat vendored Executable file
View File

@@ -0,0 +1,126 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem ##
@rem Gradle startup script for Windows ##
@rem ##
@rem ##########################################################################
@rem
@rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $
@rem
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512
@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.\
@rem Determine the command interpreter to execute the "CD" later
set COMMAND_COM="cmd.exe"
if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"
@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
set FIND_EXE="find.exe"
if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"
:check_JAVA_HOME
@rem Make sure we have a valid JAVA_HOME
if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
echo.
echo ERROR: Environment variable JAVA_HOME has not been set.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo.
goto end
:have_JAVA_HOME
@rem Validate JAVA_HOME
%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
if not errorlevel 1 goto init
echo.
echo ERROR: JAVA_HOME might be set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation if there are problems.
echo.
:init
@rem get name of script to launch with full path
@rem Get command-line arguments, handling Windowz variants
SET _marker=%JAVA_HOME: =%
@rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems.
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%eval[2+2]" == "4" goto 4NT_args
IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args
set _FIXPATH=
call :fixpath "%JAVA_HOME%"
set JAVA_HOME=%_FIXPATH:~1%
goto win9xME_args
:fixpath
if not %1.==. (
for /f "tokens=1* delims=;" %%a in (%1) do (
call :shortfilename "%%a" & call :fixpath "%%b"
)
)
goto :EOF
:shortfilename
for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi
goto :EOF
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar
set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%"
exit /b "%ERRORLEVEL%"
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

17
settings.gradle Normal file
View File

@@ -0,0 +1,17 @@
/*
* Copyright 2002-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.
*/
include 'spring-integration-core'