thickGlass
thickGlass

Reputation: 580

Remove a particular jar from plugin on creation of war in Grails

I'm using dynamic-jasper:0.6 with my Grails 2.2.4 application, the plugin is currently importing an older version of mysql-connector mysql-connector-java-5.0.4-bin.jar which in some cases is conflicting with my current connector and creating some problem. I'd like to keep on using the plugin without modifying it but also exclude the particular jar file and only include the library I need. Is there any way to achieve this?

I tried excluding the file from _Events.groovy but it didn't work here is my code

includeTargets << grailsScript("_GrailsInit")

target(main: "The description of the script goes here!") {
    eventCreateWarStart = { name, stagingDir ->
    ant.delete(dir:"${stagingDir}/WEB-INF/lib/", includes: "mysql-connector*.jar", verbose: true)
}
}

setDefaultTarget(main)

Upvotes: 2

Views: 940

Answers (1)

cfrick
cfrick

Reputation: 37033

add in your scripts/_Events.groovy:

eventCreateWarStart = { name, stagingDir ->
    ant.delete(dir:"${stagingDir}/WEB-INF/lib/", includes: "xercesImpl*.jar", verbose: true)
}

Above example is of course for xerces, just change the includes: mask to your liking. In case you already have a closure eventCreateWarStart, only add the ant.delete part.

Yet in the case of the mysql-connector, which most likely is referenced as runtime from your current project, you might as well try to prevent it from bleeding in from the plugin with an exclude, like (BuildConfig.groovy for e.g. an entry in the plugins section):

compile(":vaadin:7.3.9") { excludes 'xercesImpl' }

See http://grails.github.io/grails-doc/2.4.4/guide/conf.html#configurationsAndDependencies for Excluding specific transitive dependencies

Upvotes: 2

Related Questions