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/07/05 12:43:26 UTC
[maven-install-plugin] 01/01: Make plugin simpler
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch full-resolver
in repository https://gitbox.apache.org/repos/asf/maven-install-plugin.git
commit a32f8c26840314b069846e92ed7c7ec1a0152f25
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Jul 5 14:43:08 2022 +0200
Make plugin simpler
---
.../maven/plugins/install/AbstractInstallMojo.java | 115 +--------------
.../maven/plugins/install/InstallFileMojo.java | 160 ++++++---------------
.../apache/maven/plugins/install/InstallMojo.java | 18 +++
.../apache/maven/plugins/install/Installer.java | 143 ++++++++++++++++++
.../maven/plugins/install/InstallFileMojoTest.java | 5 +
.../maven/plugins/install/InstallMojoTest.java | 3 +-
6 files changed, 217 insertions(+), 227 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/install/AbstractInstallMojo.java b/src/main/java/org/apache/maven/plugins/install/AbstractInstallMojo.java
index 7143461..28aa4f3 100644
--- a/src/main/java/org/apache/maven/plugins/install/AbstractInstallMojo.java
+++ b/src/main/java/org/apache/maven/plugins/install/AbstractInstallMojo.java
@@ -19,24 +19,11 @@ package org.apache.maven.plugins.install;
* under the License.
*/
-import java.io.File;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.artifact.ProjectArtifact;
-import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.installation.InstallRequest;
-import org.eclipse.aether.installation.InstallationException;
-import org.eclipse.aether.util.artifact.SubArtifact;
/**
* Common fields for installation mojos.
@@ -49,105 +36,9 @@ public abstract class AbstractInstallMojo
@Component
protected RepositorySystem repositorySystem;
+ @Component
+ protected Installer installer;
+
@Parameter( defaultValue = "${session}", required = true, readonly = true )
protected MavenSession session;
-
- /**
- * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist
- * (yet).
- *
- * @param artifact The artifact whose local repo path should be determined, must not be <code>null</code>.
- * @return The absolute path to the artifact when installed, never <code>null</code>.
- */
- protected File getLocalRepoFile( Artifact artifact )
- {
- String path = session.getRepositorySession().getLocalRepositoryManager()
- .getPathForLocalArtifact( RepositoryUtils.toArtifact( artifact ) );
- return new File( session.getRepositorySession().getLocalRepository().getBasedir(), path );
- }
-
- /**
- * Gets the path of the specified artifact metadata within the local repository. Note that the returned path need
- * not exist (yet).
- *
- * @param metadata The artifact metadata whose local repo path should be determined, must not be <code>null</code>.
- * @return The absolute path to the artifact metadata when installed, never <code>null</code>.
- */
- protected File getLocalRepoFile( ProjectArtifactMetadata metadata )
- {
- DefaultArtifact pomArtifact = new DefaultArtifact(
- metadata.getGroupId(),
- metadata.getArtifactId(),
- "",
- "pom",
- metadata.getBaseVersion() );
-
- String path = session.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(
- pomArtifact );
- return new File( session.getRepositorySession().getLocalRepository().getBasedir(), path );
- }
-
- protected void installProject( MavenProject project )
- throws MojoFailureException, MojoExecutionException
- {
- try
- {
- InstallRequest request = new InstallRequest();
- Artifact artifact = project.getArtifact();
- String packaging = project.getPackaging();
- File pomFile = project.getFile();
- boolean isPomArtifact = "pom".equals( packaging );
-
- if ( pomFile != null )
- {
- request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) );
- }
-
- if ( !isPomArtifact )
- {
- File file = artifact.getFile();
-
- // Here, we have a temporary solution to MINSTALL-3 (isDirectory() is true if it went through compile
- // but not package). We are designing in a proper solution for Maven 2.1
- if ( file != null && file.isFile() )
- {
- org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact );
- request.addArtifact( mainArtifact );
-
- for ( Object metadata : artifact.getMetadataList() )
- {
- if ( metadata instanceof ProjectArtifactMetadata )
- {
- org.eclipse.aether.artifact.Artifact pomArtifact =
- new SubArtifact( mainArtifact, "", "pom" );
- pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
- request.addArtifact( pomArtifact );
- }
- }
- }
- else if ( !project.getAttachedArtifacts().isEmpty() )
- {
- throw new MojoExecutionException( "The packaging plugin for this project did not assign "
- + "a main file to the project but it has attachments. Change packaging to 'pom'." );
- }
- else
- {
- throw new MojoExecutionException( "The packaging for this project did not assign "
- + "a file to the build artifact" );
- }
- }
-
- for ( Artifact attached : project.getAttachedArtifacts() )
- {
- getLog().debug( "Attaching for install: " + attached.getId() );
- request.addArtifact( RepositoryUtils.toArtifact( attached ) );
- }
-
- repositorySystem.install( session.getRepositorySession(), request );
- }
- catch ( InstallationException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
- }
}
diff --git a/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java b/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java
index c6d527d..5591631 100644
--- a/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java
+++ b/src/main/java/org/apache/maven/plugins/install/InstallFileMojo.java
@@ -32,28 +32,14 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
-import org.apache.maven.model.building.ModelBuildingException;
-import org.apache.maven.model.building.ModelSource;
-import org.apache.maven.model.building.StringModelSource;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.XmlStreamReader;
@@ -61,8 +47,16 @@ import org.codehaus.plexus.util.xml.XmlStreamWriter;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.eclipse.aether.DefaultRepositoryCache;
import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactType;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.DefaultArtifactType;
+import org.eclipse.aether.installation.InstallRequest;
+import org.eclipse.aether.installation.InstallationException;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.util.artifact.SubArtifact;
/**
* Installs a file in the local repository.
@@ -161,21 +155,7 @@ public class InstallFileMojo
@Parameter( property = "localRepositoryPath" )
private File localRepositoryPath;
- /**
- * Used for attaching the artifacts to install to the project.
- */
- @Component
- private MavenProjectHelper projectHelper;
-
- /**
- * Used for creating the project to which the artifacts to install will be attached.
- */
- @Component
- private ProjectBuilder projectBuilder;
-
- /**
- * @see org.apache.maven.plugin.Mojo#execute()
- */
+ @Override
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -186,6 +166,7 @@ public class InstallFileMojo
throw new MojoFailureException( message );
}
+ RepositorySystemSession repositorySystemSession = session.getRepositorySession();
if ( localRepositoryPath != null )
{
// "clone" repository session and replace localRepository
@@ -202,8 +183,7 @@ public class InstallFileMojo
LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager( newSession,
new LocalRepository( localRepositoryPath, contentType ) );
newSession.setLocalRepositoryManager( localRepositoryManager );
- this.session = new MavenSession(
- session.getContainer(), newSession, session.getRequest(), session.getResult() );
+ repositorySystemSession = newSession;
}
File temporaryPom = null;
@@ -218,65 +198,54 @@ public class InstallFileMojo
pomFile = temporaryPom;
}
- MavenProject project = createMavenProject();
-
- // We need to set a new ArtifactHandler otherwise
- // the extension will be set to the packaging type
- // which is sometimes wrong.
- DefaultArtifactHandler ah = new DefaultArtifactHandler( packaging );
- ah.setExtension( FileUtils.getExtension( file.getName() ) );
-
- project.getArtifact().setArtifactHandler( ah );
- Artifact artifact = project.getArtifact();
-
- if ( file.equals( getLocalRepoFile( artifact ) ) )
+ if ( groupId == null || artifactId == null || version == null || packaging == null )
{
- throw new MojoFailureException( "Cannot install artifact. "
- + "Artifact is already in the local repository." + LS + LS + "File in question is: " + file + LS );
+ throw new MojoExecutionException( "The artifact information is incomplete: 'groupId', 'artifactId', "
+ + "'version' and 'packaging' are required." );
}
- if ( classifier == null )
+ InstallRequest installRequest = new InstallRequest();
+
+ ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry().get( packaging );
+ if ( artifactType == null )
{
- artifact.setFile( file );
- if ( "pom".equals( packaging ) )
- {
- project.setFile( file );
- }
+ artifactType = new DefaultArtifactType(
+ packaging, FileUtils.getExtension( file.getName() ), classifier, "none"
+ );
}
- else
+
+ Artifact mainArtifact = new DefaultArtifact(
+ groupId,
+ artifactId,
+ classifier,
+ null,
+ version,
+ artifactType
+ ).setFile( file );
+ installRequest.addArtifact( mainArtifact );
+
+ File artifactLocalFile = installer.getLocalRepositoryFile( session.getRepositorySession(), mainArtifact );
+ File pomLocalFile = installer.getPomLocalRepositoryFile( session.getRepositorySession(), mainArtifact );
+
+ if ( file.equals( artifactLocalFile ) )
{
- projectHelper.attachArtifact( project, packaging, classifier, file );
+ throw new MojoFailureException( "Cannot install artifact. "
+ + "Artifact is already in the local repository." + LS + LS + "File in question is: " + file + LS );
}
if ( !"pom".equals( packaging ) )
{
if ( pomFile != null )
{
- if ( classifier == null )
- {
- artifact.addMetadata( new ProjectArtifactMetadata( artifact, pomFile ) );
- }
- else
- {
- project.setFile( pomFile );
- }
+ installRequest.addArtifact( new SubArtifact( mainArtifact, "", "pom", pomFile ) );
}
else
{
- temporaryPom = generatePomFile();
- ProjectArtifactMetadata pomMetadata = new ProjectArtifactMetadata( artifact, temporaryPom );
- if ( Boolean.TRUE.equals( generatePom )
- || ( generatePom == null && !getLocalRepoFile( pomMetadata ).exists() ) )
+ if ( Boolean.TRUE.equals( generatePom ) || ( generatePom == null && !pomLocalFile.exists() ) )
{
+ temporaryPom = generatePomFile();
getLog().debug( "Installing generated POM" );
- if ( classifier == null )
- {
- artifact.addMetadata( pomMetadata );
- }
- else
- {
- project.setFile( temporaryPom );
- }
+ installRequest.addArtifact( new SubArtifact( mainArtifact, "", "pom", temporaryPom ) );
}
else if ( generatePom == null )
{
@@ -287,19 +256,19 @@ public class InstallFileMojo
if ( sources != null )
{
- projectHelper.attachArtifact( project, "jar", "sources", sources );
+ installRequest.addArtifact( new SubArtifact( mainArtifact, "sources", "jar", sources ) );
}
if ( javadoc != null )
{
- projectHelper.attachArtifact( project, "jar", "javadoc", javadoc );
+ installRequest.addArtifact( new SubArtifact( mainArtifact, "javadoc", "jar", javadoc ) );
}
try
{
- installProject( project );
+ repositorySystem.install( repositorySystemSession, installRequest );
}
- catch ( Exception e )
+ catch ( InstallationException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
@@ -313,43 +282,6 @@ public class InstallFileMojo
}
}
- /**
- * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version. When a classifier is
- * supplied, the packaging must be POM because the project with only have attachments. This project serves as basis
- * to attach the artifacts to install to.
- *
- * @return The created Maven project, never <code>null</code>.
- * @throws MojoExecutionException When the model of the project could not be built.
- * @throws MojoFailureException When building the project failed.
- */
- private MavenProject createMavenProject()
- throws MojoExecutionException, MojoFailureException
- {
- if ( groupId == null || artifactId == null || version == null || packaging == null )
- {
- throw new MojoExecutionException( "The artifact information is incomplete: 'groupId', 'artifactId', "
- + "'version' and 'packaging' are required." );
- }
- ModelSource modelSource = new StringModelSource( "<project><modelVersion>4.0.0</modelVersion><groupId>"
- + groupId + "</groupId><artifactId>" + artifactId + "</artifactId><version>" + version
- + "</version><packaging>" + ( classifier == null ? packaging : "pom" ) + "</packaging></project>" );
- ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
- pbr.setProcessPlugins( false );
- try
- {
- return projectBuilder.build( modelSource, pbr ).getProject();
- }
- catch ( ProjectBuildingException e )
- {
- if ( e.getCause() instanceof ModelBuildingException )
- {
- throw new MojoExecutionException( "The artifact information is not valid:" + LS
- + e.getCause().getMessage() );
- }
- throw new MojoFailureException( "Unable to create the project.", e );
- }
- }
-
private File readingPomFromJarFile()
throws MojoExecutionException
{
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 51d15ce..f01d6c9 100644
--- a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
+++ b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
@@ -29,6 +29,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
+import org.eclipse.aether.installation.InstallationException;
/**
* Installs the project's main artifact, and any other artifacts attached by other plugins in the lifecycle, to the
@@ -92,6 +93,7 @@ public class InstallMojo
return pluginContext.containsKey( INSTALL_PROCESSED_MARKER );
}
+ @Override
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -147,6 +149,22 @@ public class InstallMojo
return true;
}
+ private void installProject( MavenProject project ) throws MojoExecutionException, MojoFailureException
+ {
+ try
+ {
+ repositorySystem.install( session.getRepositorySession(), installer.processProject( project ) );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ throw new MojoFailureException( e.getMessage(), e );
+ }
+ catch ( InstallationException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ }
+
public void setSkip( boolean skip )
{
this.skip = skip;
diff --git a/src/main/java/org/apache/maven/plugins/install/Installer.java b/src/main/java/org/apache/maven/plugins/install/Installer.java
new file mode 100644
index 0000000..66568a2
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/install/Installer.java
@@ -0,0 +1,143 @@
+package org.apache.maven.plugins.install;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import java.io.File;
+
+import org.apache.maven.RepositoryUtils;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.ProjectArtifact;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.installation.InstallRequest;
+import org.eclipse.aether.util.artifact.SubArtifact;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Installer component.
+ */
+@Singleton
+@Named
+public class Installer
+{
+ private final Logger logger = LoggerFactory.getLogger( getClass() );
+
+ /**
+ * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist
+ * (yet).
+ *
+ * @param artifact The artifact whose local repo path should be determined, must not be <code>null</code>.
+ * @return The absolute path to the artifact when installed, never <code>null</code>.
+ */
+ public File getLocalRepositoryFile( RepositorySystemSession session, Artifact artifact )
+ {
+ String path = session.getLocalRepositoryManager().getPathForLocalArtifact( artifact );
+ return new File( session.getLocalRepository().getBasedir(), path );
+ }
+
+ /**
+ * Gets the path of the specified artifact POM within the local repository. Note that the returned path need
+ * not exist (yet).
+ *
+ * @param artifact The artifact whose POM local repo path should be determined, must not be <code>null</code>.
+ * @return The absolute path to the artifact POM when installed, never <code>null</code>.
+ */
+ public File getPomLocalRepositoryFile( RepositorySystemSession session, Artifact artifact )
+ {
+ SubArtifact pomArtifact = new SubArtifact( artifact, "", "pom" );
+ String path = session.getLocalRepositoryManager().getPathForLocalArtifact( pomArtifact );
+ return new File( session.getLocalRepository().getBasedir(), path );
+ }
+
+ /**
+ * Processes passed in {@link MavenProject} and produces {@link InstallRequest} out of it.
+ *
+ * @throws IllegalArgumentException if project is badly set up.
+ */
+ public InstallRequest processProject( MavenProject project )
+ {
+ InstallRequest request = new InstallRequest();
+ org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact();
+ String packaging = project.getPackaging();
+ File pomFile = project.getFile();
+ boolean isPomArtifact = "pom".equals( packaging );
+ boolean pomArtifactAttached = false;
+
+ if ( pomFile != null )
+ {
+ request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) );
+ pomArtifactAttached = true;
+ }
+
+ if ( !isPomArtifact )
+ {
+ File file = mavenMainArtifact.getFile();
+ if ( file != null && file.isFile() )
+ {
+ Artifact mainArtifact = RepositoryUtils.toArtifact( mavenMainArtifact );
+ request.addArtifact( mainArtifact );
+
+ if ( !pomArtifactAttached )
+ {
+ for ( Object metadata : mavenMainArtifact.getMetadataList() )
+ {
+ if ( metadata instanceof ProjectArtifactMetadata )
+ {
+ request.addArtifact( new SubArtifact(
+ mainArtifact,
+ "",
+ "pom"
+ ).setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ) );
+ pomArtifactAttached = true;
+ }
+ }
+ }
+ }
+ else if ( !project.getAttachedArtifacts().isEmpty() )
+ {
+ throw new IllegalArgumentException( "The packaging plugin for this project did not assign "
+ + "a main file to the project but it has attachments. Change packaging to 'pom'." );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "The packaging for this project did not assign "
+ + "a file to the build artifact" );
+ }
+ }
+
+ if ( !pomArtifactAttached )
+ {
+ throw new IllegalArgumentException( "The POM could not be attached" );
+ }
+
+ for ( org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts() )
+ {
+ logger.debug( "Attaching for install: " + attached.getId() );
+ request.addArtifact( RepositoryUtils.toArtifact( attached ) );
+ }
+
+ return request;
+ }
+}
diff --git a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
index c135d95..9ed4b6e 100644
--- a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
@@ -31,9 +31,11 @@ import org.apache.maven.project.ProjectBuildingRequest;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.artifact.DefaultArtifactType;
import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
+import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -291,6 +293,9 @@ public class InstallFileMojoTest
repositorySession, new LocalRepository( LOCAL_REPO )
)
);
+ DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
+ stereotypes.add( new DefaultArtifactType( "pom" ) );
+ repositorySession.setArtifactTypeRegistry( stereotypes );
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
buildingRequest.setRepositorySession( repositorySession );
when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
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 6fea289..6da54a8 100644
--- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
@@ -32,6 +32,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.execution.MavenSession;
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;
import org.apache.maven.plugins.install.stubs.AttachedArtifactStub0;
@@ -214,7 +215,7 @@ public class InstallMojoTest
fail( "Did not throw mojo execution exception" );
}
- catch ( MojoExecutionException e )
+ catch ( MojoFailureException e )
{
//expected
}