-
In Eclipse 2024-06, new workspace, when I create a simple maven project with 2 plugins bound to the package phase, one is ignored and one is executed. I thought Eclipse only considers phases up to and including compile as 'interesting', but I couldn't find any documentation about this, only hints here: https://eclipse.dev/m2e/documentation/m2e-execution-not-covered.html I had a look inside the maven-dependency-plugin jar but did not observe any META-INF/m2e lifecycle mapping that could explain the execution. I clearly observe the junit dependency being copied to target/dependency by the Eclipse workspace build (no manual maven execution). Is the maven-dependency-plugin treated special by m2e?
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 1 reply
-
In your screenshot you can see that the antrun plugin is ignored (I assume it has a mapping for that), the dependency plugin is executed because mojos are executed by default if not otherwise specified. |
Beta Was this translation helpful? Give feedback.
-
@laeubi are you sure? that is the core of my question: I thought only plugins bound to "interesting phases" (i.e. up to compile) are executed by eclipse? at least that's what is written in the linked page. |
Beta Was this translation helpful? Give feedback.
-
Thanks for that pointer, that's good to know. So the package phase is an "interesting" phase for m2e? I mean, plugins bound to test/install/deploy are surely never executed by m2e, right? I will check the maven-antrun-plugin... |
Beta Was this translation helpful? Give feedback.
-
I checked the plugin jar and don't see a META-INF/m2e folder. Are there other ways to specify m2e mappings that I can check? |
Beta Was this translation helpful? Give feedback.
-
m2e ship with some default mappings |
Beta Was this translation helpful? Give feedback.
-
I am mainly trying to update my mental model of how m2e is supposed to work with relation to the package phase: I was surprised by the maven-dependency-plugin being executed, because I thought m2e would never automatically execute plugins bound to the package phase. Now you pointed me to the release notes that say that m2e executes all plugins by default, which I think is not the case at least for the test/install/deploy-phases. I believe my custom plugins bound to the package phase are also not executed by default but I have to recheck those. I tried to click on "Open workspace lifecycle mappings metadata" but got an error message and an empty editor. Edit: Now it works (but this mapping is empty). |
Beta Was this translation helpful? Give feedback.
-
Yes it is not always easy when it comes to mappings, but you can open the LifeCycle Mappings as a view to at least get the info what is executed. In this particular case I think the reason is that m2e has a default mapping for So even if the package-phase is "uninteresting" by default, if there is a mapping (either implicit or explicit) m2e can execute mojos in such a phase. So here we have:
|
Beta Was this translation helpful? Give feedback.
-
Ok thanks a lot for linking that m2e mapping file! With this file and the lifecycle mappings view I should be able to answer such questions in the future. This also confirms that:
|
Beta Was this translation helpful? Give feedback.
Yes it is not always easy when it comes to mappings, but you can open the LifeCycle Mappings as a view to at least get the info what is executed.
In this particular case I think the reason is that m2e has a default mapping for
maven-dependency-plugin
here that is used when nothing else is configured.So even if the package-phase is "uninteresting" by default, if there is a mapping (either implicit or explicit) m2e can execute mojos in such a phase.
So here we have:
maven-antrun-plugin:run
has no explicit or implicit binding andpackage
phase is uninteresting ->ignored
maven-dependency-plugin:copy-dependency
has implicitdefault
binding ->execute
regardless of phase.