Maven profiles provide a way to define properties that can be selected from the command-line by just passing in the profile id.
We will see an example for the same to understand it better and also see how the properties can be substituted by maven configuration.
The profiles can be activated using the -P flag.
Example:
mvn clean package
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running prismoskills.TestConfiguration
Properties read:
prop1=${prop1.val}
prop2=${prop2.val}
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.176 sec
mvn clean -Pprofile1 package
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running prismoskills.TestConfiguration
Properties read:
prop1=1
prop2=2
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.175 sec
mvn clean -Pprofile2 package
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running prismoskills.TestConfiguration
Properties read:
prop1=One
prop2=Two
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.169 sec
Got a thought to share or found a bug in the code? We'd love to hear from you: