Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit, taken from Spring Security codebase.

  • Loading branch information...
commit 9868de730a6e0fba4c21c49eec6078cf240edf9b 0 parents
@tekul authored Luke Taylor committed
14 .gitignore
@@ -0,0 +1,14 @@
+.classpath
+.project
+.DS_Store
+.settings/
+.idea/
+out/
+intellij/
+build/
+*.log
+*.iml
+*.ipr
+*.iws
+.gradle/
+gradle.properties
53 build.gradle
@@ -0,0 +1,53 @@
+apply plugin: 'groovy'
+apply plugin: 'idea'
+apply plugin: 'maven'
+
+group = 'org.springframework'
+version = '0.1-SNAPSHOT'
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+ // Bundlor
+ mavenRepo name: 'SpringSource', urls: 'http://repository.springsource.com/maven/bundles/release'
+}
+
+// Docbook Plugin
+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']
+ groovy localGroovy()
+ compile gradleApi(),
+ 'xml-resolver:xml-resolver:1.2',
+ 'xerces:xercesImpl:2.9.1',
+ 'saxon:saxon:6.5.3',
+ fopDeps
+
+ runtime 'net.sf.xslthl:xslthl:2.0.1',
+ 'net.sf.docbook:docbook-xsl:1.75.2:ns-resources@zip'
+}
+
+// GAE
+dependencies {
+ compile 'com.google.appengine:appengine-tools-sdk:1.4.2'
+}
+
+dependencies{
+ compile "emma:emma:2.0.5312"
+}
+
+// Bundlor
+dependencies {
+ compile 'com.springsource.bundlor:com.springsource.bundlor:1.0.0.RELEASE',
+ 'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RELEASE'
+}
+
+ideaModule {
+ excludeDirs += file('.gradle')
+}
75 src/main/groovy/ScpUpload.groovy
@@ -0,0 +1,75 @@
+import org.gradle.api.DefaultTask;
+import org.gradle.api.tasks.*;
+import org.gradle.api.tasks.bundling.Tar;
+import org.gradle.api.tasks.bundling.Compression;
+
+/**
+ * Extends the Tar task, uploading the created archive to a remote directory, unpacking and deleting it.
+ * Requires Ant ssh (jsch) support.
+ */
+class ScpUpload extends Tar {
+ @Input
+ String remoteDir
+ Login login
+ @Input
+ String host
+
+ ScpUpload() {
+ compression = Compression.BZIP2
+ if (project.configurations.findByName('antjsch') == null) {
+ project.configurations.add('antjsch')
+ project.dependencies {
+ antjsch 'org.apache.ant:ant-jsch:1.8.1'
+ }
+ def classpath = project.configurations.antjsch.asPath
+ project.ant {
+ taskdef(name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp', classpath: classpath)
+ taskdef(name: 'sshexec', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec', classpath: classpath)
+ }
+ }
+ }
+
+ @TaskAction
+ void copy() {
+ super.copy();
+ upload();
+ }
+
+ def upload() {
+ String username = login.username
+ String password = login.password
+ String host = login.host
+ project.ant {
+ scp(file: archivePath, todir: "$username@$host:$remoteDir", password: password)
+ sshexec(host: host, username: username, password: password, command: "cd $remoteDir && tar -xjf $archiveName")
+ sshexec(host: host, username: username, password: password, command: "rm $remoteDir/$archiveName")
+ }
+ }
+
+ void setLogin(Login login) {
+ dependsOn(login)
+ this.login = login
+ this.host = login.host
+ }
+}
+
+/**
+ * Stores login information for a remote host.
+ */
+class Login extends DefaultTask {
+ @Input
+ String host
+ String username
+ String password
+
+ @TaskAction
+ login() {
+ def console = System.console()
+ if (console) {
+ username = console.readLine("\nPlease enter the ssh username for host '$host': ")
+ password = new String(console.readPassword("Please enter the ssh password for '$host': "))
+ } else {
+ logger.error "Unable to access System.console()."
+ }
+ }
+}
74 src/main/groovy/org/springframework/gradle/plugins/aspectj/AspectJPlugin.groovy
@@ -0,0 +1,74 @@
+package org.springframework.gradle.plugins.aspectj
+
+import org.gradle.api.Project
+import org.gradle.api.Plugin
+import org.gradle.api.tasks.TaskAction
+import org.gradle.api.logging.LogLevel
+import org.gradle.api.file.FileCollection
+import org.gradle.api.tasks.SourceSet
+import org.gradle.api.DefaultTask
+import org.gradle.api.GradleException
+
+/**
+ *
+ * @author Luke Taylor
+ */
+class AspectJPlugin implements Plugin<Project> {
+
+ void apply(Project project) {
+ if (!project.hasProperty('aspectjVersion')) {
+ throw new GradleException("You must set the property 'aspectjVersion' before applying the aspectj plugin")
+ }
+
+ if (project.configurations.findByName('ajtools') == null) {
+ project.configurations.add('ajtools')
+ project.dependencies {
+ ajtools "org.aspectj:aspectjtools:${project.aspectjVersion}"
+ compile "org.aspectj:aspectjrt:${project.aspectjVersion}"
+ }
+ }
+
+ if (project.configurations.findByName('aspectpath') == null) {
+ project.configurations.add('aspectpath')
+ }
+
+ project.tasks.add(name: 'compileJava', overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) {
+ dependsOn project.processResources
+ sourceSet = project.sourceSets.main
+ outputs.dir(sourceSet.classesDir)
+ aspectPath = project.configurations.aspectpath
+ }
+
+ project.tasks.add(name: 'compileTestJava', overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) {
+ dependsOn project.processTestResources, project.compileJava, project.jar
+ sourceSet = project.sourceSets.test
+ outputs.dir(sourceSet.classesDir)
+ aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath)
+ }
+ }
+}
+
+class Ajc extends DefaultTask {
+ SourceSet sourceSet
+ FileCollection aspectPath
+
+ Ajc() {
+ logging.captureStandardOutput(LogLevel.INFO)
+ }
+
+ @TaskAction
+ def compile() {
+ logger.info("Running ajc ...")
+ ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath)
+ ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.classesDir.absolutePath,
+ source: project.convention.plugins.java.sourceCompatibility,
+ target: project.convention.plugins.java.targetCompatibility,
+ aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') {
+ sourceroots {
+ sourceSet.java.srcDirs.each {
+ pathelement(location: it.absolutePath)
+ }
+ }
+ }
+ }
+}
121 src/main/groovy/org/springframework/gradle/plugins/bundlor/BundlorPlugin.groovy
@@ -0,0 +1,121 @@
+package org.springframework.gradle.plugins.bundlor
+
+import com.springsource.bundlor.ClassPath
+import com.springsource.bundlor.ManifestGenerator
+import com.springsource.bundlor.ManifestWriter
+import com.springsource.bundlor.blint.ManifestValidator
+import com.springsource.bundlor.blint.support.DefaultManifestValidatorContributorsFactory
+import com.springsource.bundlor.blint.support.StandardManifestValidator
+import com.springsource.bundlor.support.DefaultManifestGeneratorContributorsFactory
+import com.springsource.bundlor.support.StandardManifestGenerator
+import com.springsource.bundlor.support.classpath.StandardClassPathFactory
+import com.springsource.bundlor.support.manifestwriter.StandardManifestWriterFactory
+import com.springsource.bundlor.support.properties.EmptyPropertiesSource
+import com.springsource.bundlor.support.properties.FileSystemPropertiesSource
+import com.springsource.bundlor.support.properties.PropertiesPropertiesSource
+import com.springsource.bundlor.support.properties.PropertiesSource
+import com.springsource.bundlor.util.BundleManifestUtils
+import com.springsource.util.parser.manifest.ManifestContents
+import org.gradle.api.DefaultTask
+import org.gradle.api.GradleException
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.Task
+import org.gradle.api.logging.LogLevel
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.Optional
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+
+/**
+ * @author Luke Taylor
+ */
+class BundlorPlugin implements Plugin<Project> {
+ void apply(Project project) {
+ Task bundlor = project.tasks.add('bundlor', Bundlor.class)
+ bundlor.setDescription('Generates OSGi manifest using bundlor tool')
+ project.jar.dependsOn bundlor
+ }
+}
+
+public class Bundlor extends DefaultTask {
+ @InputFile
+ File manifestTemplate
+
+ @OutputDirectory
+ File bundlorDir = new File("${project.buildDir}/bundlor")
+
+ @OutputFile
+ File manifest = project.file("${bundlorDir}/META-INF/MANIFEST.MF")
+
+ @Input
+ Map<String,String> expansions = [:]
+
+ @InputFile
+ @Optional
+ File osgiProfile
+
+ @Input
+ boolean failOnWarnings = false
+
+ Bundlor() {
+ manifestTemplate = new File(project.projectDir, 'template.mf')
+ inputs.files project.sourceSets.main.runtimeClasspath
+ project.jar.manifest.from manifest
+ project.jar.inputs.files manifest
+ }
+
+ @TaskAction
+ void createManifest() {
+ logging.captureStandardOutput(LogLevel.INFO)
+
+ project.mkdir(bundlorDir)
+
+ String inputPath = project.sourceSets.main.classesDir
+
+ ClassPath inputClassPath = new StandardClassPathFactory().create(inputPath);
+ ManifestWriter manifestWriter = new StandardManifestWriterFactory().create(inputPath, bundlorDir.absolutePath);
+ ManifestContents mfTemplate = BundleManifestUtils.getManifest(manifestTemplate);
+
+ // Must be a better way of doing this...
+ Properties p = new Properties()
+ expansions.each {entry ->
+ p.setProperty(entry.key, entry.value as String)
+ }
+
+ PropertiesSource expansionProps = new PropertiesPropertiesSource(p)
+ PropertiesSource osgiProfileProps = osgiProfile == null ? new EmptyPropertiesSource() :
+ new FileSystemPropertiesSource(osgiProfile);
+
+ ManifestGenerator manifestGenerator = new StandardManifestGenerator(
+ DefaultManifestGeneratorContributorsFactory.create(expansionProps, osgiProfileProps));
+
+ ManifestContents mf = manifestGenerator.generate(mfTemplate, inputClassPath);
+
+ try {
+ manifestWriter.write(mf);
+ } finally {
+ manifestWriter.close();
+ }
+
+ ManifestValidator manifestValidator = new StandardManifestValidator(DefaultManifestValidatorContributorsFactory.create());
+
+ List<String> warnings = manifestValidator.validate(mf);
+
+ if (warnings.isEmpty()) {
+ return
+ }
+
+ logger.warn("Bundlor Warnings:");
+ for (String warning : warnings) {
+ logger.warn(" " + warning);
+ }
+
+ if (failOnWarnings) {
+ throw new GradleException("Bundlor returned warnings. Please fix manifest template at " + manifestTemplate.absolutePath + " and try again.")
+ }
+
+ }
+}
276 src/main/groovy/org/springframework/gradle/plugins/docbook/DocbookPlugin.groovy
@@ -0,0 +1,276 @@
+package org.springframework.gradle.plugins.docbook;
+
+import org.gradle.api.Plugin;
+import org.gradle.api.GradleException;
+import org.gradle.api.DefaultTask;
+import org.gradle.api.Task;
+import org.gradle.api.Project;
+
+
+import org.gradle.api.tasks.*;
+
+
+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 com.icl.saxon.TransformerFactoryImpl;
+
+/**
+ * Gradle Docbook plugin implementation.
+ * <p>
+ * Creates three tasks: docbookHtml, docbookHtmlSingle and docbookPdf. Each task takes a single File on
+ * which it operates.
+ */
+class DocbookPlugin implements Plugin<Project> {
+ public void apply(Project project) {
+ // Add the plugin tasks to the project
+ Task docbookHtml = project.tasks.add('docbookHtml', DocbookHtml.class);
+ docbookHtml.setDescription('Generates chunked docbook html output');
+
+ Task docbookHtmlSingle = project.tasks.add('docbookHtmlSingle', Docbook.class);
+ docbookHtmlSingle.setDescription('Generates single page docbook html output')
+ docbookHtmlSingle.suffix = '-single'
+
+ Task docbookFoPdf = project.tasks.add("docbookFoPdf", DocbookFoPdf.class);
+ docbookFoPdf.setDescription('Generates PDF output');
+ docbookFoPdf.extension = 'fo'
+
+ Task docbook = project.tasks.add("docbook", DefaultTask.class);
+ docbook.dependsOn (docbookHtml, docbookHtmlSingle, docbookFoPdf)
+ }
+}
+
+/**
+ */
+public class Docbook extends DefaultTask {
+
+ @Input
+ String extension = 'html';
+
+ @Input
+ String suffix = '';
+
+ @Input
+ boolean XIncludeAware = true;
+
+ @Input
+ boolean highlightingEnabled = true;
+
+ String admonGraphicsPath;
+
+ String imgSrcPath;
+
+ @InputDirectory
+ File sourceDirectory = new File(project.getProjectDir(), "src/docbook");
+
+ @Input
+ String sourceFileName;
+
+ @InputFile
+ File stylesheet;
+
+ @OutputDirectory
+ File docsDir = new File(project.getBuildDir(), "docs");
+
+ @TaskAction
+ public final void transform() {
+ 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) + suffix + '.' + extension;
+
+ File outputFile = new File(getDocsDir(), 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);
+ }
+
+ if (imgSrcPath != null) {
+ transformer.setParameter("img.src.path", imgSrcPath);
+ }
+
+ preTransform(transformer, srcFile, outputFile);
+
+ transformer.transform(new SAXSource(reader, inputSource), result);
+
+ postTransform(outputFile);
+ }
+
+ private void extractHighlightFiles(File toDir) {
+ URLClassLoader cl = (URLClassLoader) getClass().getClassLoader();
+ URL[] urls = cl.getURLs();
+ URL docbookZip = null;
+
+ for (URL url : urls) {
+ if (url.toString().contains("docbook-xsl-")) {
+ docbookZip = url;
+ break;
+ }
+ }
+
+ if (docbookZip == null) {
+ throw new GradleException("Docbook zip file not found");
+ }
+
+ ZipFile zipFile = new ZipFile(new File(docbookZip.toURI()));
+
+ 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());
+
+ 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");
+ }
+}
114 src/main/groovy/org/springframework/gradle/plugins/emma/EmmaPlugin.groovy
@@ -0,0 +1,114 @@
+package org.springframework.gradle.plugins.emma;
+
+import org.gradle.api.*
+import org.gradle.api.tasks.testing.Test
+import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.Input
+import com.vladium.emma.instr.InstrProcessor
+import com.vladium.emma.report.ReportProcessor
+
+import com.vladium.util.XProperties;
+
+/**
+ *
+ * @author Luke Taylor
+ */
+class EmmaPlugin implements Plugin<Project> {
+
+ void apply(Project project) {
+ Project rootProject = project.rootProject
+ def emmaMetaDataFile = "${rootProject.buildDir}/emma/emma.em"
+ def emmaCoverageFile = "${rootProject.buildDir}/emma/emma.ec"
+
+ if (project.configurations.findByName('emma_rt') == null) {
+ project.configurations.add('emma_rt')
+ project.dependencies {
+ emma_rt 'emma:emma:2.0.5312'
+ }
+ }
+
+ project.task('emmaInstrument') {
+ dependsOn project.classes
+
+ doFirst {
+ InstrProcessor processor = InstrProcessor.create ();
+ String[] classesDirPath = [project.sourceSets.main.classesDir.absolutePath]
+
+ processor.setInstrPath(classesDirPath, false);
+ processor.setOutMode(InstrProcessor.OutMode.OUT_MODE_COPY);
+ processor.setInstrOutDir("${project.buildDir}/emma/classes");
+ processor.setMetaOutFile(emmaMetaDataFile);
+ processor.setMetaOutMerge(true);
+ //processor.setInclExclFilter (null);
+ processor.run();
+ }
+ }
+
+ // Modify test tasks in the project to generate coverage data
+ project.afterEvaluate {
+ if (project.hasProperty('coverage') && ['on','true'].contains(project.properties.coverage)) {
+ project.tasks.withType(Test.class).each { task ->
+ task.dependsOn project.emmaInstrument
+ task.configure() {
+ jvmArgs '-Dsec.log.level=DEBUG', "-Demma.coverage.out.file=$emmaCoverageFile"
+ jvmArgs '-Demma.verbosity.level=quiet'
+ }
+ task.doFirst {
+ classpath = project.files("${project.buildDir}/emma/classes") + project.configurations.emma_rt + classpath
+ }
+ }
+ }
+ }
+
+ List<Task> reportTasks = rootProject.getTasksByName('coverageReport', false) as List;
+ CoverageReport task;
+
+ if (reportTasks.isEmpty()) {
+ task = rootProject.tasks.add('coverageReport', CoverageReport.class);
+ task.dataPath = [emmaMetaDataFile, emmaCoverageFile];
+ } else {
+ task = reportTasks[0];
+ }
+
+ task.modules.add(project);
+ }
+}
+
+class CoverageReport extends DefaultTask {
+ @Input
+ List<Project> modules = [];
+
+ @Input
+ String[] dataPath;
+
+ @TaskAction
+ void generateReport() {
+ def buildDir = project.rootProject.buildDir
+
+ if (!buildDir.exists()) {
+ throw new GradleException("No coverage data. Run gradle with -Pcoverage=on if using coverageReport");
+ }
+
+ ReportProcessor processor = ReportProcessor.create ();
+ processor.setDataPath(dataPath)
+
+ def srcPath = []
+ modules.each {module->
+ module.sourceSets.main.java.srcDirs.each {
+ srcPath.add(it.absolutePath)
+ }
+ }
+
+ processor.setSourcePath(srcPath as String[]);
+
+
+ def types = ['txt', 'html']
+ processor.setReportTypes(types as String[]);
+ XProperties properties = new XProperties();
+ properties.setProperty('report.html.out.file', "$buildDir/emma/coverage.html");
+ properties.setProperty('report.txt.out.file', "$buildDir/emma/coverage.txt");
+ processor.setPropertyOverrides(properties)
+
+ processor.run()
+ }
+}
29 src/main/groovy/org/springframework/gradle/plugins/gae/GaePlugin.groovy
@@ -0,0 +1,29 @@
+package org.springframework.gradle.plugins.gae;
+
+import com.google.appengine.tools.admin.AppCfg
+import org.gradle.api.*;
+
+/**
+ *
+ */
+class GaePlugin implements Plugin<Project> {
+ public void apply(Project project) {
+ if (!project.hasProperty('appEngineSdkRoot')) {
+ println "'appEngineSdkRoot' must be set in gradle.properties"
+ } else {
+ System.setProperty('appengine.sdk.root', project.property('appEngineSdkRoot'))
+ }
+
+ File explodedWar = new File(project.buildDir, "gae-exploded")
+
+ project.task('gaeDeploy') << {
+ AppCfg.main("update", explodedWar.toString())
+ }
+
+ project.gaeDeploy.dependsOn project.war
+
+ project.war.doLast {
+ ant.unzip(src: project.war.archivePath, dest: explodedWar)
+ }
+ }
+}
1  src/main/resources/META-INF/gradle-plugins/aspectj.properties
@@ -0,0 +1 @@
+implementation-class=org.springframework.gradle.plugins.aspectj.AspectJPlugin
1  src/main/resources/META-INF/gradle-plugins/bundlor.properties
@@ -0,0 +1 @@
+implementation-class=org.springframework.gradle.plugins.bundlor.BundlorPlugin
1  src/main/resources/META-INF/gradle-plugins/docbook.properties
@@ -0,0 +1 @@
+implementation-class=org.springframework.gradle.plugins.docbook.DocbookPlugin
1  src/main/resources/META-INF/gradle-plugins/emma.properties
@@ -0,0 +1 @@
+implementation-class=org.springframework.gradle.plugins.emma.EmmaPlugin
1  src/main/resources/META-INF/gradle-plugins/gae.properties
@@ -0,0 +1 @@
+implementation-class=org.springframework.gradle.plugins.gae.GaePlugin
Please sign in to comment.
Something went wrong with that request. Please try again.