Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINSTALL-115] Install At End feature (no extension) #15

Merged
merged 17 commits into from Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main/java/org/apache/maven/plugins/install/InstallMojo.java
Expand Up @@ -83,24 +83,30 @@ public class InstallMojo
@Component
private ProjectInstaller installer;

private enum State
{
SKIPPED, INSTALLED, TO_BE_INSTALLED
}

public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( skip )
{
getPluginContext().put( INSTALL_PROCESSED_MARKER, Boolean.FALSE );
getLog().info( "Skipping artifact installation" );
getPluginContext().put( INSTALL_PROCESSED_MARKER, State.SKIPPED.name() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have objects, why not retain the enum, why use name?

Copy link
Member Author

@cstamas cstamas Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These span across several classloaders, there is no single enum.

}
else
{
if ( !installAtEnd )
{
installProject( project );
getPluginContext().put( INSTALL_PROCESSED_MARKER, State.INSTALLED.name() );
}
else
{
getPluginContext().put( INSTALL_PROCESSED_MARKER, Boolean.TRUE );
getLog().info( "Installing " + getProjectReferenceId( project ) + " at end" );
getPluginContext().put( INSTALL_PROCESSED_MARKER, State.TO_BE_INSTALLED.name() );
}
}

Expand All @@ -109,14 +115,8 @@ public void execute()
for ( MavenProject reactorProject : reactorProjects )
{
Map<String, Object> pluginContext = session.getPluginContext( pluginDescriptor, reactorProject );
Boolean install = (Boolean) pluginContext.get( INSTALL_PROCESSED_MARKER );
if ( !install )
{
getLog().info(
"Project " + getProjectReferenceId( reactorProject ) + " skipped install"
);
}
else
State state = State.valueOf( (String) pluginContext.get( INSTALL_PROCESSED_MARKER ) );
if ( state == State.TO_BE_INSTALLED )
{
installProject( reactorProject );
}
Expand Down
Expand Up @@ -91,6 +91,7 @@ public void testBasicInstall()
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
updateMavenProject( project );

setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() );
setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
setVariableValueToObject( mojo, "session", createMavenSession() );
Expand Down Expand Up @@ -124,6 +125,7 @@ public void testBasicInstallWithAttachedArtifacts()
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
updateMavenProject( project );

setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() );
setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
setVariableValueToObject( mojo, "session", createMavenSession() );
Expand Down Expand Up @@ -167,6 +169,7 @@ public void testUpdateReleaseParamSetToTrue()
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
updateMavenProject( project );

setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() );
setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
setVariableValueToObject( mojo, "session", createMavenSession() );
Expand Down Expand Up @@ -194,6 +197,7 @@ public void testInstallIfArtifactFileIsNull()
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
updateMavenProject( project );

setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() );
setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
setVariableValueToObject( mojo, "session", createMavenSession() );
Expand Down Expand Up @@ -231,6 +235,7 @@ public void testInstallIfPackagingIsPom()
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
updateMavenProject( project );

setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() );
setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
setVariableValueToObject( mojo, "session", createMavenSession() );
Expand Down Expand Up @@ -268,6 +273,7 @@ public void testBasicInstallAndCreate()
MavenSession mavenSession = createMavenSession();
updateMavenProject( project );

setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() );
setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
setVariableValueToObject( mojo, "session", mavenSession );
Expand Down