Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 18f44e2163
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 76 lines (62 sloc) 2.967 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
includeTargets << grailsScript("_GrailsInit")

USAGE = """
wrapper [--wrapperDir=dir] [--distributionUrl=url]

where
--wrapperDir = Directory where wrapper support files are installed relative to project root
--distributationUrl = URL to the directory where the release may be downloaded from if necessary

examples
grails wrapper --wrapperDir=grailsWrapper
grails wrapper --wrapperDir=grailsWrapper --distributionUrl=http://dist.springframework.org.s3.amazonaws.com/milestone/GRAILS/

optional argument default values
wrapperDir = 'wrapper'
distributionUrl = 'http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/'

"""

target ('default': "Installs the Grails wrapper") {
    depends(checkVersion, parseArguments)
    event 'InstallWrapperStart', [ 'Installing Wrapper...' ]

    grailsDistUrl = argsMap.distributionUrl ?: 'http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/'
    grailsWrapperDir = argsMap.wrapperDir ?: 'wrapper'

    targetDir = "${basedir}/${grailsWrapperDir}"

    supportFiles = []
    new File("${grailsHome}/dist/").eachFileMatch( groovy.io.FileType.FILES, { it ==~ /grails-wrapper-support.*/ }) {
        supportFiles << it
    }
    if (supportFiles.size() != 1) {
        if (supportFiles.size() == 0) {
            event("StatusError", ["An error occurred locating the grails-wrapper-support jar file"])
        } else {
            event("StatusError", ["Multiple grails-wrapper-support jar files were found ${supportFiles.absolutePath}"])
        }
        exit 1
    }
    supportFile = supportFiles[0]
    ant.unjar(dest: targetDir, src: supportFile.absolutePath, overwrite: true) {
        patternset {
            exclude(name: "META-INF/**")
        }
    }
    ant.move(todir: basedir) {
        fileset(dir: targetDir) {
            include(name: 'grailsw*')
        }
    }
    ant.replace(dir: targetDir, includes: '*.properties', token: '@distributationUrl@', value: grailsDistUrl)
    ant.replace(dir: basedir, includes: 'grailsw*', token: '@wrapperDir@', value: grailsWrapperDir)
    ant.chmod(file: 'grailsw', perm: 'u+x')

    springloadedFiles = []
    new File("${grailsHome}/lib/com.springsource.springloaded/springloaded-core/jars/").eachFileMatch( groovy.io.FileType.FILES, { it ==~ /springloaded-core-.*/ }) {
        springloadedFiles << it
    }
    if (springloadedFiles.size() != 1) {
        if (springloadedFiles.size() == 0) {
            event("StatusError", ["An error occurred locating the springloaded-core jar file"])
        } else {
            event("StatusError", ["Multiple springloaded-core jar files were found ${springloadedFiles.absolutePath}"])
        }
        exit 1
    }

    springloadedFile = springloadedFiles[0]

    ant.copy(todir: targetDir, file: springloadedFile.absolutePath, overwrite: true)

    event("StatusUpdate", [ "Wrapper installed successfully"])
    event 'InstallWrapperEnd', [ 'Finished Installing Wrapper.' ]
}
Something went wrong with that request. Please try again.