You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Christoph Läubrich (Jira)" <ji...@apache.org> on 2022/07/09 06:08:00 UTC
[jira] [Created] (MNG-7510) Enhance AbstractMavenLifecycleParticipant to watch for buildProject events
Christoph Läubrich created MNG-7510:
---------------------------------------
Summary: Enhance AbstractMavenLifecycleParticipant to watch for buildProject events
Key: MNG-7510
URL: https://issues.apache.org/jira/browse/MNG-7510
Project: Maven
Issue Type: New Feature
Reporter: Christoph Läubrich
Currently Tycho injects some dependencies into the maven model at a very early state. As this computation is time consuming, it has several drawbacks:
# Even if one executes some goals that do not require the resolving of these artifacts, the computation is performed
# If computation fails for one module the whole build fails, so flags like -fae are not really usable and implementing such support directly is very complex
# If running a parallel build, the build can't start unless we have computed all modules
For this I have now prototype a new approach that only computes the absolute necessary parts and delays the heavy computation into a mojo called in the initialization phase of the life-cycle. This works quite well but currently requires some hacks:
# I need to force maven to throw away all resolved state because otherwise later injected dependencies are missing, I'm currently use project.setDependencyArtifacts(null); for this but of course it feels like waste of throw away all the data and rely on internal behavior of maven
# other maven tools are not aware of this (e.g. dependency:list) and if I execute such one, the user needs to add an explicitly manual mojo execution
Because of this, I like to discuss/suggest a way for a project scoped extension to participate in the collection of DependencyArtifacts.
For now, I found two possible "vectors":
# DefaultProjectArtifactFactory currently converts Artifact out of the Dependency and it seems one might want to hook in here to provide additional Artifact/Dependency, but it seems to be to narrow to be useful in general.
# LifecycleDependencyResolver.resolveProjectDependencies(MavenProject, Collection<String>, Collection<String>, MavenSession, boolean, Set<Artifact>) seems the most suitable place as it actually do the computation and checks.
# LifecycleModuleBuilder#buildProject is actually the most valuable / generic place I think as it would also allow other use-cases where one want to get notified about a project build started, and as AbstractMavenLifecycleParticipant is abstract an extension here would even be backward-compatible and wont require any new interfaces/services/... to be created.
I'm in favor of option (3) but still wanted to still explain how I got there of course and feedback/ideas are appreciated! I'll try to provide a PR for (3) as well so one could maybe better discuss on the actual code changes.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)