Hi,

On 24.04.20 14:47, Christian Domsch wrote:
Hi,

I would like to be able to get access to the reactor module tree. I have a
specific plugin that is executed for each reactor module and it needs to
check, if for a predefined set of modules in the reactor (in our case war
archives that contain a subset of all modules) see if the current module is
actually contained in that war (directly or via transitive dependencies).

Can you explain more in detail what the use case is? If an artifact is
part of a war? Why would like to check that? Can be seen in the war module?


What I tried so far, but isn't working, is using the aether dependency
resolution mechanism. The reason why it isn't working is fairly obvious:
checking the transitive dependencies of these war modules, aether tries to
download all artifacts first and fails because they haven't been build by
the reactor, yet, and thus are unknown. This makes a lot of sense, but also
means this way won't help me.

Now, the reactor itself has to be able to calculate those dependencies, as
it will calculate a certain order of building the modules, depending on how
those modules depend on each other. This (what I will call) reactor module
tree is exactly the information I need.

The reactor is the part which contains the parents/modules and order of
building the modules...this can be accessed via:

@Parameter(defaultValue = "${session}", required = true, readonly = true)
MavenSession session;

By using the above session you could:
 * session.getProjectDependencyGraph().getSortedProjects();

The sortedProjects is exactly the order of the reactor ..


If you like to know the dependencies you have to go via dependency
resolution in your plugin:

Something like:

@Mojo(name = "xxx", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST,
    requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe
= true)

The important part is:
requiresDependencyResolution = ResolutionScope.RUNTIME

which you now gives you the option to access the dependencies:

project.getArtifacts();

where mvnProject:

  @Parameter(defaultValue = "${project}", required = true, readonly = true)
  private MavenProject project;

Kind regards
Karl Heinz Marbaise


Is there a way to access this information from a plugin? ${reactorProjects}
does not tell me that. Or am I missing sth very obvious?

Thx,

Christian




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to