| apply from: 'gradle/filter.gradle' |
| apply from: 'gradle/indy.gradle' |
| if (JavaVersion.current().java6Compatible) { |
| apply from: 'gradle/bintray.gradle' |
| } |
| |
| buildscript { |
| repositories { |
| jcenter() |
| maven { |
| name 'Bintray Asciidoctor repo' |
| url 'http://dl.bintray.com/content/aalmiray/asciidoctor' |
| } |
| } |
| |
| dependencies { |
| classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.5.0' |
| classpath 'net.saliman:gradle-cobertura-plugin:1.1.2' |
| classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3' |
| } |
| } |
| |
| File javaHome = new File(System.getProperty('java.home')) |
| logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})" |
| |
| // TODO use antlr plugin |
| //apply plugin: 'antlr' |
| |
| allprojects { |
| apply plugin: 'java' |
| |
| buildDir = 'target' |
| sourceCompatibility = 1.5 |
| targetCompatibility = 1.5 |
| |
| group = 'org.codehaus.groovy' |
| version = groovyVersion |
| repositories { |
| jcenter() |
| } |
| |
| apply plugin: 'checkstyle' |
| apply plugin: 'groovy' |
| apply plugin: 'codenarc' |
| apply from: "${rootProject.projectDir}/gradle/groovydoc.gradle" |
| apply from: "${rootProject.projectDir}/gradle/indy.gradle" |
| |
| if (isJava15()) { |
| // do nothing on JDK 5 as gradle fails to create a proxy for the AsciidoctorTask |
| logger.warn 'You must run on JDK 6+ to be able to generate the Asciidoc documentation.' |
| } else { |
| apply plugin: 'asciidoctor' |
| |
| asciidoctor { |
| logDocuments = true |
| sourceDir = project.file('src/spec/doc') |
| } |
| |
| // skip the asciidoctor task if there's no directory with asciidoc files |
| asciidoctor.onlyIf { project.file('src/spec/doc').exists() } |
| } |
| |
| // don't fail build on CodeNarc tasks |
| tasks.withType(CodeNarc) { |
| ignoreFailures = true |
| configFile = file("$rootProject.projectDir/config/codenarc/codenarc.groovy") |
| } |
| tasks.withType(Checkstyle) { |
| ignoreFailures = true |
| configFile = file("$rootProject.projectDir/config/checkstyle/checkstyle.xml") |
| } |
| |
| if (useIndy()) { |
| tasks.withType(GroovyCompile) { |
| groovyOptions.optimizationOptions.indy = true |
| groovyClasspath = files( |
| rootProject.compileJava.destinationDir, |
| rootProject.compileJava.classpath, |
| { project(':groovy-docgenerator').compileJava.destinationDir }, |
| { project(':groovy-groovydoc').compileJava.destinationDir }, |
| { project(':groovy-ant').compileJava.destinationDir }, |
| { project(':groovy-templates').compileJava.destinationDir }, |
| ) |
| } |
| |
| compileJava.sourceCompatibility = 1.7 |
| compileJava.targetCompatibility = 1.7 |
| jar { |
| classifier = 'indy' |
| } |
| } |
| } |
| |
| // todo: use the conventional "resources" directory for classpath resources |
| task(copyResources, type: Copy) { |
| destinationDir = file("$buildDir/classes") |
| // text files requiring filtering |
| into('main') { |
| from('src/main') |
| include('**/*.txt', '**/*.xml', '**/*.properties', '**/*.html') |
| filter(rootProject.propertiesFilter, org.apache.tools.ant.filters.ReplaceTokens) |
| } |
| // other resources |
| into('main') { |
| from 'src/main' |
| include('**/*.png', '**/*.gif', '**/*.ico', '**/*.css') |
| } |
| } |
| compileJava.dependsOn(copyResources) |
| task(copyTestResources, type: Copy) |
| .from('src/test') |
| .into("$buildDir/classes/test") |
| .include('**/*.txt', '**/*.xml', '**/*.properties', '**/*.png', '**/*.html', '**/*.gif', '**/*.ico', '**/*.css') |
| compileTestJava.dependsOn(copyTestResources) |
| |
| task sourceJar(type: Jar) { |
| classifier = 'sources' |
| from 'src/main' |
| } |
| |
| subprojects { |
| task sourceJar(type: Jar) { |
| classifier = 'sources' |
| from sourceSets.main.allSource |
| } |
| } |
| |
| repositories { |
| // todo Some repos are needed only for some configs. Declare them just for the configuration once Gradle allows this. |
| // mavenCentral() // default, tools |
| maven { url 'http://www.aQute.biz/repo' } // tools |
| maven { url 'http://repository.jboss.org/maven2' } // examples, tools |
| } |
| |
| // todo do we need compile and runtime scope for examples? |
| configurations { |
| compilerCompile |
| tools |
| examplesCompile.extendsFrom compile |
| examplesRuntime.extendsFrom examplesCompile |
| antlr |
| spec |
| } |
| |
| dependencies { |
| def antVersion = '1.9.2' |
| def asmVersion = '4.1' |
| def antlrVersion = '2.7.7' |
| def bndVersion = '0.0.401' |
| def checkstyleVersion = '4.4' |
| def coberturaVersion = '1.9.4.1' |
| def commonsCliVersion = '1.2' |
| def commonsHttpClientVersion = '3.1' |
| def eclipseOsgiVersion = '3.5.0.v20090520' |
| def gparsVersion = '1.1.0' |
| def ivyVersion = '2.3.0' |
| def jansiVersion = '1.10' |
| def jarjarVersion = '1.3' |
| def jmockVersion = '1.2.0' |
| def logbackVersion = '0.9.21' |
| def log4jVersion = '1.2.16' |
| def log4j2Version = '2.0-beta9' |
| def luceneVersion = '4.3.1' |
| def openejbVersion = '1.0' |
| def qdoxVersion = '1.12.1' |
| def simianVersion = '2.2.4' |
| def slf4jVersion = '1.6.0' |
| def xmlunitVersion = '1.3' |
| def xstreamVersion = '1.4.4' |
| |
| compilerCompile "antlr:antlr:$antlrVersion" |
| compilerCompile "org.ow2.asm:asm:$asmVersion" |
| compilerCompile "org.ow2.asm:asm-analysis:$asmVersion" |
| compilerCompile "org.ow2.asm:asm-commons:$asmVersion" |
| compilerCompile "org.ow2.asm:asm-tree:$asmVersion" |
| compilerCompile "org.ow2.asm:asm-util:$asmVersion" |
| |
| compilerCompile "commons-cli:commons-cli:$commonsCliVersion" |
| compilerCompile "org.apache.ant:ant:$antVersion" |
| compilerCompile("com.thoughtworks.xstream:xstream:$xstreamVersion") { |
| exclude(group: 'xpp3', module: 'xpp3_min') |
| exclude(group: 'junit', module: 'junit') |
| exclude(group: 'jmock', module: 'jmock') |
| } |
| compilerCompile "org.fusesource.jansi:jansi:$jansiVersion" |
| compilerCompile("org.apache.ivy:ivy:$ivyVersion") { |
| transitive = false |
| } |
| compilerCompile files("$buildDir/classes/compiler") |
| |
| groovy files("$buildDir/classes/compiler") |
| groovy "antlr:antlr:$antlrVersion" |
| groovy "org.ow2.asm:asm:$asmVersion" |
| groovy "org.ow2.asm:asm-analysis:$asmVersion" |
| groovy "org.ow2.asm:asm-commons:$asmVersion" |
| groovy "org.ow2.asm:asm-tree:$asmVersion" |
| groovy "org.ow2.asm:asm-util:$asmVersion" |
| |
| compile "commons-cli:commons-cli:$commonsCliVersion" |
| compile("com.thoughtworks.xstream:xstream:$xstreamVersion") { |
| exclude(group: 'xpp3', module: 'xpp3_min') |
| exclude(group: 'junit', module: 'junit') |
| exclude(group: 'jmock', module: 'jmock') |
| } |
| compile "org.fusesource.jansi:jansi:$jansiVersion" |
| compile("org.apache.ivy:ivy:$ivyVersion") { |
| transitive = false |
| } |
| runtime "org.codehaus.gpars:gpars:$gparsVersion" |
| testCompile "jmock:jmock:$jmockVersion" |
| testCompile "jmock:jmock-cglib:$jmockVersion" |
| testCompile "xmlunit:xmlunit:$xmlunitVersion" |
| testCompile "ch.qos.logback:logback-classic:$logbackVersion" |
| testCompile "log4j:log4j:$log4jVersion" |
| testCompile "org.apache.logging.log4j:log4j-core:$log4j2Version" |
| testCompile "org.slf4j:jcl-over-slf4j:$slf4jVersion" |
| testCompile "com.thoughtworks.qdox:qdox:$qdoxVersion" |
| |
| tools "com.googlecode.jarjar:jarjar:$jarjarVersion" |
| tools("checkstyle:checkstyle:$checkstyleVersion") { |
| exclude(module: 'junit') |
| } |
| tools "redhill:simian:$simianVersion" |
| tools("net.sourceforge.cobertura:cobertura:$coberturaVersion") { |
| exclude(module: 'asm') |
| exclude(module: 'asm') |
| exclude(module: 'ant') |
| } |
| tools "org.ow2.asm:asm-all:$asmVersion" |
| tools "com.thoughtworks.qdox:qdox:$qdoxVersion" |
| tools "biz.aQute:bnd:$bndVersion" |
| |
| examplesCompile project(':groovy-test') |
| examplesCompile project(':groovy-swing') |
| examplesCompile "org.apache.lucene:lucene-core:$luceneVersion" |
| examplesCompile "org.apache.lucene:lucene-analyzers-common:$luceneVersion" |
| examplesCompile "org.apache.lucene:lucene-queryparser:$luceneVersion" |
| examplesCompile "org.eclipse:osgi:$eclipseOsgiVersion" |
| examplesRuntime("commons-httpclient:commons-httpclient:$commonsHttpClientVersion") { |
| exclude(module: 'junit') |
| exclude(module: 'commons-logging') |
| exclude(module: 'commons-codec') |
| } |
| examplesRuntime("openejb:openejb-loader:$openejbVersion") { |
| exclude(module: 'log4j') |
| exclude(module: 'openejb-core') |
| exclude(module: 'geronimo-jta_1.0.1B_spec') |
| exclude(module: 'geronimo-servlet_2.4_spec') |
| exclude(module: 'geronimo-ejb_2.1_spec') |
| exclude(module: 'geronimo-j2ee-connector_1.5_spec') |
| } |
| |
| // TODO use antlr plugin |
| // antlr 'antlr:antlr:2.7.7' |
| antlr "org.apache.ant:ant-antlr:$antVersion" |
| |
| // TODO remove once M12N refactoring finished |
| testCompile project(':groovy-ant') |
| testCompile project(':groovy-test') |
| } |
| |
| ext.generatedDirectory = "${buildDir}/generated-sources" |
| |
| sourceSets { |
| compiler { |
| // This sourceSet corresponds to the minimal "bootstrap" Groovy compiler |
| // which will be used by the build itself to compile the groovy files |
| java { |
| srcDirs = [ |
| 'src/main', |
| 'subprojects/groovy-ant/src/main', |
| 'subprojects/groovy-groovydoc/src/main', |
| 'subprojects/groovy-templates/src/main', |
| 'subprojects/groovy-xml/src/main', |
| 'subprojects/groovy-jmx/src/main', |
| "$generatedDirectory/src/main" |
| ] |
| if (!useIndy()) { |
| exclude '**/indy/*' |
| exclude '**/v7/*' |
| exclude '**/vm7/*' |
| } |
| } |
| } |
| main { |
| java { |
| srcDirs = [ |
| 'src/main', |
| "$generatedDirectory/src/main" |
| ] |
| fileTree('src/main/groovy/ui').matching { |
| exclude 'GroovyMain.java', 'GroovySocketServer.java' |
| }.visit { details -> |
| exclude "groovy/ui/$details.path" |
| } |
| if (!useIndy()) { |
| exclude '**/indy/*' |
| exclude '**/v7/*' |
| exclude '**/vm7/*' |
| } |
| } |
| groovy { |
| srcDirs = [ |
| 'src/main', |
| "$generatedDirectory/src/main" |
| ] |
| if (!useIndy()) { |
| exclude '**/indy/*' |
| exclude '**/v7/*' |
| exclude '**/vm7/*' |
| } |
| } |
| resources { |
| srcDirs = ['src/main', 'src/tools', 'src/resources'] |
| include 'META-INF/services/*', |
| 'META-INF/groovy-release-info.properties', |
| 'groovy/grape/*.xml', |
| 'groovy/ui/*.properties', |
| 'groovy/ui/**/*.png', |
| 'groovy/inspect/swingui/AstBrowserProperties.groovy', |
| 'org/codehaus/groovy/tools/shell/**/*.properties', |
| 'org/codehaus/groovy/tools/shell/**/*.xml', |
| 'org/codehaus/groovy/tools/groovydoc/gstringTemplates/**/*.*', |
| 'org/codehaus/groovy/tools/groovy.ico' |
| } |
| } |
| test { |
| groovy { |
| srcDirs = ['src/test'] |
| } |
| resources { |
| srcDirs = ['src/test-resources'] |
| } |
| output.classesDir = "$buildDir/test-classes" as File |
| } |
| tools { |
| groovy { |
| srcDirs = ['src/tools'] |
| } |
| resources { |
| srcDirs = ['src/tools'] |
| } |
| compileClasspath = configurations.tools + sourceSets.main.runtimeClasspath |
| runtimeClasspath = output + compileClasspath |
| output.classesDir = "$buildDir/tools-classes" as File |
| } |
| examples { |
| groovy { |
| srcDirs = ['src/examples'] |
| } |
| resources { |
| srcDirs = ['src/examples'] |
| } |
| compileClasspath = configurations.examplesRuntime + sourceSets.main.output |
| output.classesDir = "$buildDir/examples-classes" as File |
| } |
| } |
| |
| // make sure examples can be compiled, even if we don't run them |
| // todo: reorganize examples so that we can run them too |
| check { |
| dependsOn examplesClasses |
| } |
| |
| // remove this from config once GRADLE-854 is fixed. |
| processResources.doLast { |
| copy { |
| from('src/main') { |
| include 'groovy/inspect/swingui/AstBrowserProperties.groovy', |
| 'org/codehaus/groovy/tools/groovydoc/gstringTemplates/GroovyDocTemplateInfo.java' |
| } |
| into sourceSets.main.output.classesDir |
| } |
| } |
| |
| task ensureGrammars { |
| description = 'Ensure all the Antlr generated files are up to date.' |
| ext.antlrDirectory = "$projectDir/src/main/org/codehaus/groovy/antlr" |
| ext.groovyParserDirectory = "$ext.antlrDirectory/parser" |
| ext.javaParserDirectory = "$ext.antlrDirectory/java" |
| ext.genPath = "$generatedDirectory/src/main/org/codehaus/groovy/antlr" |
| ext.groovyOutDir = "$ext.genPath/parser" |
| ext.javaOutDir = "$ext.genPath/java" |
| inputs.dir(antlrDirectory) |
| outputs.dir(groovyOutDir) |
| outputs.dir(javaOutDir) |
| doFirst { |
| new File(groovyOutDir).mkdirs() |
| new File(javaOutDir).mkdirs() |
| ant { |
| taskdef(name: 'antlr', |
| classname: 'org.apache.tools.ant.taskdefs.optional.ANTLR', |
| classpath: configurations.antlr.asPath) |
| |
| mkdir dir: ext.groovyParserDirectory |
| antlr(target: "$ext.antlrDirectory/groovy.g", outputdirectory: ext.groovyOutDir) { |
| classpath path: configurations.compile.asPath |
| } |
| antlr(target: "$ext.javaParserDirectory/java.g", outputdirectory: ext.javaOutDir) { |
| classpath path: configurations.compile.asPath |
| } |
| } |
| } |
| } |
| |
| apply from: 'gradle/utils.gradle' |
| |
| def isJava16() { |
| System.properties['java.version'].contains('1.6') |
| } |
| |
| def isJava15() { |
| System.properties['java.version'].contains('1.5') |
| } |
| |
| def modules() { |
| subprojects.findAll { it.name =~ /groovy-(?!all-tests)/ } |
| } |
| |
| // provide to other build scripts |
| ext.isJava6 = this.&isJava16() |
| ext.isJava5 = this.&isJava15() |
| ext.modules = this.&modules() |
| |
| task dgmConverter(type: JavaExec, dependsOn: 'classes') { |
| description = 'Generates DGM info file required for faster startup.' |
| ext.classesDir = sourceSets.main.output.classesDir |
| classpath = files(classesDir) + configurations.compile |
| main = 'org.codehaus.groovy.tools.DgmConverter' |
| args = ['--info', classesDir.absolutePath] |
| doFirst { |
| file("$classesDir/META-INF").mkdirs() |
| } |
| inputs.files fileTree(dir: projectDir, includes: ['src/**/*GroovyMethods.java']) |
| outputs.file file("$classesDir/META-INF/dgminfo") |
| } |
| |
| task compilerDgmConverter(type: JavaExec) { |
| description = 'Generates DGM info file for the bootstrap compiler' |
| ext.compilerClassesDir = sourceSets.compiler.output.classesDir |
| classpath = files(compilerClassesDir) + configurations.compilerCompile |
| main = 'org.codehaus.groovy.tools.DgmConverter' |
| args = ['--info', compilerClassesDir.absolutePath] |
| doFirst { |
| file("$compilerClassesDir/META-INF").mkdirs() |
| } |
| inputs.files fileTree(dir: projectDir, includes: ['src/**/*GroovyMethods.java']) |
| outputs.file file("$compilerClassesDir/META-INF/dgminfo") |
| } |
| |
| compileCompilerJava { |
| dependsOn ensureGrammars, exceptionUtils |
| options.fork(memoryMaximumSize: javacMain_mx) |
| } |
| |
| compileJava { |
| dependsOn compilerClasses, compilerDgmConverter, ensureGrammars |
| options.fork(memoryMaximumSize: javacMain_mx) |
| } |
| |
| compileGroovy { |
| doFirst { |
| if (useIndy()) { |
| logger.info('Building with InvokeDynamic support activated') |
| } |
| } |
| groovyOptions.fork(memoryMaximumSize: groovycMain_mx) |
| } |
| |
| compileTestGroovy { |
| groovyOptions.fork(memoryMaximumSize: groovycTest_mx) |
| } |
| |
| compileExamplesGroovy { |
| groovyOptions.fork(memoryMaximumSize: groovycExamples_mx) |
| } |
| |
| // suppress CheckStyle/CodeNarc |
| task checkstyleExamples(overwrite: true) << {} |
| task checkstyleMain(overwrite: true) << {} |
| task checkstyleTest(overwrite: true) << {} |
| task checkstyleTools(overwrite: true) << {} |
| task codenarcExamples(overwrite: true) << {} |
| |
| apply from: 'gradle/test.gradle' |
| apply from: 'gradle/docs.gradle' |
| apply from: 'gradle/assemble.gradle' |
| apply from: 'gradle/upload.gradle' |
| apply from: 'gradle/idea.gradle' |
| apply from: 'gradle/eclipse.gradle' |
| // Define a GroovyDoc task which depends on the generated groovydoc tool |
| apply from: 'gradle/groovydoc.gradle' |
| if (isJava15()) { |
| // do nothing on JDK 5 as sardine is built for Java 6 |
| logger.warn 'You must run on JDK 6+ to be able to deploy to codehaus.' |
| } else { |
| apply from: 'gradle/codehaus.gradle' |
| } |
| |
| classes { |
| doFirst { |
| logger.lifecycle "InvokeDynamic support ${useIndy() ? 'on' : 'off'}" |
| } |
| } |
| |
| // If a local configuration file for tweaking the build is present, apply it |
| if (file('user.gradle').exists()) { |
| apply from: 'user.gradle' |
| } |
| |
| allprojects { |
| apply plugin: 'cobertura' |
| cobertura { |
| coverageFormats = ['xml', 'html'] |
| coverageReportDir = file("$buildDir/reports/cobertura") |
| } |
| } |
| |
| wrapper { |
| gradleVersion = '1.7' |
| } |
| |
| // produce warning if running on 1.5 or 1.6 |
| if (isJava15() || isJava16()) { |
| logger.lifecycle ''' |
| **************************************** WARNING ********************************************** |
| ****** You are running the build with an older JDK. NEVER try to release with 1.5 or 1.6 ****** |
| ****** You must use a JDK 1.7+ in order to compile all features of the language. ****** |
| *********************************************************************************************** |
| ''' |
| } |