How can I exclude plugins jar required at build time?

早过忘川 提交于 2019-12-04 13:39:13

Add to your BuildConfig.groovy:

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

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