1
votes

Grails 3.2.5. Build.gradle has mail plugin:

compile "org.grails.plugins:mail:2.0.0.RC6"

In deploying a war to production I need to remove javax.mail-1.5.6.jar from WEB-INF/lib since that jar must be in the Tomcat lib when using a JNDI mail resource. So how do I keep the mail plugin but remove the offending jar file from the war? I knew how to do this in Grails 2.x. Via the gradle war task in build.gradle I have tried to exclude the file (doesn't work - the jar drifts in from a plugin somehow), and have tried to filter the file out. When I build the war I get two files - "app-0.1.war" and "app-0.1.war.original". The "original" file has the WEB-INF/lib/javax.mail jar filtered out, but the real, complete war still has it.

So how do I prevent that plugin jar from getting into the war file? Thanks.

1

1 Answers

1
votes

One way to do it is with something like this:

war {
    rootSpec.exclude '**/javax.mail*.jar'
}

(you may need to adjust depending on whether or not you want to also exclude the javax.mail-api jar file along with the javax.mail jar)

See https://github.com/jeffbrown/excludejar/blob/67734ac0c65cdbead468f1e65bcfc29041cd2279/build.gradle#L70-L72