Permalink
Browse files

I have added an "init" task to the Gradle plugin that creates a fresh

Grails project. The build file must contain a project version.

The name of the Grails project is set by default to the name of the
project directory, but this can be overridden with the "args" project
property:

  gradle init -Pargs="my-grails"
  • Loading branch information...
1 parent eb97079 commit 09e677934a1b0e9a7419a4340b6ebc2a88b7f1b5 @pledbrook pledbrook committed Feb 8, 2010
Showing with 20 additions and 0 deletions.
  1. +20 −0 grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/GrailsPlugin.groovy
@@ -23,6 +23,26 @@ class GrailsPlugin implements Plugin<Project> {
test.extendsFrom compile
}
+ // Provide a task that allows the user to create a fresh Grails
+ // project from a basic Gradle build file.
+ project.task("init") << {
+ // First make sure that a project version has been configured.
+ if (project.version == "unspecified") {
+ throw new RuntimeException("[GrailsPlugin] Build file must specify a 'version' property.")
+ }
+
+ // Don't create a new project if one already exists.
+ if (project.file("application.properties").exists() && project.file("grails-app").exists()) {
+ logger.warn "Grails project already exists - SKIPPING"
+ return
+ }
+
+ // The project name comes from the name of the project
+ // directory, but this can be overridden by an argument.
+ def projName = project.hasProperty("args") ? project.args : project.projectDir.name
+ runGrails("CreateApp", project, "--inplace --appVersion=" + project.version + " " + projName)
+ }
+
// Most people are used to a "test" target or task, but Grails
// has "test-app". So we hard-code a "test" task.
project.task("test") << {

0 comments on commit 09e6779

Please sign in to comment.