You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Mariusz Smykuła (JIRA)" <ji...@apache.org> on 2019/04/03 20:44:00 UTC

[jira] [Created] (MNG-6624) CLONE - Injecting goals into default lifecycle, this is actually possible, but requires hacks

Mariusz Smykuła created MNG-6624:
------------------------------------

             Summary: CLONE - Injecting goals into default lifecycle, this is actually possible, but requires hacks
                 Key: MNG-6624
                 URL: https://issues.apache.org/jira/browse/MNG-6624
             Project: Maven
          Issue Type: Bug
          Components: core
    Affects Versions: 3.3.9
            Reporter: Mariusz Smykuła


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.

{code}
<component>
	<role>org.apache.maven.lifecycle.Lifecycle</role>
	<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
	<role-hint>accurest</role-hint>
	<configuration>
		<id>accurest</id>
		<phases>
			<phase>accurest-not-used-phase</phase>
		</phases>
		<default-phases>
			<process-test-resources>
				io.codearte.accurest:accurest-maven-plugin:${project.version}:convert
			</process-test-resources>
			<generate-test-sources>
				io.codearte.accurest:accurest-maven-plugin:${project.version}:generateTests
			</generate-test-sources>
			<package>
				io.codearte.accurest:accurest-maven-plugin:${project.version}:generateStubs
			</package>
		</default-phases>
	</configuration>
</component>
{code}

I need to define fake phase to make this working: <phase>accurest-not-used-phase</phase>

WIthout this ugly hacks, error occurs in sample project.

Error:
{code}
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)
{code} 


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? 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)