Skip to content

Commit

Permalink
[MINSTALL-185] Install all artifacts in one request
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Nov 8, 2022
1 parent 569b31a commit f5980b0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/org/apache/maven/plugins/install/InstallMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public void execute()
{
if ( !installAtEnd )
{
installProject( project );
InstallRequest request = new InstallRequest();
processProject( project, request );
installProject( request );
putState( State.INSTALLED );
}
else
Expand All @@ -137,14 +139,16 @@ public void execute()

if ( allProjectsMarked( allProjectsUsingPlugin ) )
{
InstallRequest request = new InstallRequest();
for ( MavenProject reactorProject : allProjectsUsingPlugin )
{
State state = getState( reactorProject );
if ( state == State.TO_BE_INSTALLED )
{
installProject( reactorProject );
processProject( reactorProject, request );
}
}
installProject( request );
}
}

Expand Down Expand Up @@ -190,11 +194,11 @@ private boolean hasExecution( Plugin plugin )
return false;
}

private void installProject( MavenProject project ) throws MojoExecutionException
private void installProject( InstallRequest request ) throws MojoExecutionException
{
try
{
repositorySystem.install( session.getRepositorySession(), processProject( project ) );
repositorySystem.install( session.getRepositorySession(), request );
}
catch ( InstallationException e )
{
Expand All @@ -203,14 +207,12 @@ private void installProject( MavenProject project ) throws MojoExecutionExceptio
}

/**
* Processes passed in {@link MavenProject} and produces {@link InstallRequest} out of it.
* Processes passed in {@link MavenProject} and prepares content of {@link InstallRequest} out of it.
*
* @throws MojoExecutionException if project is badly set up.
*/
private InstallRequest processProject( MavenProject project ) throws MojoExecutionException
private void processProject( MavenProject project, InstallRequest request ) throws MojoExecutionException
{
InstallRequest request = new InstallRequest();

if ( isFile( project.getFile() ) )
{
request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) );
Expand Down Expand Up @@ -245,8 +247,6 @@ else if ( !project.getAttachedArtifacts().isEmpty() )
getLog().debug( "Attaching for install: " + attached.getId() );
request.addArtifact( RepositoryUtils.toArtifact( attached ) );
}

return request;
}

private boolean isFile( File file )
Expand Down

0 comments on commit f5980b0

Please # to comment.