You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2022/10/20 07:21:52 UTC
[maven-install-plugin] 01/01: Fix installAtEnd when module does not use m-install-p
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch fix-module-wo-install
in repository https://gitbox.apache.org/repos/asf/maven-install-plugin.git
commit 3418b79bc5c5c4107935495e00c95e5071be9757
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Oct 20 09:21:32 2022 +0200
Fix installAtEnd when module does not use m-install-p
---
.../org/apache/maven/plugins/install/InstallMojo.java | 16 +++++++++++++++-
.../apache/maven/plugins/install/InstallMojoTest.java | 10 ++++++++--
2 files changed, 23 insertions(+), 3 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 a6c694b..c4c42b0 100644
--- a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
+++ b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
@@ -20,6 +20,7 @@ package org.apache.maven.plugins.install;
*/
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -149,7 +150,7 @@ public class InstallMojo
private boolean allProjectsMarked()
{
- for ( MavenProject reactorProject : reactorProjects )
+ for ( MavenProject reactorProject : allProjectsUsingPlugin() )
{
if ( !hasState( reactorProject ) )
{
@@ -159,6 +160,19 @@ public class InstallMojo
return true;
}
+ private List<MavenProject> allProjectsUsingPlugin()
+ {
+ ArrayList<MavenProject> result = new ArrayList<>();
+ for ( MavenProject reactorProject : reactorProjects )
+ {
+ if ( reactorProject.getPlugin( "org.apache.maven.plugins:maven-install-plugin" ) != null )
+ {
+ result.add( reactorProject );
+ }
+ }
+ return result;
+ }
+
private void installProject( MavenProject project ) throws MojoExecutionException, MojoFailureException
{
try
diff --git a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
index 57fe471..ead646e 100644
--- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
@@ -31,8 +31,9 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
@@ -47,11 +48,11 @@ import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
+import org.junit.Ignore;
/**
* @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
*/
-
public class InstallMojoTest
extends AbstractMojoTestCase
{
@@ -381,5 +382,10 @@ public class InstallMojoTest
project.setGroupId( project.getArtifact().getGroupId() );
project.setArtifactId( project.getArtifact().getArtifactId() );
project.setVersion( project.getArtifact().getVersion() );
+
+ Plugin plugin = new Plugin();
+ plugin.setArtifactId( "maven-install-plugin" );
+ project.setBuild( new Build() );
+ project.getBuild().addPlugin( plugin );
}
}