Reputation: 23323
I have Grails plugin that do some job (precompiles static files) at build time (before war is built). To do its job some jar dependencies are required. So this dependencies are required only at build time. How can I exclude them from final WAR?
Upvotes: 3
Views: 1974
Reputation: 12528
This is best done using script. I had to employ this when deploying a WAR for a production that required excluding jar files.
Create a script file called _Event.groovy under the script directory. Inside the _Event.groovy file, add code to delete jar. BTW, this is event triggered and naming convention has to be followed.
In scripts/_Event.groovy
eventCreateWarStart = { warName, myDir ->
println 'EVENT CALLED!'
File libDir = new File("${myDir}/WEB-INF/lib/")
if (grailsEnv != "development") {
libDir.eachFileMatch( ~/^(tomcat|grails-plugin-tomcat).*\.jar$/) { File jarToRemove ->
println 'REMOVING JAR: ' + jarToRemove
jarToRemove.delete()
}
}
}
Upvotes: 0
Reputation: 8832
Add to your BuildConfig.groovy
:
grails.war.resources = { stagingDir ->
delete(file:"${stagingDir}/WEB-INF/lib/whatever.jar")
}
Upvotes: 8