Skip to content

Instantly share code, notes, and snippets.

@kattrali
Created October 27, 2010 18:24

Revisions

  1. kattrali revised this gist Feb 25, 2011. 1 changed file with 48 additions and 30 deletions.
    78 changes: 48 additions & 30 deletions classpath.groovy
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,27 @@
    // classpath retriever for all jars in project "lib" folder and compiled classes in project,
    // plus a hacky way to load ivy dependencies (until I can get groovy Grape configured properly)
    // classpath retriever for all jars in project "lib" folder and compiled classes in project

    //import groovy.grape.Grape
    //import groovy.util.ConfigObject
    //import groovy.util.ConfigSlurper
    def GRAILS_VERSION = '1.3.7'

    def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
    def project = redcar_config.parentFile
    def classpath = []
    def home = System.getProperty("user.home")
    def cache = new File(home+File.separator+".ivy2"+File.separator+"cache")

    //manual ivy resolution; jars must already be installed.
    def ivy = { map ->
    cache.path + File.separator +
    map.group + File.separator +
    map.module + File.separator +
    "jars" + File.separator +
    "${map.module}-${map.version}.jar"
    }
    // grails plugin classes
    def plugin_classes = new File(
    home + File.separator +
    ".grails" + File.separator +
    GRAILS_VERSION + File.separator + // NOTE: update on grails upgrade
    "projects" + File.separator +
    project.name + File.separator +
    "plugin-classes")

    classpath << plugin_classes.path

    classpath << ivy(group:'com.mycompany', module:'interchange', version:'1.0-SNAPSHOT')
    classpath << ivy(group:'com.mycompany', module:'project' , version:'3.1-SNAPSHOT')
    classpath << ivy(group:'com.mycompany', module:'commons' , version:'3.1-SNAPSHOT')
    classpath << ivy(group:'com.mycompany', module:'testutils' , version:'1.0-SNAPSHOT')
    //installed libraries
    def lib = new File(project.path + File.separator + "lib")
    lib.list().each {name -> classpath << lib.path+File.separator+name}

    //compiled classes
    def target_classes = new File(
    @@ -33,19 +31,39 @@ def target_classes = new File(
    )
    classpath << target_classes.path

    //installed libraries
    def lib = new File(project.path + File.separator + "lib")
    lib.list().each {name -> classpath << lib.path+File.separator+name}
    /* manual ivy resolution */
    //fake ivy dependency loader
    def ivy = { map ->
    cache.path + File.separator +
    map.group + File.separator +
    map.module + File.separator +
    "jars" + File.separator +
    "${map.module}-${map.version}.jar"
    }

    // grails plugin classes
    def plugin_classes = new File(
    home + File.separator +
    ".grails" + File.separator +
    "1.3.5" + File.separator + // NOTE: update on grails upgrade
    "projects" + File.separator +
    "projectname" + File.separator +
    "plugin-classes"
    )
    classpath << plugin_classes.path
    //grails version dependencies
    [
    'grails-bootstrap','grails-core','grails-crud','grails-gorm','grails-spring',
    'grails-test','grails-web'
    ].each { module ->
    classpath << ivy(group:'org.grails',module:module,version: GRAILS_VERSION)
    }

    //spring framework dependencies
    [
    'org.springframework.beans','org.springframework.context','org.springframework.core',
    'org.springframework.jms', 'org.springframework.test','org.springframework.web',
    'org.springframework.web.servlet','spring-tx'
    ].each { module ->
    classpath << ivy(group:'org.springframework',module: module,version:'3.0.3.RELEASE')
    }

    classpath << ivy(group:'commons-lang' ,module: 'commons-lang' ,version: '2.4' )
    classpath << ivy(group:'commons-logging' ,module: 'commons-logging',version: '1.1.1' )
    classpath << ivy(group:'javax.servlet' ,module: 'jsp-api' ,version: '1.2' )
    classpath << ivy(group:'org.apache.ant' ,module: 'ant-junit' ,version: '1.7.1' )
    classpath << ivy(group:'org.hibernate' ,module: 'hibernate-core' ,version: '3.3.1.GA' )
    classpath << ivy(group:'org.jscience' ,module: 'jscience' ,version: '4.3' )
    classpath << ivy(group:'junit' ,module: 'junit' ,version: '4.8.1' )

    return classpath.toArray()
  2. kattrali revised this gist Nov 3, 2010. 1 changed file with 14 additions and 3 deletions.
    17 changes: 14 additions & 3 deletions classpath.groovy
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    // classpath retriever for all jars in project "lib" folder and compiled classes in project,
    // plus a hacky way to load ivy dependencies (until I can get groovy Grape configured properly)

    import groovy.grape.Grape
    import groovy.util.ConfigObject
    import groovy.util.ConfigSlurper
    //import groovy.grape.Grape
    //import groovy.util.ConfigObject
    //import groovy.util.ConfigSlurper

    def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
    def project = redcar_config.parentFile
    @@ -37,4 +37,15 @@ classpath << target_classes.path
    def lib = new File(project.path + File.separator + "lib")
    lib.list().each {name -> classpath << lib.path+File.separator+name}

    // grails plugin classes
    def plugin_classes = new File(
    home + File.separator +
    ".grails" + File.separator +
    "1.3.5" + File.separator + // NOTE: update on grails upgrade
    "projects" + File.separator +
    "projectname" + File.separator +
    "plugin-classes"
    )
    classpath << plugin_classes.path

    return classpath.toArray()
  3. kattrali created this gist Oct 27, 2010.
    40 changes: 40 additions & 0 deletions classpath.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    // classpath retriever for all jars in project "lib" folder and compiled classes in project,
    // plus a hacky way to load ivy dependencies (until I can get groovy Grape configured properly)

    import groovy.grape.Grape
    import groovy.util.ConfigObject
    import groovy.util.ConfigSlurper

    def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
    def project = redcar_config.parentFile
    def classpath = []
    def home = System.getProperty("user.home")
    def cache = new File(home+File.separator+".ivy2"+File.separator+"cache")

    //manual ivy resolution; jars must already be installed.
    def ivy = { map ->
    cache.path + File.separator +
    map.group + File.separator +
    map.module + File.separator +
    "jars" + File.separator +
    "${map.module}-${map.version}.jar"
    }

    classpath << ivy(group:'com.mycompany', module:'interchange', version:'1.0-SNAPSHOT')
    classpath << ivy(group:'com.mycompany', module:'project' , version:'3.1-SNAPSHOT')
    classpath << ivy(group:'com.mycompany', module:'commons' , version:'3.1-SNAPSHOT')
    classpath << ivy(group:'com.mycompany', module:'testutils' , version:'1.0-SNAPSHOT')

    //compiled classes
    def target_classes = new File(
    project.path + File.separator +
    "target" + File.separator +
    "classes"
    )
    classpath << target_classes.path

    //installed libraries
    def lib = new File(project.path + File.separator + "lib")
    lib.list().each {name -> classpath << lib.path+File.separator+name}

    return classpath.toArray()