[MNG-6013] Injecting goals into default lifecycle, this is actually possible, but requires hacks
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Mariusz Smykuła](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mariuszs)** opened **[MNG-6013](https://issues.apache.org/jira/browse/MNG-6013?redirect=false)** and commented
I have developed plugin, which allows to inject three goals into default lifecycle and extend it. I'm not sure if this is undocumented feature or bug, but this works and I think this is very useful.
Plugin: https://github.com/Codearte/accurest-maven-plugin
Sample project with jar package, without goal defined with extension:true
https://github.com/mariuszs/gs-rest-service-accurest/blob/master/pom.xml
My custom components.xml works, but requires hack to work.
```
org.apache.maven.lifecycle.Lifecycle
org.apache.maven.lifecycle.Lifecycle
accurest
accurest
accurest-not-used-phase
io.codearte.accurest:accurest-maven-plugin:${project.version}:convert
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateTests
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateStubs
```
I need to define fake phase to make this working: \accurest-not-used-phase\
WIthout this ugly hacks, error occurs in sample project.
Error:
```
java.lang.NullPointerException
at org.apache.maven.lifecycle.DefaultLifecycles.getPhaseToLifecycleMap(DefaultLifecycles.java:94)
at org.apache.maven.lifecycle.DefaultLifecycles.get(DefaultLifecycles.java:71)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateLifecycleMappings(DefaultLifecycleExecutionPlanCalculator.java:242)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateMojoExecutions(DefaultLifecycleExecutionPlanCalculator.java:217)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:127)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:145)
at org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan(BuilderCommon.java:96)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:109)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
```
There is related question on stackoverflow: http://stackoverflow.com/questions/36945610/how-to-bind-plugin-mojos-goals-to-few-phases-of-default-lifecycle/36981756#36981756 which describes the problem.
Should we change this bug into feature?
---
**Affects:** 3.3.9
**Issue Links:**
- [MNG-6624](https://issues.apache.org/jira/browse/MNG-6624) CLONE - Injecting goals into default lifecycle, this is actually possible, but requires hacks
(_**"is cloned by"**_)
- [MNG-6624](https://issues.apache.org/jira/browse/MNG-6624) CLONE - Injecting goals into default lifecycle, this is actually possible, but requires hacks
(_**"is duplicated by"**_)
0 votes, 5 watchers
Contributor guide
Assessment
This issue has not been assessed yet.