Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v1.2.4
Fetching contributors…

Cannot retrieve contributors at this time

346 lines (313 sloc) 13.095 kb
import org.gradle.api.tasks.testing.ForkMode
import org.gradle.util.ClasspathUtil
import org.gradle.api.tasks.compile.GroovyCompile
defaultTasks "libs"
// Groovy plugin settings.
usePlugin('groovy')
sourceCompatibility = "1.5"
targetCompatibility = "1.5"
archivesBaseName = 'grails'
groovySrcDirNames = [ "commons", "groovy", "persistence", "scaffolding", "tiger", "web" ]
// This manifest gets added to all the Grails JARs we create. "version"
// comes from gradle.properties.
manifest.mainAttributes(
"Built-By": System.getProperty("user.name"),
"Implementation-Title": "Grails",
"Implementation-Version": version,
"Implementation-Vendor": "grails.org")
archivesBaseName = "grails"
// The scripts are compiled to a different directory from all the other
// source files.
scriptClassesDirTask = dir("$buildDirName/script-classes")
// All the libraries that Grails depends on.
dependencies {
addFlatDirResolver('lib', new File(rootDir, 'lib'))
clientModule(['groovy'], ":groovy-all:1.6.8") {
dependency(":commons-cli:1.0")
clientModule(":ant:1.7.0") {
dependencies(":ant-junit:1.7.0", ":ant-launcher:1.7.0")
}
}
compile ":ant:1.7.0",
":ant-launcher:1.7.0",
":jcl-over-slf4j:1.5.2",
":spring:2.5.6",
":spring-test:2.5.6",
":spring-webmvc:2.5.6",
":org.springframework.binding:2.0.3.RELEASE",
":org.springframework.webflow:2.0.3.RELEASE",
":junit:3.8.2",
":commons-beanutils:1.7.0",
":commons-codec:1.3",
":commons-collections:3.2",
":commons-dbcp:1.2.1",
":commons-fileupload:1.1.1",
":commons-io:1.4",
":commons-lang:2.1",
":commons-validator:1.3.0",
":ejb3-persistence:3.3.0",
":gant_groovy1.6:1.5.0",
":jsp-api:2.0",
":log4j:1.2.15",
":servlet-api-2.5:6.1.4",
":hibernate3:3.2.6",
":hibernate-annotations:3.3.0",
":sitemesh:2.3",
":xpp3_min:1.1.3.4.O",
":xstream:1.2.1"
testCompile ":cglib-nodep:2.1_3",
":jstl:2.4"
testRuntime ":slf4j-api:1.5.2",
":slf4j-log4j12:1.5.2",
":ant-nodeps:1.7.0",
":antlr:2.7.6",
":commons-pool:1.2",
":hibernate-commons-annotations:3.3.0",
":hsqldb:1.8.0.5",
":jta:1.0.1B",
":jstl:2.4",
":ognl:2.6.9",
":org.springframework.js:2.0.3.RELEASE",
":oro:2.0.8",
":oscache:2.4.1",
":standard:2.4",
":xercesImpl:2.9.0"
addConfiguration("jsp21")
jsp21 ":jsp-api:2.1"
}
/**
* Compiles the Gant scripts to a custom target directory using Groovyc.
*/
createTask("compile-scripts", dependsOn: [ "compile", scriptClassesDirTask ]) {
ant {
taskdef(name: "groovyc",
classname: "org.codehaus.groovy.ant.Groovyc",
classpath: dependencies.antpath("groovy"))
groovyc(destdir: scriptClassesDirTask.dir, encoding: "UTF-8", fork: true, classpath: dependencies.antpath("compile")) {
classpath {
pathelement(location: classesDir)
pathelement(location: "$rootDir/lib/ant-junit-1.7.0.jar")
pathelement(location: "$rootDir/lib/jetty-6.1.12.jar")
pathelement(location: "$rootDir/lib/jetty-plus-6.1.12.jar")
pathelement(location: "$rootDir/lib/jetty-util-6.1.12.jar")
pathelement(location: "$rootDir/lib/svnkit-1.2.0.jar")
pathelement(location: "$rootDir/lib/xalan.jar")
pathelement(location: "$rootDir/lib/xercesImpl-2.9.0.jar")
}
src(path: "$rootDir/scripts")
}
}
}
/**
* Packages all the resource files for new Grails applications and
* plugins into a set of JAR files. Basically they contain the starting
* directory and file structure.
*/
createTask("jar-app-files", dependsOn: [ "compile" ]) {
// Clear out the existing JAR files first.
ant.delete {
fileset(dir: buildDir, includes: "grails-*-files.jar")
}
// Package up the files that are shared by both applications and plugins.
ant.jar(destfile: "$buildDir/grails-shared-files.jar") {
fileset(dir: "$rootDir/src/grails/templates/ide-support/eclipse")
fileset(dir: "$rootDir/src/grails", includes: "build.xml")
fileset(dir: "$rootDir/src/grails/templates/ide-support/textmate", includes: "project.tmproj")
zipfileset(dir: "$rootDir/src/war", prefix: "web-app") {
include(name: "WEB-INF/applicationContext.xml")
include(name: "WEB-INF/applicationContext.xml")
include(name: "WEB-INF/sitemesh.xml")
include(name: "WEB-INF/tld/*.tld")
}
fileset(dir: "$rootDir/src/grails") {
include(name: "grails-app/conf/DataSource.groovy")
include(name: "grails-app/conf/UrlMappings.groovy")
}
}
// Package up the files that are exclusive to applications.
ant.jar(destfile: "$buildDir/grails-app-files.jar") {
zipfileset(dir: "$rootDir/src/war", prefix: "web-app") {
exclude(name: "WEB-INF/**")
}
fileset(dir: "$rootDir/src/grails") {
include(name: "grails-app/**")
exclude(name: "grails-app/taglib/**")
exclude(name: "grails-app/utils/**")
exclude(name: "grails-app/conf/DataSource.groovy")
exclude(name: "grails-app/conf/UrlMappings.groovy")
}
}
// Package up the files that are exclusive to plugins.
ant.jar(destfile: "$buildDir/grails-plugin-files.jar") {
fileset(dir: "$rootDir/src/grails/templates/plugins")
}
}
/**
* DEBUG
* Runs the DefaultUrlMappingEvaluatorsTests test case on its own. It
* seems to fail for no apparent reason with Gradle. Works fine from
* the Ant build.
*/
createTask("test-single", dependsOn: "testCompile") {
ant.mkdir(dir: testResultsDir)
ant.junit(fork: true, forkmode: "once", clonevm: true) {
sysproperty(key: "grails.cli.testing", value: true)
jvmarg(value: "-server")
jvmarg(value: "-Xmx1G")
jvmarg(value: "-Xms256m")
jvmarg(value: "-XX:MaxPermSize=256m")
classpath(path: dependencies.antpath("testRuntime"))
classpath(location: classesDir)
classpath(location: testClassesDir)
// classpath(location: "$rootDir/target/test-classes")
formatter(type: "xml")
test(todir: testResultsDir, name: "org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingEvaluatorTests")
}
}
// After the source files have been compiled, we...
compile.doLast {
// Compile the JSP 2.1 specific classes with the "jsp-api-2.1.jar"
// library on the classpath.
dependencies.linkConfWithTask('jsp21', 'jspCompile');
dependencies.linkConfWithTask('compile', 'jspCompile');
GroovyCompile jspCompile = createTask('jspCompile', type: GroovyCompile).configure {
conventionMapping(DefaultConventionsToPropertiesMapping.COMPILE)
groovySourceDirs = ["$srcRoot/jsp21" as File]
groovyClasspath = dependencies.resolve("groovy")
unmanagedClasspath(classesDir)
destinationDir = classesDir
}
jspCompile.execute()
// ...create a manifest file in the "classes" directory using Ant's
// manifest task. It replicates the manifest included in the dist
// JARs.
def manifestDir = new File(classesDir, "META-INF")
ant.mkdir(dir: manifestDir)
ant.manifest(file: "$manifestDir/MANIFEST.MF") {
manifest.manifest.mainAttributes.each { key, value ->
attribute(name: key, value: value)
}
}
// ...copy all the "*.properties" files from the source directories
// to "classes". Normally the files would be in a "resources"
// directory and we could leave Gradle to do this automatically.
ant.copy(todir: classesDir) {
groovySrcDirs.each { dir ->
fileset(dir: dir, includes: "**/*.properties")
}
}
}
testCompile {
// Because of the layout of Grails, we can't simply specify a list of
// directory names for the test sources. This is because Gradle's Java
// plugin expects them to be under "src", which they're not. So we
// update the test source directories manually here.
groovySourceDirs = [
new File("$rootDir/test/commons"),
new File("$rootDir/test/groovy"),
new File("$rootDir/test/persistence"),
new File("$rootDir/test/scaffolding"),
new File("$rootDir/test/tiger"),
new File("$rootDir/test/web") ]
groovyOptions.forkOptions.memoryMaximumSize = '1G'
}
test {
dependsOn("jar-app-files")
// These directories need to be on the classpath for the tests it
// seems. Perhaps the relevant files could be moved to "resources"
// in the future? Also, the JDK tools.jar is required for some of
// the CLI tests because they need to run 'native2ascii'.
unmanagedClasspath(
rootDir,
buildDir,
new File(rootDir, "src/war/WEB-INF"),
new File(rootDir, "src/grails/grails-app/utils"),
new File(rootDir, "test/commons"),
new File(rootDir, "test/groovy"),
new File(rootDir, "test/persistence"))
// tools jar does not exists on every OS (e.g. OS X))
if (ClasspathUtil.toolsJar) { unmanagedClasspath(ClasspathUtil.toolsJar) }
// We don't want to run all the classes under "test-classes" as tests,
// so we set up the inclusions and exclusions here. We also need to
// pass arguments to the forked JUnit processes, so we do that here too.
testName = System.getProperty("test") ?: '*'
includes = ["**/${testName}Tests.class"]
exclude("**/Abstract*", "**/TransactionalServiceReloadTests*")
options.fork(
forkMode: ForkMode.ONCE,
jvmArgs: [ "-Dgrails.cli.testing=true", "-Xmx1G", "-Xms256m", "-XX:MaxPermSize=256m" ])
}
// Clean the test results and reports before each test run.
test.doFirst {
// Clean the reports.
ant {
delete(dir: testResultsDir)
delete(dir: reportsDir)
}
}
// The scripts must be compiled and the application/plugin resources
// packaged before we can build the distribution JARs.
libs {
dependsOn("compile-scripts", "jar-app-files")
jar(appendix: "core") {
fileSet(dir: classesDir) {
include("META-INF/**",
"grails/ui/**",
"grails/util/**",
"**/groovy/grails/beans/factory/**",
"**/groovy/grails/commons/**",
"**/groovy/grails/compiler/**",
"**/groovy/grails/orm/support/**",
"**/groovy/grails/exceptions/**",
"**/groovy/grails/support/**",
"**/groovy/grails/validation/**",
"**/groovy/grails/plugins/**",
"**/groovy/grails/commons/spring/**",
"**/groovy/grails/plugins/orm/hibernate**",
"**/groovy/grails/plugins/web/**",
"**/groovy/grails/plugins/converters/**",
"**/groovy/grails/plugins/webflow/**",
"**/groovy/grails/plugins/scaffolding/**",
"**/groovy/grails/validation/Hibernate**")
exclude("grails/util/BuildSettings*",
"grails/util/GrailsNameUtils*",
"grails/util/Environment*",
"grails/util/Metadata*",
"grails/util/BuildScope*")
}
files(new File(rootDir, "build.properties"))
destinationDir = distsDir
}
jar(appendix: "bootstrap") {
fileSet(dir: classesDir) {
include("META-INF/**",
"grails/util/BuildSettings*",
"grails/util/GrailsNameUtils*",
"grails/util/Environment*",
"grails/util/Metadata*",
"grails/util/BuildScope*",
"grails/ant/**/*",
"**/groovy/grails/cli/**/*")
}
fileSet(dir: "$rootDir/conf") {
include("groovy-starter*.conf")
}
destinationDir = distsDir
}
jar(appendix: "scripts") {
fileSet(dir: scriptClassesDirTask.dir)
destinationDir = distsDir
}
jar(appendix: "resources") {
fileSet(dir: buildDir) {
include("*.jar")
}
fileSet(dir: rootDir) {
include("conf/webdefault.xml",
"src/grails/templates/artifacts/**",
"src/grails/templates/scaffolding/**",
"src/war/WEB-INF/web*.template.xml")
}
destinationDir = distsDir
}
}
Jump to Line
Something went wrong with that request. Please try again.