Permalink
Browse files

Update to Grails 1.3 & a new version of Gradle.

  • Loading branch information...
1 parent a22d70a commit 75050d13c9f5ec1d33ab90ccd54bbe34b0604175 @pledbrook committed Jun 1, 2012
View
@@ -1,4 +1,5 @@
-apply id: 'groovy'
+apply plugin: 'groovy'
+apply plugin: 'project-report'
configurations {
provided { transitive = false }
@@ -8,6 +9,7 @@ configurations {
repositories {
mavenCentral()
+// mavenRepo urls: "http://repository.jboss.org/nexus/content/groups/public/"
flatDir dirs: file("lib")
}
@@ -16,27 +18,31 @@ dependencies {
compile configurations.groovy,
gradleApi(),
- "org.grails:grails-bootstrap:1.2.0",
- "org.grails:grails-core:1.2.0",
- "org.grails:grails-spring:1.2.0",
- "org.springframework:spring-context:3.0.0.RELEASE",
- "org.springframework:spring-core:3.0.0.RELEASE"
+ "org.grails:grails-bootstrap:1.3.3",
+// "org.grails:grails-spring:1.3.3",
+ "org.springframework:spring-context:3.0.3.RELEASE",
+ "org.springframework:spring-core:3.0.3.RELEASE"
- runtime "org.grails:grails-resources:1.2.0"
+ compile "org.grails:grails-core:1.3.3", {
+ exclude module: "netty"
+ exclude module: "jsr166y"
+ }
+
+ runtime "org.grails:grails-resources:1.3.3"
provided "javax.servlet:servlet-api:2.5"
// Required by the Groovy compiler, but the code has no explicit
// dependency on these.
- provided "org.springframework:spring-beans:3.0.0.RELEASE"
+ provided "org.springframework:spring-beans:3.0.3.RELEASE"
// Required by Grails' AST transformations, which are included in
// grails-core.
provided "commons-lang:commons-lang:2.4",
"org.slf4j:slf4j-api:1.5.10",
"org.slf4j:slf4j-jdk14:1.5.10",
- "org.slf4j:jcl-over-slf4j:1.5.10",
- "org.springframework:spring-web:3.0.0.RELEASE"
+ "org.slf4j:jcl-over-slf4j:1.5.10"//,
+// "org.springframework:spring-web:3.0.0.RELEASE"
itCompile gradleApi(),
"org.gradle:gradle-test:0.9-20100220071335+0000",
@@ -66,14 +72,16 @@ sourceSets {
runtimeClasspath = configurations.itRuntime + sourceSets.integTest.classes
}
}
-
+/*
task integTest(type: AntTest, dependsOn: jar) { //}, dependsOn: [intTestImage, binZip, allZip, srcZip, ':docs:userguideDocbook']) {
// integTestUserDir = file('intTestHomeDir')
// options.systemProperties['integTest.srcDir'] = file('src').absolutePath
// options.systemProperties['integTest.userGuideInfoDir'] = project(':docs').docbookSrc
// options.systemProperties['integTest.userGuideOutputDir'] = new File(project(':docs').samplesSrcDir, "userguideOutput").absolutePath
// options.systemProperties['integTest.gradleUserHomeDir'] = integTestUserDir.absolutePath
+*/
// include '**/'
+/*
useTestNG()
// jvmArgs("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006")
@@ -97,3 +105,4 @@ task integTest(type: AntTest, dependsOn: jar) { //}, dependsOn: [intTestImage, b
// options.fork(forkArgs)
// }
}
+*/
@@ -0,0 +1,68 @@
+package grails.build
+
+import org.testng.annotations.Test
+import org.testng.annotations.BeforeClass
+import org.testng.annotations.AfterClass
+
+/**
+ *
+ */
+class CreateToPackageTest extends AbstractIntegrationTest {
+ private static final String TEST_PROJECT_NAME = "proj1"
+
+ File projectDir
+
+ @BeforeClass
+ void createTempDir() {
+ projectDir = new File("build/test-projects/${TEST_PROJECT_NAME}")
+ projectDir.mkdirs()
+ }
+
+ @AfterClass
+ void deleteTempDir() {
+ projectDir.deleteDir()
+ }
+
+ @Test
+ void createApplication() {
+ def testScript = """\
+buildscript {
+ repositories {
+ mavenCentral()
+ mavenRepo urls: "http://download.java.net/maven/2/"
+ flatDir dirs: "${new File('build/libs').absolutePath}"
+ }
+
+ dependencies {
+ classpath "org.grails:grails-bootstrap:1.2.0",
+ "org.grails:grails-core:1.2.0",
+ ":grails-build:"
+ }
+}
+
+apply id: 'grails-x'
+
+dependencies {
+ compile "org.grails:grails-core:1.2.0"
+}
+"""
+ def buildFile = testFile(projectDir, "build.gradle")
+ buildFile.write testScript
+
+ def result = usingProjectDir(projectDir).withTasks("init").run()
+ if (result.error) {
+ println "Error\n-----\n${result.error}"
+ assert false
+ }
+
+ assert new File(projectDir, "application.properties").exists()
+ assert new File(projectDir, "grails-app/conf/BuildConfig.groovy").exists()
+ assert new File(projectDir, "grails-app/conf/Config.groovy").exists()
+ assert new File(projectDir, "grails-app/conf/UrlMappings.groovy").exists()
+ assert new File(projectDir, "grails-app/conf/spring/resources.groovy").exists()
+ assert new File(projectDir, "web-app/WEB-INF").exists()
+
+ // There should be no META-INF directory from the JARs.
+ assert !new File(projectDir, "META-INF").exists()
+ }
+}
@@ -0,0 +1,15 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath "org.grails:grails-bootstrap:1.2.0", "org.grails:grails-core:1.2.0", ":grails-build:"
+ }
+}
+
+apply id: 'grails-ex'
+
+dependencies {
+ compile "org.grails:grails-core:1.2.0"
+}
View
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/groovy" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="Groovy" level="application" />
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/gradle-0.9-20100217000142+0300/lib/gradle-launcher-0.9-20100217000142+0300.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/gradle-0.9-20100217000142+0300/lib/gradle-core-0.9-20100217000142+0300.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/grails-1.2.0/dist/grails-bootstrap-1.2.0.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/grails-1.2.0/dist/grails-core-1.2.0.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/grails-1.2.0/lib/org.springframework.beans-3.0.0.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/grails-1.2.0/lib/org.springframework.context-3.0.0.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../tools/grails-1.2.0/lib/org.springframework.core-3.0.0.RELEASE.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar:///opt/java/jdk-1.6/lib/tools.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ </component>
+</module>
+
@@ -14,10 +14,10 @@ import org.gradle.api.file.FileCollection
class GrailsPlugin implements Plugin<Project> {
File metadataFile
- void use(Project project) {
+ void apply(Project project) {
project.with {
- apply id: 'groovy'
- apply id: 'war'
+ apply plugin: 'groovy'
+ apply plugin: 'war'
if (!project.hasProperty("grailsHome")) {
grailsHome = System.getProperty("grails.home") ?: System.getenv("GRAILS_HOME")
@@ -53,7 +53,7 @@ class GrailsPlugin implements Plugin<Project> {
// A Grails project has a rather distinctive directory structure,
// but it is at heart a straight WAR project. This sets up the
// source directories.
- sourceSets {
+ project.sourceSets {
main {
groovy {
def grailsAppDirs = file("grails-app").listFiles({ f -> f.directory } as FileFilter)
@@ -63,15 +63,15 @@ class GrailsPlugin implements Plugin<Project> {
}
}
- dependencies {
- groovy "org.codehaus.groovy:groovy:1.7.0"
- compile "org.grails:grails-bootstrap:1.2.0"
+ project.dependencies {
+ groovy "org.codehaus.groovy:groovy:1.7.5"
+ compile "org.grails:grails-bootstrap:$grailsVersion"
// Required by Grails' AST transformations.
provided "commons-lang:commons-lang:2.4",
"javax.servlet:servlet-api:2.5",
"log4j:log4j:1.2.14",
- "org.grails:grails-spring:1.2.0",
+ "org.grails:grails-spring:$grailsVersion",
"org.slf4j:slf4j-api:1.5.8",
"org.slf4j:slf4j-jdk14:1.5.8",
"org.slf4j:jcl-over-slf4j:1.5.8",
@@ -96,10 +96,10 @@ class GrailsPlugin implements Plugin<Project> {
if (grailsHome) {
resources files(grailsHome)
}
- resources "org.grails:grails-resources:1.2.0"
+ resources "org.grails:grails-resources:$grailsVersion"
}
- task("tmpBuildDir") {
+ project.task("tmpBuildDir") {
dir = new File(buildDir, "tmp")
doLast {
ant.mkdir dir: dir
@@ -7,7 +7,6 @@ import org.gradle.api.Project
import org.gradle.api.internal.AbstractTask
import org.gradle.api.tasks.TaskAction
import org.gradle.groovy.scripts.StringScriptSource
-import org.gradle.initialization.DefaultCacheInvalidationStrategy
import org.gradle.initialization.DefaultGradleLauncherFactory
import org.gradle.util.GFileUtils
import groovy.text.SimpleTemplateEngine
@@ -46,14 +45,6 @@ Grails settings: Base dir = ${settings.baseDir}
buildParameters.currentDir = plugin.pluginDirectory
buildParameters.searchUpwards = false
buildParameters.taskNames = [ "exportedClasses" ]
- boolean executeBuild = true
-
- // Don't bother building the project if nothing's changed.
- File markerFile = new File(buildParameters.currentDir, "build/COMPLETED")
- if (buildParameters.cacheUsage == CacheUsage.ON
- && new DefaultCacheInvalidationStrategy().isValid(markerFile, buildParameters.currentDir)) {
- executeBuild = false
- }
// If the plugin has a 'build.gradle' file, use that, otherwise
// use a standard build script packaged with this Gradle plugin.
@@ -78,25 +69,15 @@ Grails settings: Base dir = ${settings.baseDir}
// Now we build the plugin by creating a new Gradle launcher
// to execute the build in the plugin's directory.
def gradleLauncher = new DefaultGradleLauncherFactory().newInstance(buildParameters)
-
- BuildResult buildResult
- if (executeBuild) {
- buildResult = gradleLauncher.run()
- }
- else {
- // If we don't need to build the plugin, we still need its
- // dependencies and classpaths.
- buildResult = gradleLauncher.getBuildAnalysis()
- }
- buildResult.rethrowFailure()
- GFileUtils.touch(markerFile)
+ BuildResult buildResult = gradleLauncher.run().rethrowFailure()
// Make the plugin's project instance available from the root
// project. Then, if the Grails plugin has a Gradle Plugin
// instance, it can access the classpaths. Otherwise, the
// Gradle plugin has no way of finding out about its own project.
def pluginProject = buildResult.gradle.rootProject
project.grailsPlugins[plugin.name] = pluginProject
+ project.currentPlugin = pluginProject
// Find out whether the plugin implements a Gradle plugin. If
// it does, execute it now.
@@ -105,8 +86,8 @@ Grails settings: Base dir = ${settings.baseDir}
// there is an associated Gradle plugin.
def pluginConfig = loadBuildConfig(plugin, metadata, settings)
if (pluginConfig?.plugin?.buildPluginClass) {
- // We will load the plugin within the context of the plugin's
- // runtime classpath.
+ // We will load the plugin's Gradle plugin within the context of
+ // the Grails plugin's runtime classpath.
def pluginBuildClasspath = buildResult.gradle.rootProject.sourceSets.plugin.
runtimeClasspath.filter { it != null }.files
@@ -117,7 +98,7 @@ Grails settings: Base dir = ${settings.baseDir}
try {
// Load and (manually) execute the Gradle plugin.
def buildPlugin = cl.loadClass(pluginConfig.plugin.buildPluginClass).newInstance()
- buildPlugin.use(project)
+ buildPlugin.apply(project)
}
catch (ClassNotFoundException ex) {
throw new RuntimeException("[GrailsPlugin] Can't find configured build plugin " +
Oops, something went wrong.

0 comments on commit 75050d1

Please sign in to comment.