MNG-406. Remove hardcoded repository location in generated .classpath. Use M2_REPO as eclipse variable

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@170723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-05-18 08:23:27 +00:00
parent c4db798207
commit 32303a7958
5 changed files with 31 additions and 5 deletions

View File

@ -22,10 +22,13 @@ package org.apache.maven.plugin.eclipse;
* SOFTWARE.
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import java.io.File;
/**
* A Maven2 plugin which integrates the use of Maven2 with Eclipse.
*
@ -47,6 +50,13 @@ public class EclipsePlugin
*/
private MavenProject project;
/**
* @parameter expression="${localRepository}"
* @required
* @readonly
*/
private ArtifactRepository localRepository;
public EclipsePlugin()
{
eclipseWriter = new EclipseWriter();
@ -57,6 +67,11 @@ public class EclipsePlugin
this.project = project;
}
public void setLocalRepository( ArtifactRepository localRepository )
{
this.localRepository = localRepository;
}
public void execute()
throws MojoExecutionException
{
@ -67,6 +82,8 @@ public class EclipsePlugin
try
{
eclipseWriter.setLocalRepositoryFile( new File ( localRepository.getBasedir() ) );
eclipseWriter.write( project );
}
catch ( EclipsePluginException e )

View File

@ -45,6 +45,13 @@ import java.util.Set;
*/
public class EclipseWriter
{
private File localRepository;
public void setLocalRepositoryFile( File localRepository )
{
this.localRepository = localRepository;
}
public void write( MavenProject project )
throws EclipsePluginException
{
@ -330,7 +337,7 @@ public class EclipseWriter
writer.addAttribute( "kind", "lib" );
writer.addAttribute( "path", path.getPath().replace( '\\', '/' ) );
writer.addAttribute( "path", "M2_REPO/" + toRelative( localRepository, path.getPath() ) );
writer.endElement();
}

View File

@ -85,7 +85,9 @@ public class EclipsePluginTest
}
plugin.setProject( project );
plugin.setLocalRepository( localRepository );
plugin.execute();
assertFileEquals( localRepository.getBasedir(), new File( basedir, "project" ), new File( basedir, ".project" ) );
@ -128,7 +130,7 @@ public class EclipsePluginTest
while ( (line = reader.readLine()) != null )
{
lines.add( StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) );
lines.add( line );//StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) );
}
return lines;

View File

@ -2,5 +2,5 @@
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
<classpathentry kind="lib" path="#ArtifactRepositoryPath#/maven/jars/maven-core-2.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="M2_REPO/maven/jars/maven-core-2.0-SNAPSHOT.jar"/>
</classpath>

View File

@ -5,5 +5,5 @@
<classpathentry kind="src" path="src/test/resources" output="target/test-classes"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
<classpathentry kind="lib" path="#ArtifactRepositoryPath#/junit/jars/junit-2.0.jar"/>
<classpathentry kind="lib" path="M2_REPO/junit/jars/junit-2.0.jar"/>
</classpath>