How can I exclude plugins jar required at build time?

点点圈 提交于 2019-12-06 07:49:32

问题


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?


回答1:


Add to your BuildConfig.groovy:

grails.war.resources = { stagingDir ->
    delete(file:"${stagingDir}/WEB-INF/lib/whatever.jar")
}



回答2:


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()
      }
   }
}


来源:https://stackoverflow.com/questions/15062033/how-can-i-exclude-plugins-jar-required-at-build-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!