In my maven project, I have multiple maven profiles. In each profile, I have docker-maven-plugin
and maven-failsafe-plugin
. This is how I have bound goals and phases.
docker-maven-plugin
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
<goal>remove</goal>
</goals>
maven-failsafe-plugin
<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?