Clarification on Maven profiles and Phases
<phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> <phase>post-integration-test</phase> <goals> <goal>stop</goal> <goal>remove</goal> </goals>
<phase>integration-test</phase> <goals> <goal>integration-test</goal> </goals> <phase>verify</phase> <goals> <goal>verify</goal> </goals>
I have profiles for each database type (i.e. MySQL, Postgres etc.). What I’m trying to do is that run my integration tests on docker with each database type.
My question is that, can I run mvn with multiple profiles (i.e.
mvn clean install -P local-postgres,local-mysql), so that each profile is executed one after the other? My requirement is not to have 2 docker containers up at once.
What I observed is that
pre-integration-test phases of all profiles run first, and fails with
The name "/apim-postgres" is already in use by container xxxxx. Is that how maven phases are supposed to work when multiple profiles are given?
Is there a way I can get my requirement fulfilled?
One Solution collect form web for “Clarification on Maven profiles and Phases”
I’m not sure if this will work, but if you define each profile independently it should work. You define each plugin twice, one for each profile. The order of execution depends on various factors. I don’t know where you have defined the profiles, but if they are defined in the same pom then the order should be the one defined in that pom. See https://www.waltercedric.com/index.php?option=com_content&view=article&id=1795&catid=129&Itemid=332 for more help.