buildscript { repositories { maven { url "https://repo.grails.org/grails/core" } maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "commons-io:commons-io:2.11.0" classpath "io.github.gradle-nexus:publish-plugin:1.1.0" classpath "com.netflix.nebula:gradle-extra-configurations-plugin:7.0.0" classpath "com.github.adrianbk:gradle-travisci-trigger-plugin:1.0.0" classpath "com.bmuschko:gradle-nexus-plugin:$gradleNexusPluginVersion" classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:$gradleSdkVendorVersion" classpath "javax.xml.bind:jaxb-api:$jaxbVersion" classpath "com.sun.xml.bind:jaxb-impl:$jaxbVersion" classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.2" classpath "org.gradle:test-retry-gradle-plugin:1.3.1" } } import static groovyx.net.http.ContentType.* apply plugin: 'idea' ext { isJava8Compatible = org.gradle.api.JavaVersion.current().isJava8Compatible() grailsVersion = project.projectVersion groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion isBuildSnapshot = grailsVersion.endsWith("-SNAPSHOT") isReleaseVersion = !isBuildSnapshot isCiBuild = System.getenv().get("TRAVIS") == 'true' || System.getenv().get("CI") as Boolean springLoadedCommonOptions = "-Xverify:none -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true" dependencyVersions = [ 'javax.annotation-api': [ version: javaxAnnotationApiVersion, group:'javax.annotation', names:['javax.annotation'], modules:['api'] ], 'jakarta-annotation': [ version: jakartaAnnotationApiVersion, group:'jakarta.annotation', names:['jakarta.annotation-api'], modules:[''] ], 'micronaut': [ version: micronautVersion, group:'io.micronaut', names:['micronaut'], modules:['aop', 'bom', 'inject','runtime', 'inject-groovy', 'inject-java', 'core', 'http-client', 'http', 'buffer-netty', 'http-netty'] ], 'micronaut.cache': [ version: micronautCacheVersion, group: 'io.micronaut.cache', names:['micronaut-cache'], modules:['core'] ], 'micronaut.micronaut-runtime-groovy': [ version: micronautRuntimeGroovyVersion, group:'io.micronaut', names:['micronaut'], modules:['runtime-groovy'] ], 'micronaut.spring': [ version: micronautSpringVersion, group:'io.micronaut.spring', names:['micronaut-spring'], modules:['spring', 'context','boot', 'web', 'boot-annotation', 'annotation', 'web-annotation'] ], 'mongodb': [ version: mongodbJavaDriverVersion, group: 'org.mongodb', names: ['mongodb-driver'], modules: ['core', 'sync'] ], gorm: [ version: datastoreVersion, group : 'org.grails', names : ['grails-datastore'], modules: ['async','core', 'web', 'gorm','gorm-async','gorm-support', 'gorm-rx', 'gorm-test', 'gorm-validation'] ], 'gorm.hibernate': [ version: hibernateDatastoreVersion, group : 'org.grails', names : ['grails-datastore-gorm-hibernate5'], modules: [''] ], 'scaffolding-core': [ version: scaffoldingCoreVersion, group : 'org.grails', names : ['scaffolding'], modules: ['core'] ], groovy: [ version: groovyVersion, group : 'org.codehaus.groovy', names : ['groovy'], modules: ['', 'xml', 'swing', 'console', 'json', 'ant', 'sql', 'templates', 'nio', 'dateutil', 'macro'] ], spring: [ version: springVersion, group : 'org.springframework', names : ['spring'], modules: ['aop', 'aspects', 'beans', 'context-support', 'context', 'core', 'expression', 'instrument', 'jdbc', 'jms', 'messaging', 'orm', 'oxm', 'test', 'tx', 'web', 'webmvc', 'websocket'] ], directoryWatcher: [ version: directoryWatcherVersion, group : 'io.methvin', names : ['directory-watcher'], modules: [''] ], springLoaded: [ version: springLoadedVersion, group : 'org.springframework', names : ['springloaded'], modules: [''] ], async: [ version: asyncVersion, group : 'org.grails.plugins', names : ['async', 'events'], modules: [''] ], asyncImpls: [ version: asyncVersion, group : 'org.grails', names : ['grails-async', 'grails-events'], modules: ['gpars', 'rxjava', 'rxjava2'] ], spock: [ version: spockVersion, group : 'org.spockframework', names : ['spock-core', 'spock-spring'], modules: [''] ], gsp: [ version: gspVersion, group : 'org.grails.plugins', names : ['gsp'], modules: [''] ], testingSupport: [ version: testingSupportVersion, group : 'org.grails', names : ['grails-testing-support', 'grails-gorm-testing-support', 'grails-web-testing-support'], modules: [''] ], 'views-json-testing-support': [ version: viewsVersion, group : 'org.grails', names : ['views-json-testing-support'], modules: [''] ], h2: [ version: h2Version, group : 'com.h2database', names : ['h2'], modules: [''] ], ] nexusUsername = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : '' nexusPassword = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : '' } version = grailsVersion group = "org.grails" // directories created during the build which are related // to turning the workspace root into a GRAILS_HOME ext { distInstallDir = file("$buildDir/dist-tmp") homeDistDir = file("dist") homeBinDir = file("bin") homeConfDir = file("conf") homeLibDir = file("lib") homeSrcDir = file("src") } // Groovy is added as a dependency to both the 'groovy' and 'compile' // configurations, so place the dependency in a shared variable. The // 'compile' is required so that Groovy appears as a dependency in the // artifacts' POMs. ext.jointBuildGroovyJarProperty = System.getProperty('groovy.jar') ext.groovyDependency = null ext."signing.keyId" = System.getenv("SIGNING_KEY") ?: project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : null ext."signing.password" = System.getenv("SIGNING_PASSPHRASE") ?: project.hasProperty("signing.password") ? project.getProperty('signing.password') : null ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : null if (jointBuildGroovyJarProperty) { def jointBuildGroovyJar = file(jointBuildGroovyJarProperty) if (jointBuildGroovyJar.exists()) { groovyDependency = dependencies.create(files(jointBuildGroovyJar)) } else { throw new GradleException("The groovy.jar system property points to ${jointBuildGroovyJar.absolutePath} which does not exist.") } } else { groovyDependency = dependencies.create("org.codehaus.groovy:groovy:${groovyVersion}") { exclude module:"commons-cli" exclude module:"ant" } } if (isReleaseVersion) { apply plugin: 'maven-publish' apply plugin: "io.github.gradle-nexus.publish-plugin" nexusPublishing { repositories { sonatype { def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : '' def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : '' def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : '' username = ossUser password = ossPass stagingProfileId = ossStagingProfileId } } } } allprojects { repositories { mavenLocal() maven { url "https://repo.grails.org/grails/core" } maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } if(groovyVersion.endsWith('-SNAPSHOT')) { maven { name 'JFrog OSS snapshot repo' url 'https://oss.jfrog.org/oss-snapshot-local/' } } } configurations { all { resolutionStrategy { def cacheHours = isCiBuild ? 0 : 24 cacheDynamicVersionsFor cacheHours, 'hours' cacheChangingModulesFor cacheHours, 'hours' eachDependency { DependencyResolveDetails details -> //specifying a fixed version for all libraries with 'org.gradle' group if (details.requested.group == 'org.codehaus.groovy') { details.useVersion groovyVersion } if (details.requested.group == "org.spockframework") { details.useVersion(spockVersion) } } } } } [Javadoc, Groovydoc].each { tasks.withType(it).all { // exclude problematic jar file from javadoc classpath // http://www.adam-bien.com/roller/abien/entry/trouble_with_crippled_java_ee if (classpath) { classpath -= classpath.filter { it.name == 'javaee-web-api-6.0.jar' } } // this will apply the javadoc fix tool to all generated javadocs // we use it to make sure that the javadocs are not vulnerable independently of the JDK used to build doLast { def javadocFix = new JavadocFixTool() javadocFix.recursive = true javadocFix.doPatch = true javadocFix.searchAndPatch(destinationDir) } } } tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') } } apply from: "gradle/idea.gradle" subprojects { project -> version = grailsVersion group = "org.grails" configurations { documentation } ext.isTestSuite = project.name.startsWith("grails-test-suite") ext.isCiBuild = project.hasProperty("isCiBuild") || System.getenv().get("CI") as Boolean ext.pomInfo = { delegate.name 'Grails' delegate.description 'Grails Web Application Framework' delegate.url 'http://grails.org/' delegate.licenses { delegate.license { delegate.name 'The Apache Software License, Version 2.0' delegate.url 'http://www.apache.org/licenses/LICENSE-2.0.txt' delegate.distribution 'repo' } } delegate.scm { delegate.url 'scm:git@github.com:grails/grails-core.git' delegate.connection 'scm:git@github.com:grails/grails-core.git' delegate.developerConnection 'scm:git@github.com:grails/grails-core.git' } delegate.developers { delegate.developer { delegate.id 'graemerocher' delegate.name 'Graeme Rocher' } delegate.developer { delegate.id 'jeffscottbrown' delegate.name 'Jeff Brown' } delegate.developer { delegate.id 'lhotari' delegate.name 'Lari Hotari' } } } if(!project.hasProperty("artifactoryPublishPassword") && System.getenv("ARTIFACTORY_PASSWORD")) { project.ext.artifactoryPublishPassword = System.getenv("ARTIFACTORY_PASSWORD") } apply plugin: 'java-library' apply plugin: 'groovy' if(!isTestSuite) { apply plugin: 'com.bmuschko.nexus' apply plugin: 'maven-publish' apply plugin: 'signing' } apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'project-report' apply plugin: 'nebula.optional-base' apply plugin: "org.gradle.test-retry" if (!isTestSuite) { modifyPom { delegate.project { def updatePom = pomInfo.clone() updatePom.delegate = delegate updatePom() } } publishing { if (isBuildSnapshot) { repositories { maven { credentials { def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : '' def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : '' username = u password = p } url "https://repo.grails.org/grails/libs-snapshots-local" } } } if(project.name == 'grails-dependencies') return if(project.name == 'grails-bom') return publications { maven(MavenPublication) { from components.java afterEvaluate { artifact source: sourcesJar, classifier: "sources" artifact source: javadocJar, classifier: "javadoc" } pom.withXml { def xml = asNode() xml.children().last() + pomInfo } } } } afterEvaluate { signing { required { isReleaseVersion && gradle.taskGraph.hasTask("publish") } sign publishing.publications.maven } } tasks.withType(Sign) { onlyIf { isReleaseVersion } } //do not generate extra load on Nexus with new staging repository if signing fails tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach { shouldRunAfter(tasks.withType(Sign)) } } if(project.name == 'grails-dependencies') return if(project.name == 'grails-bom') return sourceCompatibility = "1.8" targetCompatibility = "1.8" if(project.name =~ /^(grails-web|grails-plugin-|grails-test-suite|grails-test)/) { dependencies { api "javax.servlet:javax.servlet-api:$servletApiVersion" // MockHttpServletRequest/Response/Context used in many classes api("org.springframework:spring-test:${springVersion}") { exclude group: 'commons-logging', module:'commons-logging' } } } if(project.name =~ /^(grails-plugin-datasource|grails-test-suite)/) { dependencies { api 'hsqldb:hsqldb:1.8.1.1' api "com.h2database:h2:$h2Version" } } jar{ manifest.mainAttributes( "Built-By": System.properties['user.name'], "Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", "Implementation-Title": "Grails", "Implementation-Version": grailsVersion, "Implementation-Vendor": 'grails.org') } configure([compileGroovy, compileTestGroovy]) { groovyOptions.fork(memoryInitialSize: '128M', memoryMaximumSize: '1G') groovyOptions.encoding = "UTF-8" options.encoding = "UTF-8" } configure([compileJava, compileTestJava]) { options.deprecation = true options.debug = true } configure([groovydoc]) { onlyIf({ !isTestSuite }) classpath += configurations.documentation } configure([javadoc]) { onlyIf { !isTestSuite } options.encoding "UTF-8" options.docEncoding "UTF-8" options.charSet "UTF-8" options.jFlags "-Xms64M", "-Xmx512M" } dependencies { documentation("org.fusesource.jansi:jansi:$jansiVersion") documentation("jline:jline:$jlineVersion") documentation "org.codehaus.groovy:groovy-ant:$groovyVersion" documentation "org.codehaus.groovy:groovy-cli-picocli:$groovyVersion" documentation ("com.github.javaparser:javaparser-core:$javaParserCoreVersion") api groovyDependency testImplementation "org.codehaus.groovy:groovy-test-junit5:${groovyVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1" testImplementation "org.junit.platform:junit-platform-runner:1.8.1" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1" if (project.name != "grails-docs") { // Logging api "org.slf4j:slf4j-api:$slf4jVersion" api "org.slf4j:jcl-over-slf4j:$slf4jVersion" // Testing testImplementation "org.slf4j:slf4j-simple:$slf4jVersion" testImplementation("org.spockframework:spock-core:${spockVersion}") { transitive = false } // Required by Spock's Mocking testImplementation "cglib:cglib-nodep:${cglibVersion}" testImplementation "org.objenesis:objenesis:${objenesisVersion}" } } def debugArguments = ['-Xmx2g', '-Xdebug', '-Xnoagent', '-Djava.compiler=NONE', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'] tasks.withType(Test) { useJUnitPlatform() } test { retry { maxRetries = 2 maxFailures = 20 failOnPassedAfterRetry = true } testLogging { events "passed", "skipped", "failed" showExceptions true exceptionFormat "full" showCauses true showStackTraces true } excludes = ["**/*TestCase.class", "**/*\$*.class"] if (isCiBuild) { maxParallelForks = 2 maxHeapSize = '768m' afterSuite { System.out.print('.') System.out.flush() } } else { maxHeapSize = '1024m' } if(System.getProperty("debug.tests")) { jvmArgs debugArguments } } task singleTest(type: Test) { // task for running a single test with -DsingleTest.single=TestName singleTest if(System.getProperty("debug.tests")) { jvmArgs debugArguments } } configurations { meta published.extendsFrom archives, meta all*.exclude group:'commons-logging', module: 'commons-logging' } if(!isTestSuite) { task installToHomeDist(type: Upload) { configuration = configurations.archives repositories { flatDir name: 'libs', dirs: distInstallDir } } project.tasks.withType(org.gradle.api.publish.maven.tasks.PublishToMavenLocal) { org.gradle.api.publish.maven.tasks.PublishToMavenLocal t -> t.dependsOn installToHomeDist t.doLast { ant.copy(todir: homeDistDir, flatten: true, includeEmptyDirs: false) { fileset dir: distInstallDir } } } } } task clean(type: Delete, group: 'build') { delete buildDir, homeBinDir, homeConfDir, homeDistDir, homeLibDir, homeSrcDir } // From this point on we need the subprojects to be fully configured, so force their full evaluation subprojects.each { if (it.tasks.findByName('install') && it.tasks.findByName('publishToMavenLocal')) { it.tasks.findByName('install').finalizedBy(it.tasks.findByName('publishToMavenLocal')) } evaluationDependsOn it.path } apply { from 'gradle/docs.gradle' // tasks for building the documentation (e.g. user guide, javadocs) from 'gradle/assemble.gradle' // tasks for creating an installation or distribution from 'gradle/findbugs.gradle' } apply plugin: "com.github.adrianbk.tcitrigger" tciTrigger { gitHubRepo 'grails/grails3-functional-tests' } task buildscriptDependencies(type: org.gradle.api.tasks.diagnostics.DependencyReportTask) { configurations = project.buildscript.configurations } [Javadoc, Groovydoc].each { tasks.withType(it).all { // exclude problematic jar file from javadoc classpath // http://www.adam-bien.com/roller/abien/entry/trouble_with_crippled_java_ee if (classpath) { classpath -= classpath.filter { it.name == 'javaee-web-api-6.0.jar' } } } } project.afterEvaluate { allprojects.repositories.each { handler -> handler.each { if (it.url.toString().startsWith("http://")) { throw new RuntimeException("Build should not define insecure HTTP-based Maven repostories") } } } } apply plugin: "io.sdkman.vendors" sdkman { api = "https://vendors.sdkman.io" consumerKey = System.getenv("GVM_SDKVENDOR_KEY") ?: project.hasProperty("gvmSdkvendorKey") ? project.gvmSdkvendorKey : '' consumerToken = System.getenv("GVM_SDKVENDOR_TOKEN") ?: project.hasProperty("gvmSdkvendorToken") ? project.gvmSdkvendorToken : '' candidate = "grails" version = project.version url = "https://github.com/grails/grails-core/releases/download/v${project.version}/grails-${project.version}.zip" hashtag = "#grailsfw" }