mirror of https://github.com/apache/maven.git
When the downloadSources flag was off, also source files available in the local repository were not used.
Fixed so that sources archives available in the local repository are used but no additional jars are downloaded. Added an explanation message on how to turn source downloading on (this should be on by default, but let's wait till there will be more sources archives in the m2 repo) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@330090 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
777d747d1a
commit
f0d674133e
|
@ -19,6 +19,7 @@ package org.apache.maven.plugin.eclipse;
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -237,28 +238,33 @@ public class EclipseClasspathWriter
|
|||
path = "M2_REPO/" //$NON-NLS-1$
|
||||
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, fullPath, false );
|
||||
|
||||
if ( downloadSources )
|
||||
{
|
||||
Artifact sourceArtifact = retrieveSourceArtifact( artifact, remoteArtifactRepositories,
|
||||
localRepository, artifactResolver,
|
||||
artifactFactory );
|
||||
Artifact sourceArtifact = retrieveSourceArtifact( artifact, remoteArtifactRepositories,
|
||||
localRepository, artifactResolver, artifactFactory,
|
||||
downloadSources );
|
||||
|
||||
if ( !sourceArtifact.isResolved() )
|
||||
if ( !sourceArtifact.isResolved() )
|
||||
{
|
||||
if ( downloadSources )
|
||||
{
|
||||
log.info( Messages.getString( "EclipseClasspathWriter.sourcesnotavailable", //$NON-NLS-1$
|
||||
sourceArtifact.getArtifactId() ) );
|
||||
sourceArtifact.getId() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug( Messages.getString( "EclipseClasspathWriter.sourcesavailable", //$NON-NLS-1$
|
||||
new Object[] {
|
||||
sourceArtifact.getArtifactId(),
|
||||
sourceArtifact.getFile().getAbsolutePath() } ) );
|
||||
|
||||
sourcepath = "M2_REPO/" //$NON-NLS-1$
|
||||
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, sourceArtifact.getFile()
|
||||
.getAbsolutePath(), false );
|
||||
log.info( Messages.getString( "EclipseClasspathWriter.sourcesnotdownloaded", //$NON-NLS-1$
|
||||
sourceArtifact.getId() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug( Messages.getString( "EclipseClasspathWriter.sourcesavailable", //$NON-NLS-1$
|
||||
new Object[] {
|
||||
sourceArtifact.getId(),
|
||||
sourceArtifact.getFile().getAbsolutePath() } ) );
|
||||
|
||||
sourcepath = "M2_REPO/" //$NON-NLS-1$
|
||||
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, sourceArtifact.getFile()
|
||||
.getAbsolutePath(), false );
|
||||
|
||||
}
|
||||
|
||||
|
@ -281,7 +287,7 @@ public class EclipseClasspathWriter
|
|||
|
||||
private Artifact retrieveSourceArtifact( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository, ArtifactResolver artifactResolver,
|
||||
ArtifactFactory artifactFactory )
|
||||
ArtifactFactory artifactFactory, boolean downloadSources )
|
||||
throws MojoExecutionException
|
||||
{
|
||||
// source artifact: use the "sources" classifier added by the source plugin
|
||||
|
@ -293,7 +299,8 @@ public class EclipseClasspathWriter
|
|||
log.debug( Messages.getString( "EclipseClasspathWriter.lookingforsources", //$NON-NLS-1$
|
||||
sourceArtifact.getArtifactId() ) );
|
||||
|
||||
artifactResolver.resolve( sourceArtifact, remoteArtifactRepositories, localRepository );
|
||||
artifactResolver.resolve( sourceArtifact, downloadSources ? remoteArtifactRepositories : new ArrayList(),
|
||||
localRepository );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
|
@ -301,7 +308,7 @@ public class EclipseClasspathWriter
|
|||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
String message = Messages.getString( "EclipseClasspathWriter.cantresolvesources", //$NON-NLS-1$
|
||||
new Object[] { sourceArtifact.getArtifactId(), e.getMessage() } );
|
||||
new Object[] { sourceArtifact.getId(), e.getMessage() } );
|
||||
|
||||
log.debug( message, e );
|
||||
}
|
||||
|
@ -309,7 +316,7 @@ public class EclipseClasspathWriter
|
|||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
String message = Messages.getString( "EclipseClasspathWriter.errorresolvingsources", //$NON-NLS-1$
|
||||
new Object[] { sourceArtifact.getArtifactId(), e.getMessage() } );
|
||||
new Object[] { sourceArtifact.getId(), e.getMessage() } );
|
||||
|
||||
throw new MojoExecutionException( message, e );
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ EclipseSettingsWriter.usingdefaults=Not writing settings - defaults suffice
|
|||
|
||||
EclipseClasspathWriter.lookingforsources=Looking for source archive for artifact {0}
|
||||
EclipseClasspathWriter.sourcesnotavailable=Sources for artifact {0} are not available
|
||||
EclipseClasspathWriter.sourcesnotdownloaded=Sources for artifact {0} will not be downloaded.\n Please run "mvn -Declipse.downloadSources=true eclipse:eclipse" in order to check remote repositories for sources.
|
||||
EclipseClasspathWriter.sourcesavailable=Sources attachment for artifact {0} set to {1}
|
||||
|
||||
EclipseProjectWriter.notafile=Not adding a file link to {0}; it is not a file
|
Loading…
Reference in New Issue