a quick and dirty wrapper for the grails-app build

View: New views
2 Messages — Rating Filter:   Alert me  

a quick and dirty wrapper for the grails-app build

by Helmut Denk () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi gradle,

as i noted in an earlier post, i think that gradle-support
for building grails-apps would be a useful thing.

unfortunately i dont feel like the man to do a proper gradle-plugin
for grails (this is mainly a matter of skills but also a matter
of time). i also think, that regarding the future of the grails-build
there are some basic decisions/moves to be made, that are solely
in the responsibility of the grails-team.

what could be done IMO from the gradle-perspective is a
quick&dirty solution, that can be useful as long as grails
doesnt come out with something better.

my idea for this is a plugin, that wraps the existing
grails commands and adds the ability to resolve and
publish artefacts.

here a script-snippet, that tries to show what
i mean by 'wrapping grails-commands':


*** snip ***

task clean() << {
    ant.exec(executable: getExecutable(), dir: "$projectDir",
    failonerror: 'true', failifexecutionfails: 'true') {
        arg(line: getArgLine('clean'))
    }
}

task war() << {
    ant.exec(executable: getExecutable(), dir: "$projectDir",
    failonerror: 'true', failifexecutionfails: 'true') {
        arg(line: getArgLine('war'))
    }
}

task test() << {
    ant.exec(executable: getExecutable(), dir: "$projectDir",
    failonerror: 'false', failifexecutionfails: 'true') {
        arg(line: getArgLine('test-app'))
    }
}

String getExecutable() {
    String executable

    if (windowsOrNot()) {
        executable = 'cmd'
    } else {
        // dann isses Unix
        executable = 'sh'
    }
    return executable
}

String getArgLine(String arg) {
    String argLine

    if (windowsOrNot()) {
        argLine = "/c grails.bat $arg"
    } else {
        // dann isses Unix
        argLine = "-l grails.sh $arg"
    }
    return argLine
}

boolean windowsOrNot() {
    return '\\'.equals(File.separator)
}

*** snap ***

any comments/suggestions are welcome ...

have a successful day

Re: a quick and dirty wrapper for the grails-build

by Peter Ledbrook :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Helmut,

> what could be done IMO from the gradle-perspective is a
> quick&dirty solution, that can be useful as long as grails
> doesnt come out with something better.

What each Gradle task of the plugin needs to do is instantiate the class:

  org.codehaus.groovy.grails.cli.support.GrailsBuildHelper

set the compile, test, and runtime classpaths, and then execute the
appropriate Grails command/script (via the above class). The Grails
Ant task (grails.ant.GrailsTask) is an example of how the process
works.

The key is to pass the dependencies from Gradle to the
GrailsBuildHelper instance.

Hope that helps,

Peter

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email