Permalink
Browse files

whitespace

  • Loading branch information...
Burt Beckwith
Burt Beckwith committed Dec 22, 2011
1 parent 706b0eb commit 2a8456f13763d5b1a73a925ad77619ca13f5e68a
View
@@ -1,2 +1,4 @@
.gradle/
build/
+bin/
+.settings/
@@ -10,12 +10,12 @@ class GrailsPlugin implements Plugin<Project> {
if (!project.hasProperty("grailsVersion")) {
throw new RuntimeException("[GrailsPlugin] the 'grailsVersion' project property is not set - you need to set this before applying the plugin")
}
-
+
project.configurations {
compile
runtime.extendsFrom compile
test.extendsFrom compile
-
+
bootstrap.extendsFrom logging
bootstrapRuntime.extendsFrom bootstrap, runtime
}
@@ -26,23 +26,23 @@ class GrailsPlugin implements Plugin<Project> {
exclude group: "org.slf4j"
}
}
-
+
bootstrap "org.apache.ivy:ivy:2.1.0"
}
-
+
project.task("init", type: GrailsTask) {
onlyIf {
!project.file("application.properties").exists() && !project.file("grails-app").exists()
}
-
+
doFirst {
if (project.version == "unspecified") {
throw new RuntimeException("[GrailsPlugin] Build file must specify a 'version' property.")
}
}
def projName = project.hasProperty("args") ? project.args : project.projectDir.name
-
+
command "create-app"
args "--inplace --appVersion=$project.version $projName"
}
@@ -58,16 +58,16 @@ class GrailsPlugin implements Plugin<Project> {
command pluginProject ? "package-plugin" : "war"
configuration "compile"
}
-
- // Convert any task executed from the command line
+
+ // Convert any task executed from the command line
// with the special prefix into the Grails equivalent command.
project.gradle.afterProject { p, ex ->
if (p == project) {
project.tasks.addRule("Grails command") { String name ->
if (name.startsWith(GRAILS_TASK_PREFIX)) {
project.task(name, type: GrailsTask) {
command name - GRAILS_TASK_PREFIX
-
+
// We don't really know what configurations are necessary, but compile is a good default
configuration "compile"
}
@@ -14,81 +14,81 @@ class GrailsTask extends DefaultTask {
private String command = null
private String args = null
private String env = null
-
+
private boolean useRuntimeClasspathForBootstrap = false
-
+
String grailsHome = null
-
+
void command(String command) {
setCommand(command)
}
-
+
void setCommand(String command) {
this.command = command
}
-
+
String getCommand() {
this.command
}
void args(String args) {
setArgs(args)
}
-
+
void setArgs(String args) {
this.args = args
}
-
+
String getArgs() {
this.args
}
-
+
void env(String env) {
setEnv(env)
}
-
+
void setEnv(String env) {
this.env = env
}
-
+
String getEnv() {
this.env
}
-
+
void configuration(Configuration configuration) {
configurations(configuration)
}
-
+
void configuration(String configuration) {
configurations(configuration)
}
-
+
void configurations(Configuration[] configurations) {
configurations.each {
dependsOn it.getTaskDependencyFromProjectDependency(true, "jar")
}
}
-
+
void configurations(String[] configurations) {
this.configurations configurations.collect { project.configurations[it] } as Configuration[]
}
-
+
void useRuntimeClasspathForBootstrap(boolean flag) {
setUseRuntimeClasspathForBootstrap(flag)
}
-
+
void setUseRuntimeClasspathForBootstrap(boolean flag) {
this.useRuntimeClasspathForBootstrap = flag
}
-
+
boolean isUseRuntimeClasspathForBootstrap() {
this.useRuntimeClasspathForBootstrap
}
-
+
@TaskAction
def executeCommand() {
verifyGrailsDependencies()
-
+
def launchArgs = [NameUtils.toScriptName(effectiveCommand), args ?: ""]
if (env) launchArgs << end
def result = createLauncher().launch(*launchArgs)
@@ -97,16 +97,16 @@ class GrailsTask extends DefaultTask {
throw new RuntimeException("[GrailsPlugin] Grails returned non-zero value: " + result);
}
}
-
+
// TODO - use a convention for this
String getEffectiveCommand() {
command ?: name
}
-
+
String getEffectiveGrailsHome() {
grailsHome ?: (project.hasProperty('grailsHome') ? project.grailsHome : null)
}
-
+
protected void verifyGrailsDependencies() {
def runtimeDeps = project.configurations.runtime.resolvedConfiguration.resolvedArtifacts
def grailsDep = runtimeDeps.find { it.resolvedDependency.moduleGroup == 'org.grails' && it.name.startsWith('grails-') }
@@ -138,34 +138,34 @@ class GrailsTask extends DefaultTask {
if (!toolsJar.exists() && !System.getProperty('os.name') == 'Mac OS X') {
project.logger.warn "[GrailsPlugin] Cannot find tools.jar in JAVA_HOME, so native2ascii may not work."
}
-
+
if (toolsJar.exists()) {
classpath << toolsJar.toURI().toURL()
}
}
-
+
boolean isEffectiveUseRuntimeClasspathForBootstrap() {
effectiveCommand in ["run-app", "test-app", "release-plugin"] || useRuntimeClasspathForBootstrap
}
-
+
Configuration getEffectiveBootstrapConfiguration() {
project.configurations."${effectiveUseRuntimeClasspathForBootstrap ? 'bootstrapRuntime' : 'bootstrap'}"
}
-
+
protected Collection<URL> getEffectiveBootstrapClasspath() {
def classpath = effectiveBootstrapConfiguration.files.collect { it.toURI().toURL() }
addToolsJarIfNecessary(classpath)
classpath
}
-
+
protected GrailsLauncher createLauncher() {
def rootLoader = new RootLoader(getEffectiveBootstrapClasspath() as URL[], ClassLoader.systemClassLoader)
def grailsLauncher = new GrailsLauncher(rootLoader, effectiveGrailsHome, project.projectDir.absolutePath)
applyProjectLayout(grailsLauncher)
configureGrailsDependencyManagement(grailsLauncher)
grailsLauncher
}
-
+
protected void applyProjectLayout(GrailsLauncher grailsLauncher) {
grailsLauncher.compileDependencies = project.configurations.compile.files as List
grailsLauncher.testDependencies = project.configurations.test.files as List
@@ -192,7 +192,7 @@ class GrailsTask extends DefaultTask {
grailsLauncher.dependenciesExternallyConfigured = true
}
}
-
+
protected void logClasspaths() {
project.logger.with {
if (infoEnabled) {
@@ -203,9 +203,8 @@ class GrailsTask extends DefaultTask {
}
}
}
-
+
protected boolean isPluginProject() {
project.projectDir.listFiles({ dir, name -> name ==~ /.*GrailsPlugin.groovy/} as FilenameFilter)
}
-
}

0 comments on commit 2a8456f

Please sign in to comment.