English 中文(简体)
Execute goal on parent after children complete
原标题:

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before proceeding with the children.

I want to be able to define a goal that runs on the parent, but not until all of the children have been processed. Is there a way to do this?

Specifically, what I want to do is run an exec:exec goal which recurses down the filesystem looking for test result files and copies them to a central location for aggregation by our CI system (cruisecontrol). So, alternative solutions to this problem are also welcome :)

UPDATE: I forgot to mention one requirement: I need the exec goal to run regardless of whether the build is successful or not.

最佳回答

Based on the other answers and my own subsequent investigation, it doesn t look like what I described is possible with Maven.

However, I was able to solve my problem, although the solution is specific to cruisecontrol. Basically, I bound my exec goal to the pre-site phase then specified pre-site as the sitegoal in my cruisecontrol configuration. The sitegoal runs after the main goal, and does so regardless of whether the build succeeds or not.

I imagine other CI systems offer something similar..

问题回答

I don t think it s possible to do things from the parent at the end of a multi-modules build (this is just not how things work). However, did you consider adding a module (that could be of type pom) depending on all child projects (so it will be the "last" project in a reactor build) and run exec:exec in this module? I may be missing something be I don t see why this wouldn t work.

Sounds more like a reporting plugin. Creating a Maven plugin is actually quite easy.

Why not have a antrun copy step attached to the verify phase of each sub project to copy the results up to the parent location. You could then have a similiar step in the parent to do the CI aggregation.

Alternatively, you could have each sub project do its own CI integration using a simliar techneque.

We currenyly use the technique to generate websphere ejb stubs for a jar, amongst other things.





相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签