I have to different log4j.xml and property files which are to be used in Dev and Production. I am using maven for building and packaging. Is there a way I can let maven choose dev or prod by a configurable maven property in POM or passing a run time variable?
Thanks, Abi
The idea based on profiles in Maven is not the best, cause that would force you to run your build a couple of times which means if you have two environments you have to run your build twice if you have more just think about this. The best solution is to work with the Maven-Assembly-Plugin to create a set of artifacts for the different environments in a single step which will be distinct by the classifier. I have made a complete example here.
Yes, use Maven profiles.
Profiles are specified using a subset of the elements available in the POM itself (plus one extra section), and are triggered in any of a variety of ways. They modify the POM at build time, and are meant to be used in complementary sets to give equivalent-but-different parameters for a set of target environments (providing, for example, the path of the appserver root in the development, testing, and production environments).
As an alternative to profiles, which allows you to choose either "dev" or "prod" during your build, you might consider using the maven-assembly-plugin so that you can build both "dev" and "prod" assemblies every time you build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With