Repository: zest-qi4j Updated Branches: refs/heads/develop b86b66d4e -> b351def71
Build, RAT: now use external RAT Gradle Plugin, see RAT-163 Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/8886104f Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/8886104f Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/8886104f Branch: refs/heads/develop Commit: 8886104f22f1b8ac2f4bed4eb11a1f7b0f7ab5ea Parents: b86b66d Author: Paul Merlin <[email protected]> Authored: Fri Jun 19 11:34:46 2015 +0200 Committer: Paul Merlin <[email protected]> Committed: Fri Jun 19 11:34:46 2015 +0200 ---------------------------------------------------------------------- build.gradle | 11 +++- gradle/apache-rat.gradle | 117 ------------------------------------------ 2 files changed, 10 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/8886104f/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index a16bc30..57dd7be 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,15 @@ project.ext { groovycMain_maxPermSize = "256m" } +buildscript { + repositories { + maven { url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.1.1' + } +} + apply plugin: 'java' apply plugin: 'idea' @@ -35,6 +44,7 @@ apply plugin: 'maven' apply from: 'maven-compat.gradle' apply plugin: 'project-report' apply from: 'libraries.gradle' +apply plugin: 'org.nosphere.apache.rat' targetCompatibility = "1.7" sourceCompatibility = "1.7" @@ -46,7 +56,6 @@ project.ext { def releaseApprovedProjects = allprojects.findAll( { project -> rootProject.ext.releaseSpec.satisfiedBy( project ) } ) -apply from: 'gradle/apache-rat.gradle' rat { excludes = [ '**/.DS_Store/**', http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/8886104f/gradle/apache-rat.gradle ---------------------------------------------------------------------- diff --git a/gradle/apache-rat.gradle b/gradle/apache-rat.gradle deleted file mode 100644 index dc0bcd6..0000000 --- a/gradle/apache-rat.gradle +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.internal.project.IsolatedAntBuilder - -apply plugin: RatPlugin - -class RatTask extends DefaultTask { - @Input - List<String> excludes - - def reportPath = 'build/rat' - def stylesheet = 'etc/apache-rat-output-to-html.xsl' - def xmlReport = reportPath + '/rat-report.xml' - def htmlReport = reportPath + '/rat-report.html' - - def generateXmlReport(File reportDir) { - def antBuilder = services.get(IsolatedAntBuilder) - def ratClasspath = project.configurations.rat - antBuilder.withClasspath(ratClasspath).execute { - ant.taskdef(resource: 'org/apache/rat/anttasks/antlib.xml') - ant.report(format: 'xml', reportFile: xmlReport) { - fileset(dir: ".") { - patternset { - excludes.each { exclude(name: it) } - } - } - } - } - } - - def printUnknownFiles() { - def ratXml = new XmlParser().parse(xmlReport) - def unknownLicenses = 0 - ratXml.resource.each { resource -> - if (resource.'license-approval'.@name[0] == "false") { - println('Unknown license: ' + resource.@name) - unknownLicenses++ - } - } - return unknownLicenses - } - - def generateHtmlReport() { - def antBuilder = services.get(IsolatedAntBuilder) - def ratClasspath = project.configurations.rat - antBuilder.withClasspath(ratClasspath).execute { - ant.xslt( - in: xmlReport, - style: stylesheet, - out: htmlReport, - classpath: ratClasspath - ) - } - println('Rat report: ' + htmlReport) - } - - @TaskAction - def rat() { - File reportDir = new File(reportPath) - if (!reportDir.exists()) { - reportDir.mkdirs() - } - generateXmlReport(reportDir) - def errorCount = printUnknownFiles() - generateHtmlReport() - if (errorCount > 0) { - throw new GradleException("Found $errorCount files with unknown licenses.") - } - } -} - -class RatPlugin implements Plugin<Project> { - void apply(Project project) { - configureDependencies(project) - project.plugins.apply(JavaBasePlugin); - Task ratTask = project.task( - 'rat', - type: RatTask, - group: 'Apache', - description: 'Runs Apache Rat checks.' - ) - // TODO Uncomment this to hook into `check` tasks - // project.tasks[JavaBasePlugin.CHECK_TASK_NAME].dependsOn ratTask - } - - void configureDependencies(final Project project) { - project.configurations { - rat - } - project.repositories { - mavenCentral() - } - project.dependencies { - rat 'org.apache.rat:apache-rat-tasks:0.11' - } - } -}
