Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v2.0.0.RC3
Fetching contributors…

Cannot retrieve contributors at this time

231 lines (200 sloc) 9.255 kb
import org.apache.tools.ant.filters.ReplaceTokens
// This is a little fragile, need to find a way to ask Gradle for this info.
def gradleArtifactCache = new File(gradle.gradleUserHomeDir, "cache")
// The configurations of which we collect all the dependencies of for our lib dir.
// Notice that we exclude all project dependencies as we do NOT want jars built by this project
// to be part of the configuration. This also avoids building those jars when running this task.
def libsConfigurations = [:]
subprojects { subproject ->
configurations {
libs {
extendsFrom compile, runtime
["jsp21", "agent"].collect { configurations.findByName(it) }.findAll { it != null }.each { extendsFrom it }
}
}
// Filter out project dependencies, we don't want them, we just want externals
def externalLibs = configurations.libs.copyRecursive { !(it instanceof org.gradle.api.artifacts.ProjectDependency) }
// We have to manually copy the exclude rules due to GRADLE-1853
configurations.libs.hierarchy.each {
it.excludeRules.each {
externalLibs.exclude it.excludeArgs
}
}
libsConfigurations[subproject] = externalLibs
}
task populateDependencies(type: Sync, dependsOn: libsConfigurations.values) {
into homeLibDir
// Only configure this task if we are indeed going to run it because it forces a resolution of all of the subproject
// dependencies which is very costly and we want to avoid it if we aren't going to run this task. Because we do this
// after the task graph is ready we have to add the explicit dependency on the configurations as per above.
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':populateDependencies')) {
from(gradleArtifactCache) {
libsConfigurations.each { project, configuration ->
configuration.resolvedConfiguration.resolvedArtifacts.each { artifact ->
def dependency = artifact.resolvedDependency
def file = artifact.file
include "${dependency.moduleGroup}/${dependency.moduleName}/*-${dependency.moduleVersion}.*"
include "${dependency.moduleGroup}/${dependency.moduleName}/jars/${dependency.moduleName}-${dependency.moduleVersion}.jar"
include "${dependency.moduleGroup}/${dependency.moduleName}/bundles/${dependency.moduleName}-${dependency.moduleVersion}.jar"
}
}
}
}
}
}
task downloadDatastoreSources(type: org.grails.gradle.tasks.DownloadSources, dependsOn: libsConfigurations.values) {
configurations = libsConfigurations.values() as List
into(homeSrcDir) { dep ->
dep.moduleName.contains('grails-datastore')
}
}
// Can't use sync task here because this directory contains other things as well.
task sourcesJars(type: Copy) {
into homeSrcDir
from subprojects*.sourcesJar*.outputs*.files
}
sourcesJars.dependsOn downloadDatastoreSources
task pluginsFromSvn {
plugins = [
hibernate: grailsVersion,
tomcat: grailsVersion,
resources: "1.1.3",
webxml: "1.3.1",
jquery: "1.7"
]
dir = file("$buildDir/pluginsFromSvn")
outputs.files { dir.listFiles().findAll { it.name.endsWith(".zip") } }
doFirst {
ant {
mkdir(dir: dir)
plugins.each { name, version ->
def versionTag = version.replaceAll(/\./, '_').toUpperCase()
get(src: "http://plugins.grails.org/grails-${name}/tags/RELEASE_${versionTag}/grails-${name}-${version}.zip",
dest: dir, verbose: true, usetimestamp: true)
}
}
}
}
task installResources(type: Copy) {
into projectDir // not actually used, but has to be set to something
into(homeLibDir.name) {
from('grails-resources/src/grails/home/tests')
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
}
into(homeBinDir.name) {
from("grails-resources/src/grails/home/bash")
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
filter(ReplaceTokens, tokens: ['groovy.version': groovyVersion])
filter(ReplaceTokens, tokens: ['spring.loaded.version': springLoadedVersion])
fileMode = 0755
}
// the fileMode property above should take care of the chmod work, but
// it doesn't per http://jira.codehaus.org/browse/GRADLE-971
doLast {
ant.chmod(dir: homeBinDir, perm: '755', includes: '*')
}
into(homeConfDir.name) {
from("grails-resources/src/grails/home/conf")
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
filter(ReplaceTokens, tokens: ['groovy.version': groovyVersion])
filter(ReplaceTokens, tokens: ['jline.version': jlineVersion])
filter(ReplaceTokens, tokens: ['jansi.version': jansiVersion])
filter(ReplaceTokens, tokens: ['jna.version': jnaVersion])
filter(ReplaceTokens, tokens: ['commons.cli.version': commonsCliVersion])
filter(ReplaceTokens, tokens: ['ant.version': antVersion])
filter(ReplaceTokens, tokens: ['gant.version': gantVersion])
filter(ReplaceTokens, tokens: ['ivy.version': ivyVersion])
}
into(homeDslSupportDir.name) {
from 'grails-resources/src/grails/home/dsl-support'
}
into ("$homeSrcDir.name/war/WEB-INF") {
from "grails-resources/src/war/WEB-INF"
}
}
// Make the install task for each subproject place the output jar into the dist dir
subprojects {
install.doLast {
copy {
from jar.outputs.files
into homeDistDir
}
}
}
task install(dependsOn: [populateDependencies, installResources] + subprojects*.install)
task zipDist(type: Zip, dependsOn: [sourcesJars, install]) {
destinationDir = "${buildDir}/distributions" as File
baseName = 'grails'
appendix = grailsVersion
exclude "**/CVS/**"
into("grails-$grailsVersion") {
from(projectDir) {
include 'lib/', 'gradle/', 'media/', 'samples/', 'scripts/', 'build.gradle', 'build.properties', 'dependencies.txt',
'LICENSE', 'INSTALL', "src/", "gradlew.bat","gradle.properties"
exclude 'ant/bin', 'src/grails', 'src/war'
}
from("grails-resources") {
include 'src/grails/**', 'src/war/**'
// this file is accounted for later with special handling to do some token replacement
exclude 'src/grails/grails-macros.xml'
}
from(projectDir) {
include "gradlew"
fileMode = 0755
}
from(docs.destinationDir) {
into "doc"
}
from(pluginsFromSvn.outputs.files) {
into "plugins"
rename { it - "grails-" }
}
from('grails-resources/src/grails/home/docs/README') {
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
}
from('grails-resources/src/grails/home/tests') {
into "src/resources/tests"
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
}
from("grails-resources/src/grails/home/bash") {
into "bin"
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
filter(ReplaceTokens, tokens: ['groovy.version': groovyVersion])
filter(ReplaceTokens, tokens: ['spring.loaded.version': springLoadedVersion])
fileMode = 0755
}
from("grails-resources/src/grails/home/conf") {
into "conf"
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
filter(ReplaceTokens, tokens: ['groovy.version': groovyVersion])
filter(ReplaceTokens, tokens: ['jline.version': jlineVersion])
filter(ReplaceTokens, tokens: ['jansi.version': jansiVersion])
filter(ReplaceTokens, tokens: ['jna.version': jnaVersion])
filter(ReplaceTokens, tokens: ['commons.cli.version': commonsCliVersion])
filter(ReplaceTokens, tokens: ['ant.version': antVersion])
filter(ReplaceTokens, tokens: ['gant.version': gantVersion])
filter(ReplaceTokens, tokens: ['ivy.version': ivyVersion])
filter(ReplaceTokens, tokens: ['jline.version': jlineVersion])
filter(ReplaceTokens, tokens: ['jansi.version': jansiVersion])
filter(ReplaceTokens, tokens: ['jna.version': jnaVersion])
filter(ReplaceTokens, tokens: ['commons.cli.version': commonsCliVersion])
}
from(homeDistDir) {
into "dist"
exclude "*.zip"
}
from("grails-resources/src/grails/grails-macros.xml") {
into "src/grails"
filter(ReplaceTokens, tokens: ['grails.version': grailsVersion])
}
from('grails-resources/src/grails/home/dsl-support') {
into "dsl-support"
}
}
}
/*task zipDoc(type: Zip) {
appendix = 'docs'
from docs.destinationDir
}*/
task assemble(dependsOn: zipDist)
Jump to Line
Something went wrong with that request. Please try again.