grailsgant

Using a plugin in a Gant task with Grails


I have a gant task I wrote using:

grails create-script my-script

And I'm using some code from a plugin I have in my build config:

compile ":csv:0.3.1"

However, it isn't on the classpath when I execute my gant script. I have another dependency I'm using in the dependencies like this:

dependencies {
    build 'com.atlassian.jira:jira-rest-java-client-api:2.0.0-m25'
    build 'com.atlassian.jira:jira-rest-java-client-core:2.0.0-m25'
}

That are loaded on the classpath. However, my plugin code isn't. How can I get the plugin code to work with the gant script?

Update:

Here is how my script starts:

includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsClasspath")
includeTargets << grailsScript("_GrailsCompile")

target(main: "Creates JIRA tasks for Content Developers based on given lesson file.") {
    depends(compile)
    ....
}

Solution

  • The fix for this was to use the following:

    includeTargets << grailsScript("_GrailsInit")
    includeTargets << grailsScript("_GrailsBootstrap")
    
    target(main: "Creates JIRA tasks for Content Developers based on given lesson file.") {
        depends( bootstrap )
        ...
    }
    

    However, I had a transitive dependency pulling in spring framework version 2.5.6 which was a mess. And I was getting the following:

    org.codehaus.groovy.grails.commons.spring.GrailsApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;
    

    The fix for that was the following:

    dependencies {
        build( 'com.atlassian.jira:jira-rest-java-client-api:2.0.0-m25' ) {
            excludes([group: "org.springframework", name:"spring-context", version:"2.5.6"],
                     [group:"org.springframework", name:"spring-beans", version:"2.5.6"],
                     [group:"org.springframework", name:"spring-core", version:"2.5.6"])
        }
        build('com.atlassian.jira:jira-rest-java-client-core:2.0.0-m25') {
            excludes([group: "org.springframework", name:"spring-context", version:"2.5.6"],
                     [group:"org.springframework", name:"spring-beans", version:"2.5.6"],
                     [group:"org.springframework", name:"spring-core", version:"2.5.6"])
        }
    }