I'm converting an Ant webapp project over to Maven. I have most of it working, but I'm stuck trying to figure out how to copy some resource files from different sources based on the profile.
I have src/main/resources/persistence-{dev, prod}.xml
. One of these needs to be included in the war file as WEB-INF/classes/META-INF/persistence.xml
.
I would like the dev version to be copied when the dev profile is active, and the prod version when prod is active.
Profiles can be activated in the Maven settings, via the <activeProfiles> section. This section takes a list of <activeProfile> elements, each containing a profile-id inside. Profiles listed in the <activeProfiles> tag would be activated by default every time a project use it.
We can create multiple profiles by declaring id inside <profile> </profile> tag. This <profile> tag should be enclosed between <profiles></profiles> tag. In this above code, We have created a profile with name User1 and declared spring dependency for that specific user.
Just use the maven resources plugin like so http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html and have a property for the file name or extension set in a profile.
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