PR: MNG-1322

Submitted By: Allan Ramirez
Reviewed By: John Casey

Applied. Thanks, Allan.

Minor change I made was to throw a MojoFailureException with the offending path, rather than logging to the error message-level.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@330646 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-11-03 21:56:25 +00:00
parent 154fa37604
commit ef942be7aa
1 changed files with 14 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.util.IOUtil;
@ -91,7 +92,7 @@ public class InstallFileMojo
private ArtifactFactory artifactFactory;
public void execute()
throws MojoExecutionException
throws MojoExecutionException, MojoFailureException
{
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, packaging );
@ -131,7 +132,18 @@ public class InstallFileMojo
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
try
{
installer.install( file, artifact, localRepository );
String localPath = localRepository.pathOf( artifact );
File destination = new File( localRepository.getBasedir(), localPath );
if( !file.getPath().equals( destination.getPath() ) )
{
installer.install( file, artifact, localRepository );
}
else
{
throw new MojoFailureException( "Cannot install artifact. Artifact is already in the local repository.\n\nFile in question is: " + file + "\n" );
}
}
catch ( ArtifactInstallationException e )
{