For our end-2-end test we need to execute the following logical flow:
- Create and set up e2e schema (user) in the database (
pre-integration-test
) - Run Liquibase to initially populate the schema (
pre-integration-test
) - Add e2e-specific test data to the DB tables (
pre-integration-test
) - Start Tomcat (
pre-integration-test
) - Run the web application in Tomcat (
integration-test
) using Protractor - Shut down Tomcat (
post-integration-test
) - Clean up the DB: drop the schema (
post-integration-test
)
For running SQL the sql-maven-plugin
is used, however this flow doesn't fit the regular POM layout:
- The SQL plugin has to run during
pre-integration-test
twice, before and after theliquibase-maven-plugin
- The SQL plugin has to run before Tomcat plugin during
pre-integration-test
, however it has to run after duringpost-integration-test
, so that the DB schema is dropped after Tomcat has shut down.
As far as I could conclude from Maven docs, the order of plugins in the POM defines the order of execution during the same phase, and a plugin cannot be mentioned twice in the same POM.
Question: Is there any way to achieve this, apart from writing a shell script that would invoke Maven multiple times?
P.S. found a similar unanswered question.
Given the sample POM below:
We are actually configuring:
maven-antrun-plugin
to print thehello there!
messageexec-maven-plugin
to print thehello-from-exec
messagemaven-antrun-plugin
to print thehello there 2!
messageGoal executions are all attached to the same phase,
validate
, and we would expect to be executed in the same defined order.However, when invoking (the
-q
option is used to have exactly and only their output):we would have as output:
That is, for the same phase, Maven executed the defined plugins, however merging all of the defined executions for the same plugins (even if defined as different
plugin
sections) and then execute them in the order to merged definitions.Unfortunately, there is no mechanism to avoid this merging. The only options we have for configuring plugins execution behaviors are:
inherited
configuration entry:combine.children
andcombine.self
toNone of these options would help us. In this case we would need a kind of
merge
attribute on theexecution
element or have a different behavior by default (that is, Maven should respect the definition order).Invoking the single executions from command line as below:
We would instead have the desired output:
But in this case:
You can achieve exactly the same via scripting or via exec-maven-plugin invoking maven itself, but - again - the same would apply: no phase applied, only sequence of executions.