"Fossies" - the Fresh Open Source Software Archive

Member "groovy-3.0.9/gradle/quality.gradle" (3 Sep 2021, 9059 Bytes) of package /linux/misc/apache-groovy-src-3.0.9.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "quality.gradle": 3.0.8_vs_3.0.9.

    1 /*
    2  *  Licensed to the Apache Software Foundation (ASF) under one
    3  *  or more contributor license agreements.  See the NOTICE file
    4  *  distributed with this work for additional information
    5  *  regarding copyright ownership.  The ASF licenses this file
    6  *  to you under the Apache License, Version 2.0 (the
    7  *  "License"); you may not use this file except in compliance
    8  *  with the License.  You may obtain a copy of the License at
    9  *
   10  *    http://www.apache.org/licenses/LICENSE-2.0
   11  *
   12  *  Unless required by applicable law or agreed to in writing,
   13  *  software distributed under the License is distributed on an
   14  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15  *  KIND, either express or implied.  See the License for the
   16  *  specific language governing permissions and limitations
   17  *  under the License.
   18  */
   19 import groovy.text.markup.MarkupTemplateEngine
   20 import groovy.text.markup.TemplateConfiguration
   21 
   22 allprojects { proj ->
   23     apply plugin: "org.nosphere.apache.rat"
   24     //apply plugin: "com.github.hierynomus.license"
   25     apply plugin: 'checkstyle'
   26     apply plugin: 'codenarc'
   27     apply plugin: 'com.github.spotbugs'
   28     configurations.codenarc {
   29         // because we will rely on the version we build
   30         // because version ranges are evil
   31         // and because it causes bnd to be brought transitively
   32         // I am unsure why; says it is required by groovy-ant but its pom.xml does not declare so
   33         resolutionStrategy.dependencySubstitution {
   34             substitute module("org.codehaus.groovy:groovy") with project(":")
   35             substitute module("org.codehaus.groovy:groovy-ant") with project(":groovy-ant")
   36             substitute module("org.codehaus.groovy:groovy-xml") with project(":groovy-xml")
   37             substitute module("org.codehaus.groovy:groovy-groovydoc") with project(":groovy-groovydoc")
   38         }
   39 
   40         exclude module: 'groovy-all'
   41     }
   42 
   43     dependencies {
   44         checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion"
   45         codenarc "org.codenarc:CodeNarc:2.2.0"
   46         spotbugs "com.github.spotbugs:spotbugs:$spotbugsVersion"
   47         if (proj.name.contains('jaxb') && JavaVersion.current().isJava9Compatible()) {
   48             spotbugs 'javax.xml.bind:jaxb-api:2.3.0'
   49         }
   50         codenarc project(":groovy-templates")
   51     }
   52 
   53 //    license {
   54 //        header rootProject.file('config/licensing/HEADER.txt')
   55 //        include "**/*.groovy"
   56 //        include "**/*.java"
   57 //        include "**/*.properties"
   58 //        include "**/*.js"
   59 //        include "**/*.css"
   60 //        include "**/*.html"
   61 //        include "**/*.gradle"
   62 //        include "**/*.xml"
   63 //        exclude "org/codehaus/groovy/antlr/**"
   64 //        exclude 'reloading/**' // test resources for documentation of reloading
   65 //        exclude 'includes/**' // documentation resources included as snippets of code
   66 //        //dryRun = true
   67 //        ignoreFailures = true
   68 //        //skipExistingHeaders = true
   69 //        //ext.year = Calendar.instance.get(Calendar.YEAR)
   70 //    }
   71 
   72     // don't fail build on CodeNarc tasks
   73     tasks.withType(CodeNarc) {
   74         //dependsOn jar
   75         ignoreFailures = true
   76         configFile = file("$rootProject.projectDir/config/codenarc/codenarc.groovy")
   77         doFirst {
   78             configurations.codenarc.files.each { println it }
   79         }
   80     }
   81 
   82     tasks.withType(Checkstyle) {
   83         showViolations = false
   84         ignoreFailures = true
   85         configFile = file("$rootProject.projectDir/config/checkstyle/checkstyle.xml")
   86         configProperties = ['rootProject.projectDir': rootProject.projectDir]
   87         def reportFile = file("${buildDir}/reports/checkstyle/${name}.xml")
   88         reports {
   89             include ( '**/*.java')
   90             xml {
   91                 destination reportFile
   92             }
   93         }
   94         if (!source.empty) {
   95             task("${name}Report") {
   96                 def configDir = file("$rootProject.projectDir/config/checkstyle")
   97                 def templateFile = 'checkstyle-report.groovy'
   98                 def htmlReportFile = file("${buildDir}/reports/checkstyle/${name}.html")
   99                 inputs.file file("$configDir/$templateFile")
  100                 inputs.file reportFile
  101                 outputs.file htmlReportFile
  102 
  103                 doLast {
  104                     def templateConfiguration = new TemplateConfiguration()
  105                     templateConfiguration.with {
  106                         autoIndent = true
  107                         autoNewLine = true
  108                     }
  109                     def engine = new MarkupTemplateEngine(this.class.classLoader, configDir, templateConfiguration)
  110                     def xml = new XmlSlurper().parse(reportFile.newReader('utf-8'))
  111                     def files = []
  112                     xml.file.each { f ->
  113                         if (f.error.size() && !f.@name.toString().matches('.*[/\\\\]generated[/\\\\].*')) {
  114                             files << [
  115                                     name: f.@name.toString(),
  116                                     errors: f.error.collect { e ->
  117                                         def rule = e.@source.toString()
  118                                         rule = rule.substring(rule.lastIndexOf('.')+1)
  119                                         [line: e.@line.toString(),
  120                                          column: e.@column.toString(),
  121                                          message: e.@message.toString(),
  122                                          source: rule,
  123                                          severity: e.@severity.toString()]
  124                                     }]
  125                         }
  126                     }
  127                     def model = [
  128                             project: project,
  129                             files: files
  130                     ]
  131                     htmlReportFile.withWriter('utf-8') { wrt ->
  132                         engine.createTemplateByPath('checkstyle-report.groovy').make(model).writeTo(wrt)
  133                     }
  134                 }
  135             }
  136             finalizedBy "${name}Report"
  137         }
  138     }
  139 
  140     tasks.withType(SpotBugsTask) {
  141         // TODO work out why the following aren't being set automatically
  142         if (proj.name.contains('jaxb')) {
  143             reportsDir = file("$buildDir/reports/spotbugs")
  144             projectName = proj.name
  145             release = rootProject.version
  146         }
  147         excludeFilter = file("$rootProject.projectDir/config/spotbugs/exclude.xml")
  148         ignoreFailures = true
  149         effort = 'max'
  150         maxHeapSize = '2g'
  151         reports {
  152             xml.enabled = false
  153             html {
  154                 enabled = true
  155                 stylesheet = 'fancy.xsl'
  156             }
  157         }
  158     }
  159 }
  160 
  161 subprojects { sp ->
  162     def extras = []
  163     switch(sp.name) {
  164         case 'groovy-templates':
  165             extras = [
  166                     // test files
  167                     'src/spec/test-resources/*.txt',
  168                     'src/test/resources/includes/hello-escaped.txt',
  169                     'src/test/resources/includes/hello.html'
  170             ]
  171             break
  172         case ['groovy-groovydoc', 'groovy-docgenerator']:
  173             extras = [
  174                     '**/stylesheet.css'  // MIT license as per NOTICE/LICENSE files
  175             ]
  176             break
  177     }
  178     rat {
  179         inputDir = sp.projectDir
  180         excludes = [ 'target/**', 'build/**', '.gradle/**', '*.iml', '.classpath', '.project', '.settings/**', 'bin/**' , *extras]
  181     }
  182 }
  183 
  184 rat {
  185     inputDir = projectDir
  186     excludes = [ 'subprojects/**', // covered above
  187                  'benchmark/**', // benchmarking files excluded from src zip
  188                  'config/**',
  189                  'src/install/**', // CI file excluded from src zip
  190                  'src/test/org/codehaus/groovy/ast/LineColumnCheck.txt', // test file
  191                  'security/groovykeys', // excluded from src zip
  192                  '**/.gradle/**', '**/wrapper/**', 'gradlew*',  // gradle wrapper files excluded from src zip
  193                  'artifactory.properties',  // potential file on CI server
  194                  'gradle.properties',  // artifactory release plugin removes header when bumping version
  195                  '**/target/**', '**/build/**', 'licenses/**', 'notices/**',
  196                  'out/**', '*.ipr',  '**/*.iml', '*.iws', '.idea/**', // Intellij files
  197                  '**/style.css', // MIT license as per NOTICE/LICENSE files
  198                  '**/jquery-2.1.1.min.js', // MIT license as per NOTICE/LICENSE files
  199                  '.classpath', '.project', '.settings/**', 'bin/**', // Eclipse files
  200                  'bootstrap/settings.gradle', // empty file
  201     ]
  202 }
  203 
  204 apply from: 'gradle/jacoco/jacoco.gradle'
  205 
  206 sonarqube {
  207     properties {
  208         property "sonar.projectName", "Apache Groovy"
  209         property "sonar.projectKey", "apache_groovy"
  210         property "sonar.organization", "apache"
  211         property "sonar.host.url", "https://sonarcloud.io"
  212 //        property "sonar.coverage.jacoco.xmlReportPaths", "${rootProject.buildDir}/reports/jacoco/jacocoAllReport/jacocoAllReport.xml"
  213     }
  214 }