"Fossies" - the Fresh Open Source Software Archive

Member "groovy-3.0.9/build.gradle" (3 Sep 2021, 17525 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 "build.gradle": 3.0.9_vs_4.0.0-rc-1.

    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 org.codehaus.groovy.gradle.ReleaseInfoGenerator
   20 
   21 buildscript {
   22     repositories {
   23         if (rootProject.hasProperty('buildInChina')) {
   24             // Try to use Aliyun maven repository when building in China
   25             maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
   26         }
   27         jcenter()
   28         maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
   29         maven {
   30             url "https://plugins.gradle.org/m2/"
   31         }
   32         maven {
   33             url 'https://jitpack.io'
   34         }
   35     }
   36 
   37     dependencies {
   38         // using the old "classpath" style of plugins because the new one doesn't play well with multi-modules
   39         classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.8'
   40         classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"
   41         //classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
   42         classpath "org.nosphere.apache:creadur-rat-gradle:0.7.0"
   43         classpath "gradle.plugin.com.github.jk1:gradle-license-report:1.3"
   44     }
   45 }
   46 
   47 plugins {
   48     id 'me.champeau.buildscan-recipes' version '0.2.3'
   49     id 'com.github.spotbugs' version '4.6.0'
   50     id 'com.github.ben-manes.versions' version '0.38.0'
   51     id 'com.github.blindpirate.osgi' version '0.0.4'
   52     id 'org.sonarqube' version '3.0'
   53 }
   54 
   55 buildScanRecipes {
   56     recipe 'git-commit', baseUrl: 'https://github.com/apache/groovy/tree'
   57     recipe 'teamcity', baseUrl: 'https://ci.groovy-lang.org', guest: 'true'
   58     recipes 'git-status', 'gc-stats', 'teamcity', 'travis-ci'
   59 }
   60 
   61 ext.modules = {
   62     subprojects.findAll{ !['performance', 'binary-compatibility'].contains(it.name) }
   63 }
   64 ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
   65 
   66 apply from: 'gradle/bad-practices.gradle'
   67 //apply from: 'gradle/indy.gradle'
   68 apply from: 'gradle/publish.gradle'
   69 apply plugin: "com.github.jk1.dependency-license-report"
   70 
   71 File javaHome = new File(System.getProperty('java.home'))
   72 logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
   73 
   74 allprojects {
   75     apply plugin: 'java-library'
   76 
   77     buildDir = 'target'
   78     sourceCompatibility = 1.8
   79     targetCompatibility = 1.8
   80 
   81     group = 'org.codehaus.groovy'
   82     version = groovyVersion
   83     repositories {
   84         if (rootProject.hasProperty('buildInChina')) {
   85             // Try to use Aliyun maven repository when building in China
   86             maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
   87         }
   88         jcenter()
   89 //        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
   90 //        mavenLocal()
   91     }
   92 
   93     ext.buildDate = isReleaseVersion?new Date():new Date(0)
   94 
   95     task generateReleaseInfo(type: ReleaseInfoGenerator) {
   96         version = rootProject.groovyVersion
   97         bundleVersion = rootProject.groovyBundleVersion
   98         buildDate = rootProject.buildDate
   99         outputFile = file("$buildDir/release-info/groovy-release-info.properties")
  100     }
  101 
  102     apply plugin: 'groovy'
  103     apply from: "${rootProject.projectDir}/gradle/indy.gradle"
  104     apply from: "${rootProject.projectDir}/gradle/asciidoctor.gradle"
  105 
  106     tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) {
  107         outputs.cacheIf { true }
  108     }
  109 }
  110 
  111 task(copyTestResources, type: Copy)
  112         .from('src/test')
  113         .into("$buildDir/classes/test")
  114         .include('**/*.txt', '**/*.xml', '**/*.properties', '**/*.png', '**/*.html', '**/*.gif', '**/*.ico', '**/*.css')
  115 test.dependsOn(copyTestResources)
  116 
  117 repositories {
  118     // todo Some repos are needed only for some configs. Declare them just for the configuration once Gradle allows this.
  119     maven { url 'https://repository.jboss.org/nexus/content/groups/m2-release-proxy' } // tools
  120 }
  121 
  122 configurations {
  123     compilerCompile
  124     tools
  125     antlr2
  126     spec
  127 }
  128 
  129 ext {
  130     antVersion = '1.10.11'
  131     asmVersion = '9.2'
  132     antlrVersion = '2.7.7'
  133     antlr4Version = '4.9.0'
  134     bridgerVersion = '1.5.Final'
  135     coberturaVersion = '1.9.4.1'
  136     commonsCliVersion = '1.4'
  137     gparsVersion = '1.2.1'
  138     ivyVersion = '2.5.0'
  139     jansiVersion = '2.1.1'
  140     jarjarVersion = '1.7.2'
  141     javaParserVersion = '3.23.0'
  142     jlineVersion = '2.14.6'
  143     jmockVersion = '1.2.0'
  144     logbackVersion = '1.2.3'
  145     log4jVersion = '1.2.17'
  146     log4j2Version = '2.14.0'
  147     openbeansVersion = '1.0.2'
  148     picocliVersion = '4.6.1'
  149     qdoxVersion = '1.12.1'
  150     slf4jVersion = '1.7.31'
  151     xmlunitVersion = '1.6'
  152     xstreamVersion = '1.4.18'
  153     spockVersion = '2.0-groovy-3.0'
  154     spotbugsVersion = '4.4.0'
  155     spotbugsAnnotationsVersion = '4.4.0'
  156     checkstyleVersion = '8.44'
  157     junit5Version = '5.7.2'
  158     junit5PlatformVersion = '1.7.2'
  159     jcipAnnotationsVersion = '1.0'
  160     jspApiVersion = '2.3.3'
  161     servletApiVersion = '4.0.1'
  162 }
  163 
  164 dependencies {
  165     // for internal CLI usage
  166     api "info.picocli:picocli:$picocliVersion" // marked as api but manually excluded later in assemble.gradle - modules will use shaded version
  167     // for internal usage of things like Opcode
  168     api "org.ow2.asm:asm:$asmVersion" // marked as api but manually excluded later in assemble.gradle - modules will use shaded version
  169     // for internal usage by the parser but manually excluded later in assemble.gradle - modules will use shaded version
  170     api "antlr:antlr:$antlrVersion"
  171     implementation "org.ow2.asm:asm-analysis:$asmVersion"
  172     implementation "org.ow2.asm:asm-commons:$asmVersion"
  173     implementation "org.ow2.asm:asm-tree:$asmVersion"
  174     implementation "org.ow2.asm:asm-util:$asmVersion"
  175     implementation("com.thoughtworks.xstream:xstream:$xstreamVersion") {
  176         exclude(group: 'xpp3', module: 'xpp3_min')
  177         exclude(group: 'junit', module: 'junit')
  178         exclude(group: 'jmock', module: 'jmock')
  179         exclude(group: 'xmlpull', module: 'xmlpull')
  180     }
  181     implementation "me.champeau.openbeans:openbeans:$openbeansVersion"
  182     implementation "org.fusesource.jansi:jansi:$jansiVersion"
  183     implementation("org.apache.ivy:ivy:$ivyVersion") {
  184         transitive = false
  185     }
  186 
  187     implementation("org.codehaus.gpars:gpars:$gparsVersion") {
  188         exclude(group: 'org.codehaus.groovy', module: 'groovy-all')
  189     }
  190 
  191     testImplementation "jmock:jmock:$jmockVersion"
  192     testImplementation "jmock:jmock-cglib:$jmockVersion"
  193     testImplementation "xmlunit:xmlunit:$xmlunitVersion"
  194     testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
  195     testImplementation "log4j:log4j:$log4jVersion"
  196     testImplementation "org.apache.logging.log4j:log4j-core:$log4j2Version"
  197     testImplementation "org.slf4j:jcl-over-slf4j:$slf4jVersion"
  198     testImplementation "com.thoughtworks.qdox:qdox:$qdoxVersion"
  199 
  200     tools "org.pantsbuild:jarjar:$jarjarVersion"
  201     tools "org.jboss.bridger:bridger:$bridgerVersion"
  202 
  203     tools("net.sourceforge.cobertura:cobertura:$coberturaVersion") {
  204         exclude(module: 'asm')
  205         exclude(module: 'asm')
  206         exclude(module: 'ant')
  207     }
  208     tools "org.ow2.asm:asm:$asmVersion"
  209     tools "com.thoughtworks.qdox:qdox:$qdoxVersion"
  210 
  211     antlr2 "org.apache.ant:ant-antlr:$antVersion"
  212 
  213     testImplementation project(':groovy-ant')
  214     testImplementation project(':groovy-xml')
  215     testImplementation project(':groovy-dateutil')
  216     testImplementation project(':groovy-test')
  217     testImplementation project(':groovy-macro')
  218     spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
  219     testImplementation "net.jcip:jcip-annotations:$jcipAnnotationsVersion"
  220 }
  221 
  222 ext.generatedDirectory = "${buildDir}/generated/sources"
  223 
  224 sourceSets {
  225     main {
  226         java {
  227             srcDir "$generatedDirectory/antlr2/src/main"
  228             if (!JavaVersion.current().isJava9Compatible()) {
  229                 exclude '**/v9/*'
  230                 exclude '**/vm9/*'
  231             }
  232         }
  233         groovy {
  234             srcDir "$generatedDirectory/antlr2/src/main"
  235             if (!JavaVersion.current().isJava9Compatible()) {
  236                 exclude '**/v9/*'
  237                 exclude '**/vm9/*'
  238             }
  239         }
  240         resources {
  241             srcDirs = ['src/resources']
  242         }
  243     }
  244     antlr2 {
  245         resources {
  246             srcDirs = ['src/main/antlr2']
  247         }
  248     }
  249     test {
  250         groovy {
  251             srcDirs = ['src/test']
  252             if (!JavaVersion.current().isJava9Compatible()) {
  253                 exclude '**/v9/*'
  254                 exclude '**/vm9/*'
  255             }
  256         }
  257         resources {
  258             srcDirs = ['src/test-resources']
  259         }
  260     }
  261     tools {
  262         compileClasspath = sourceSets.main.runtimeClasspath + configurations.tools
  263         runtimeClasspath = output + compileClasspath
  264     }
  265 }
  266 
  267 task sourceJar(type: Jar) {
  268     classifier = 'sources'
  269     duplicatesStrategy = DuplicatesStrategy.EXCLUDE
  270     from sourceSets.main.allSource
  271     from sourceSets.antlr2.allSource
  272 }
  273 
  274 subprojects {
  275     task sourceJar(type: Jar) {
  276         classifier = 'sources'
  277         duplicatesStrategy = DuplicatesStrategy.EXCLUDE
  278         from sourceSets.main.allSource
  279     }
  280 }
  281 
  282 apply from: 'subprojects/parser-antlr4/build.gradle'
  283 
  284 task ensureGrammars {
  285     outputs.cacheIf { true }
  286     description = 'Ensure all the Antlr2 generated files are up to date.'
  287     ext.antlrDirectory = "$projectDir/src/main/antlr2/org/codehaus/groovy/antlr"
  288     ext.javaParserDirectory = "$ext.antlrDirectory/java"
  289     ext.genPath = "$generatedDirectory/antlr2/src/main/org/codehaus/groovy/antlr"
  290     ext.groovyOutDir = "$ext.genPath/parser"
  291     ext.javaOutDir = "$ext.genPath/java"
  292     inputs.dir(antlrDirectory)
  293     outputs.dir(groovyOutDir)
  294     outputs.dir(javaOutDir)
  295     doFirst {
  296         new File(groovyOutDir).mkdirs()
  297         new File(javaOutDir).mkdirs()
  298         ant {
  299             taskdef(name: 'antlr2',
  300                     classname: 'org.apache.tools.ant.taskdefs.optional.ANTLR',
  301                     classpath: configurations.antlr2.asPath)
  302 
  303             antlr2(target: "$ext.antlrDirectory/groovy.g", outputdirectory: ext.groovyOutDir) {
  304                 classpath path: configurations.compileClasspath.asPath
  305             }
  306             antlr2(target: "$ext.javaParserDirectory/java.g", outputdirectory: ext.javaOutDir) {
  307                 classpath path: configurations.compileClasspath.asPath
  308             }
  309         }
  310     }
  311 }
  312 
  313 compileJava {
  314     dependsOn ensureGrammars, generateGrammarSource
  315     options.fork(memoryMaximumSize: javacMain_mx)
  316 
  317     doLast {
  318         ant.java(classname:'org.jboss.bridger.Bridger', classpath: rootProject.configurations.tools.asPath, outputproperty: 'stdout') {
  319             arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/runtime/DefaultGroovyMethods.class")
  320             arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/runtime/StringGroovyMethods.class")
  321             arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/classgen/Verifier.class")
  322             arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/ast/tools/GeneralUtils.class")
  323         }
  324         ant.echo('Bridger (groovy): ' + ant.properties.stdout)
  325     }
  326 }
  327 
  328 task dgmConverter(dependsOn:compileJava) {
  329     outputs.cacheIf { true }
  330 
  331     description = 'Generates DGM info file required for faster startup.'
  332     def classpath = files(sourceSets.main.output.classesDirs, configurations.compileClasspath)
  333     ext.outputDir = file("$buildDir/dgm")
  334 
  335     //main = 'org.codehaus.groovy.tools.DgmConverter'
  336     //args = ['--info', classesDir.absolutePath]
  337     doFirst {
  338         file("$outputDir/META-INF").mkdirs()
  339         // we use ant.java because Gradle is a bit "too smart" with JavaExec
  340         // as it will invalidate the task if classpath changes, which will
  341         // happen once Groovy files are compiled
  342         ant.java(classname:'org.codehaus.groovy.tools.DgmConverter', classpath: classpath.asPath) {
  343             arg(value: '--info')
  344             arg(value: "$outputDir.absolutePath")
  345         }
  346     }
  347     inputs.files fileTree('src/main').include('**/*GroovyMethods.java')
  348     outputs.dir outputDir
  349 }
  350 
  351     // Gradle classloading magic with Groovy will only work if it finds a *jar*
  352     // on classpath. This "bootstrap jar" contains the minimal compiler, without .groovy compiled files
  353 
  354 task bootstrapJar(type:Jar ) {
  355     dependsOn compileJava, dgmConverter
  356 
  357     from compileJava.destinationDir
  358     from dgmConverter.outputDir
  359 
  360     destinationDir = file("$buildDir/bootstrap")
  361     classifier = 'bootstrap'
  362 }
  363 
  364 allprojects {
  365     dependencies {
  366         compileOnly "com.github.spotbugs:spotbugs-annotations:$spotbugsAnnotationsVersion"
  367     }
  368 
  369     tasks.withType(JavaCompile) {
  370         options.encoding = 'UTF-8'
  371         options.incremental = true
  372         //options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
  373 
  374         if (classpath) {
  375             classpath = classpath + files(dgmConverter.outputDir)
  376         }
  377     }
  378 
  379     if (rootProject.indyCapable()) {
  380         task compileGroovyWithIndy(type: GroovyCompile) {
  381             source = sourceSets.main.groovy
  382             classpath = compileGroovy.classpath
  383             sourceCompatibility = 1.8
  384             targetCompatibility = 1.8
  385             groovyOptions.optimizationOptions['indy'] = true
  386             destinationDir = file("$buildDir/classes/indy")
  387         }
  388     }
  389 
  390     tasks.withType(GroovyCompile) {
  391         groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4.cache.threshold=100"]
  392         groovyOptions.fork(memoryMaximumSize: groovycMain_mx)
  393         groovyOptions.encoding = 'UTF-8'
  394         //options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
  395         groovyClasspath = files(
  396                 rootProject.compileJava.classpath,
  397                 files(project==rootProject?rootProject.bootstrapJar:rootProject.jar)
  398         )
  399 
  400         // TODO: this null check was required after adding JMH plugin to performance project
  401         classpath = (classpath != null) ? classpath + groovyClasspath : groovyClasspath
  402     }.configureEach {
  403         options.incremental = true
  404     }
  405 }
  406 
  407 compileTestGroovy {
  408     groovyOptions.fork(memoryMaximumSize: groovycTest_mx)
  409 }
  410 
  411 task checkCompatibility {
  412     doLast {
  413         assert JavaVersion.current().java9Compatible
  414     }
  415 }
  416 
  417 if (!JavaVersion.current().java9Compatible) {
  418     logger.lifecycle '''
  419     **************************************** WARNING ********************************************
  420     ******   You are running the build with an older JDK. NEVER try to release with 1.8.   ******
  421     ******   You must use a JDK 1.9+ in order to compile all features of the language.     ******
  422     *********************************************************************************************
  423 '''
  424 }
  425 
  426 // Workaround to be able to access SpotBugsTask from external gradle script.
  427 // More info: https://discuss.gradle.org/t/buildscript-dependencies-in-external-script/23243
  428 project.extensions.extraProperties.set('SpotBugsTask', com.github.spotbugs.snom.SpotBugsTask)
  429 
  430 apply from: 'gradle/test.gradle'
  431 apply from: 'gradle/groovydoc.gradle'
  432 apply from: 'gradle/docs.gradle'
  433 apply from: 'gradle/assemble.gradle'
  434 apply from: 'gradle/upload.gradle'
  435 apply from: 'gradle/idea.gradle'
  436 apply from: 'gradle/eclipse.gradle'
  437 apply from: 'gradle/quality.gradle'
  438 apply from: 'gradle/parallel-build-fixes.gradle'
  439 
  440 // If a local configuration file for tweaking the build is present, apply it
  441 if (file('user.gradle').exists()) {
  442     apply from: 'user.gradle'
  443 }
  444 
  445 apply from: 'gradle/signing.gradle'
  446 
  447 licenseReport {
  448     excludeGroups = [
  449             'com.googlecode', // openbeans has no pom but is ASLv2
  450             'org.multiverse'  // we never include this optional dependency of an optional dependency
  451     ]
  452 }
  453 
  454 // UNCOMMENT THE FOLLOWING TASKS IF YOU WANT TO RUN LICENSE CHECKING
  455 //task licenseFormatCustom(type:nl.javadude.gradle.plugins.license.License) {
  456 //    source = fileTree(dir:"src").include ("**/*.java",'**/*.groovy','**/*.html','**/*.css','**/*.xml','**/*.properties','**/*.properties')
  457 //}
  458 //
  459 //task licenseFormatGradle(type:nl.javadude.gradle.plugins.license.License) {
  460 //    source = files(fileTree(dir:projectDir).include('**/*.gradle'),fileTree('buildSrc').include('**/*.groovy'))
  461 //}
  462 //
  463 //licenseFormat.dependsOn licenseFormatCustom
  464 //licenseFormat.dependsOn licenseFormatGradle
  465 //
  466 
  467 def checkRepo(repo) {
  468     if (repo instanceof MavenArtifactRepository) {
  469         def repoUrl = repo.url.toString()
  470         if (repoUrl.startsWith("http://")) {
  471             throw new GradleException("Build should not use insecure HTTP-based URLs for repositories. Found: " + repoUrl)
  472         }
  473     }
  474 }
  475 
  476 project.afterEvaluate {
  477     allprojects.repositories.each { handler ->
  478         handler.each { checkRepo(it) }
  479     }
  480     buildscript.repositories.each { handler ->
  481         handler.each { checkRepo(it) }
  482     }
  483 }