User51610
User51610

Reputation: 503

Support multiple application servers through Maven

We have a Java web application that is deployed on Wildfly. However, one client now wants to use WebSphere. We've found that the included jar files in the lib folder of our war file need to be a little different between Wildfly and WebSphere - WebSphere doesn't like having some of the libs that Wildfly is fine with (different libraries provided by the AS?).

We would like to automate this as much as possible, although I assume there's probably going to be some manual fiddling in a pom.xml or build.xml file when it comes time to build for one or the other. But is there a good, sane way to filter the jar files appropriately? The only thing I can think of is using <exclusions> in the pom.xml file, but I don't see how to sensibly control that if I want to build for one AS vs the other, other than just commenting a bunch of <exclusions> or <scope>s out, which seems impractical.

Is it possible to do this through Maven somehow, in a nearly totally automated fashion? Or what's the best way?

Upvotes: 0

Views: 124

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35843

Use build profiles.

They allow you to activate/deactivate parts of the POM. So you define a profile websphere and a profile wildfly. You put the vendor specific dependencies into the profiles (you can also put the same dependency in each of the profiles with different exclusions).

You can then activate/deactivate the profiles either from the command line, from the settings.xml or through the presence of absence of a given file.

Upvotes: 3

Related Questions