Hi Everyone,
I'm experiencing an issue with
maven goals order, that are registered to one phase "clean" that belongs to the clean lifecycle. I have a little project on
EJB. All the beans (indeed, only one stateless bean there) are to be deployed on TomEE AS. So I use tomee-maven-plugin to stop/start the server, deploy/undeploy the jar module. My pom.xml is as follows:
The goal "tomee:stop" stops the server, the goal "tomee:start" starts the server, the goals "tomee:deploy" and "tomee:undeploy" deploy and undeploy my module respectively.
When I execute
It starts the server and deploys application. I can see the result via this command:
But when I try to stop the server and clean the project (mvn clean) first I obtain the error message:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mvn-firstejb-tomee 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ mvn-firstejb-tomee ---
[INFO] Deleting D:\Tmp_f\mvn-firstejb-tomee\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.720s
[INFO] Finished at: Sun May 31 15:01:37 GMT+03:00 2015
[INFO] Final Memory: 4M/115M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project mvn-firstejb-tomee: Failed to clean project: Failed to delete D:\Tmp_f\mvn-firstejb-tomee\target\mvn-firstejb-tomee.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
There are two goals registered to the clean phase of my project. One goal ("tomee:stop") belongs to tomee-maven-plugin and the other("clean:clean") belongs to maven-clean-plugin. I generated effective pom for my project and got that maven-clean-plugin goes after tomee-maven-plugin, so as I understand, it should be executed after tomee plugin:
But nevertheless, maven-clean-plugin is executed first (see the error message above). But the jar module is locked by the server and cannot be deleted.
As per
this link: "The goals that are configured will be added to the goals already bound to the lifecycle from the packaging selected. If more than one goal is bound to a particular phase, the order used is that those from the packaging are executed first, followed by those configured in the POM."
So the goal "clean:clean" is already bound to the clean phase of the clean lifecycle by jar packaging specification. That is why it is executed first.
Could someone please suggest whether it is possible to run goals, specified in the pom.xml before the goals that are assumed by packaging as defaults and what is the workaround for my issue?