From f5980b0ddaa823f1ce1a3cf65de3da59f078dc10 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 7 Nov 2022 20:10:43 +0100 Subject: [PATCH] [MINSTALL-185] Install all artifacts in one request --- .../maven/plugins/install/InstallMojo.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java index d564ff80..299e148b 100644 --- a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java +++ b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java @@ -122,7 +122,9 @@ public void execute() { if ( !installAtEnd ) { - installProject( project ); + InstallRequest request = new InstallRequest(); + processProject( project, request ); + installProject( request ); putState( State.INSTALLED ); } else @@ -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 ); } } @@ -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 ) { @@ -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 ) ) ); @@ -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 )