Permalink
Browse files

Implemented GRAILS-7212: applied patch from Jonathan Pearlin to add a…

…n 'upgrade' goal to the plugin. This also adds a grailsHome property.
  • Loading branch information...
1 parent 4bd5b4c commit feb3df3e049be105ef2485e56a5ede001a569b66 @pledbrook pledbrook committed Feb 16, 2011
@@ -93,6 +93,13 @@
protected File pluginsDir;
/**
+ * The path to the Grails installation.
+ *
+ * @parameter expression="${grailsHome}"
+ */
+ protected File grailsHome;
+
+ /**
* POM
*
* @parameter expression="${project}"
@@ -213,7 +220,7 @@ protected void runGrails(String targetName, String args, boolean includeProjectD
} catch (Exception e) {
e.printStackTrace();
}
-
+
// Now add the project dependencies if necessary.
if (includeProjectDeps) {
deps.addAll(this.project.getRuntimeArtifacts());
@@ -250,7 +257,7 @@ protected void runGrails(String targetName, String args, boolean includeProjectD
}
classpath[classpath.length - 1] = toolsJar.toURI().toURL();
GrailsRootLoader rootLoader = new GrailsRootLoader(classpath, ClassLoader.getSystemClassLoader());
- GrailsBuildHelper helper = new GrailsBuildHelper(rootLoader, null, basedir.getAbsolutePath());
+ GrailsBuildHelper helper = new GrailsBuildHelper(rootLoader, (grailsHome != null) ? grailsHome.getAbsolutePath() : null, basedir.getAbsolutePath());
configureBuildSettings(helper);
// Search for all Grails plugin dependencies and install
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2007 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.maven.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Upgrades a Grails application to the version of this plugin.
+ *
+ * @author Jonathan Pearlin
+ * @version $Id$
+ * @description Upgrades a Grails application.
+ * @goal upgrade
+ * @requiresProject false
+ * @requiresDependencyResolution runtime
+ * @since 1.3.7
+ */
+public class GrailsUpgradeMojo extends AbstractGrailsMojo {
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ runGrails("Upgrade");
+ }
+}
@@ -137,4 +137,8 @@ public void testLoadMavenWarMojoLookup() throws Exception {
public void testLoadGrailsSetVersionMojoLookup() throws Exception {
mojoTest("grails-set-version/plugin-config.xml", "set-version", GrailsSetVersionMojo.class);
}
+
+ public void testLoadGrailsUpgradeMojoLookup() throws Exception {
+ mojoTest("grails-upgrade/plugin-config.xml", "upgrade", GrailsUpgradeMojo.class);
+ }
}
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright 2007 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id$ -->
+
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.grails</groupId>
+ <artifactId>grails-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration/>
+ </plugin>
+ </plugins>
+ </build>
+</project>

0 comments on commit feb3df3

Please sign in to comment.