Maven execute two modules sequentially

534 views Asked by At

I have two maven projects:

  • One builds a few OSGi bundles and creates a local p2 repository containing them
  • The other builds an Eclipse plugin with tycho using these bundles

When I execute them separately, everything works: the first execution creates the repository, and the second can use it.

But I want to create a single pom executing both. The simple approach:

<modules>
    <module>p2-repository-generator</module>
    <module>tycho-project</module>
</modules>

Doesn't work, because tycho tries to use the repository generated by the first pom even before it exists as described here.

Can I execute two maven tasks sequentially using maven, without external tools? Or can I delay tycho's dependency hook to a later point in the build?

To clarify:

  • tycho-project depends on p2-repository-generator, so it is executed after it.
  • but Tycho uses a custom lifecycle participant, which tries to resolve p2 dependencies with an afterProjectsRead callback - which is too soon, since the p2 repository will be there only after p2-repository-generator built it.
  • This aggretor works after I execute p2-repository-generator once manually, because then tycho-project is able to find the p2 repository generated by it
2

There are 2 answers

0
oberlies On BEST ANSWER

As you correctly noted, Tycho does things very early in the build, which leads to problems if you generate content in the same build to be used by the Tycho build. A workaround for this problem is to wrap the part of the build using Tycho in a maven-invoker-plugin call.

1
Michał Kalinowski On

Did you try setting a dependency on p2-repository-generator for tycho-project? IMHO it should enforce a build sequence you need here.