I've set profiles in a pom.xml
, like shown as follows:
<profile> <id><em>profileId1</em></id> <build> <filters> <filter>src/main/filters/<em>profileId1</em>.properties</filter> </filters> // rest of the profile </profile> <profile> <id><em>profileId2</em></id> <build> <filters> <filter>src/main/filters/<em>profileId2</em>.properties</filter> </filters> // rest of the profile </profile>
Question:
Is there any way to extract this piece from all the profiles, so that there is no need to repeat it for every profile (and possibly misspell it)?
Open Maven settings. m2 directory where %USER_HOME% represents the user home directory. If settings. xml file is not there, then create a new one. Add test profile as an active profile using active Profiles node as shown below in example.
A profile in Maven is an alternative set of configuration values which set or override default values. Using a profile, you can customize a build for different environments. Profiles are configured in the pom. xml and are given an identifier.
Or dependencies may be pulled from different repositories based upon the JDK version used. Just put the dependency for the release profile inside the profile declaration itself and do the same for debug .
A - A Build profile is a set of configuration values which can be used to set or override default values of Maven build. B - Using a build profile, you can customize build for different environments such as Production v/s Development environments.
With maven 2.2.1 and later, I was able to get the ID of the first active profile using:
${project.activeProfiles[0].id}
Of course this fails if there is not a least one active profile.
Using the
${project.profiles[0].id}
as suggested by Pascal did not work for me.
Hint: While investigating this, I really started to love mvn help:evaluate
.
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