Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v1.1.1
Fetching contributors…

Cannot retrieve contributors at this time

119 lines (96 sloc) 3.754 kb
/*
* Copyright 2004-2005 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.
*/
import grails.util.GrailsNameUtils
import grails.util.Metadata
import org.codehaus.groovy.grails.plugins.GrailsPluginUtils
/**
* Gant script that handles the creation of Grails applications
*
* @author Graeme Rocher
*
* @since 0.4
*/
includeTargets << grailsScript("_GrailsPlugins")
grailsAppName = ""
projectType = "app"
target(createApp: "Creates a Grails application for the given name") {
depends(parseArguments, appName)
initProject()
// Create a message bundle to get the user started.
touch(file: metadataFile)
// Set the default version number for the application
updateMetadata(
"app.version": grailsAppVersion ?: "0.1",
"app.servlet.version": servletVersion)
installDefaultPluginSet()
event("StatusFinal", ["Created Grails Application at $basedir"])
}
def resetBaseDirectory(String basedir) {
// Update the build settings and reload the build configuration.
grailsSettings.baseDir = new File(basedir)
grailsSettings.loadConfig()
// Reload the application metadata.
metadataFile = new File("$basedir/${Metadata.FILE}")
metadata = Metadata.getInstance(metadataFile)
// Reset the plugin stuff.
GrailsPluginUtils.clearCaches()
pluginsHome = grailsSettings.projectPluginsDir.path
}
target(createPlugin: "The implementation target") {
depends(parseArguments, appName)
metadataFile = new File("${basedir}/application.properties")
projectType = "plugin"
initProject()
// Rename the plugin descriptor.
pluginName = GrailsNameUtils.getNameFromScript(grailsAppName)
ant.move(
file: "${basedir}/GrailsPlugin.groovy",
tofile: "${basedir}/${pluginName}GrailsPlugin.groovy",
overwrite: true)
// Insert the name of the plugin into whatever files need it.
ant.replace(dir:"${basedir}") {
include(name: "*GrailsPlugin.groovy")
include(name: "scripts/*")
replacefilter(token: "@plugin.name@", value: pluginName)
replacefilter(token: "@plugin.version@", value: grailsAppVersion ?: "0.1")
replacefilter(token: "@grails.version@", value: grailsVersion)
}
event("StatusFinal", [ "Created plugin ${pluginName}" ])
}
target(initProject: "Initialise an application or plugin project") {
depends(createStructure, updateAppProperties)
grailsUnpack(dest: basedir, src: "grails-shared-files.jar")
grailsUnpack(dest: basedir, src: "grails-$projectType-files.jar")
launderIDESupportFiles()
}
target ( appName : "Evaluates the application name") {
if(!argsMap["params"]) {
ant.input(message:"Application name not specified. Please enter:",
addProperty:"grails.app.name")
grailsAppName = ant.antProject.properties."grails.app.name"
}
else {
grailsAppName = argsMap["params"].join(" ")
}
if (!argsMap["inplace"]) {
basedir = "${basedir}/${grailsAppName}"
resetBaseDirectory(basedir)
}
if (argsMap["appVersion"]) {
grailsAppVersion = argsMap["appVersion"]
}
appClassName = GrailsNameUtils.getClassNameRepresentation(grailsAppName)
}
Jump to Line
Something went wrong with that request. Please try again.