mirror of https://github.com/apache/maven.git
make the ordering predictable by sorting the key set.
Switched the key to be the simpler eclipse source root link name. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@240187 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
22365aeefe
commit
b380d0e2d4
|
@ -32,7 +32,9 @@ import java.io.FileOutputStream;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -357,9 +359,11 @@ public class EclipseWriter
|
|||
|
||||
if ( new File( sourceRoot ).isDirectory() )
|
||||
{
|
||||
String eclipseSourceRoot = toRelative( projectBaseDir, sourceRoot );
|
||||
|
||||
// Don't add the same sourceroots twice. No include/exclude
|
||||
// patterns possible in maven for (test|script|)source directories.
|
||||
if ( addedSourceRoots.containsKey( sourceRoot ) )
|
||||
if ( addedSourceRoots.containsKey( eclipseSourceRoot ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -368,14 +372,12 @@ public class EclipseWriter
|
|||
|
||||
writer.addAttribute( "kind", "src" );
|
||||
|
||||
String eclipseSourceRoot = toRelative( projectBaseDir, sourceRoot );
|
||||
|
||||
if (!projectBaseDir.equals(basedir))
|
||||
{
|
||||
eclipseSourceRoot = eclipseSourceRoot.replaceAll( "/", "-" );
|
||||
}
|
||||
|
||||
addedSourceRoots.put( sourceRoot, eclipseSourceRoot );
|
||||
addedSourceRoots.put( eclipseSourceRoot, sourceRoot );
|
||||
|
||||
writer.addAttribute( "path", eclipseSourceRoot );
|
||||
|
||||
|
@ -419,21 +421,21 @@ public class EclipseWriter
|
|||
|
||||
String resourceDir = resource.getDirectory();
|
||||
|
||||
String eclipseResourceDir = toRelative( projectBaseDir, resourceDir );
|
||||
|
||||
// don't add the same sourceroot twice; eclipse can't handle
|
||||
// that, even with mutual exclusive include/exclude patterns.
|
||||
if ( addedSourceRoots.containsKey( resourceDir ) )
|
||||
if ( addedSourceRoots.containsKey( eclipseResourceDir ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String eclipseResourceDir = toRelative( projectBaseDir, resourceDir );
|
||||
|
||||
if ( ! projectBaseDir.equals( basedir ) )
|
||||
{
|
||||
eclipseResourceDir = eclipseResourceDir.replaceAll( "/", "-" );
|
||||
}
|
||||
|
||||
addedSourceRoots.put( resourceDir, eclipseResourceDir );
|
||||
addedSourceRoots.put( eclipseResourceDir, resourceDir );
|
||||
|
||||
writer.startElement( "classpathentry" );
|
||||
|
||||
|
@ -472,13 +474,16 @@ public class EclipseWriter
|
|||
|
||||
private void addSourceLinks( XMLWriter writer, File projectBaseDir, File basedir, Map sourceRoots )
|
||||
{
|
||||
for ( Iterator it = sourceRoots.keySet().iterator(); it.hasNext(); )
|
||||
List roots = new ArrayList( sourceRoots.keySet() );
|
||||
Collections.sort( roots );
|
||||
|
||||
for ( Iterator it = roots.iterator(); it.hasNext(); )
|
||||
{
|
||||
String sourceRoot = (String) it.next();
|
||||
String linkName = (String) it.next();
|
||||
|
||||
String linkName = (String) sourceRoots.get( sourceRoot );
|
||||
String sourceRoot = (String) sourceRoots.get( linkName );
|
||||
|
||||
sourceRoot = sourceRoot.replaceAll("\\\\", "/");
|
||||
sourceRoot = sourceRoot.replace('\\', '/');
|
||||
|
||||
log.debug( "Adding link '" + linkName + "' to '" + sourceRoot + "'" );
|
||||
|
||||
|
|
|
@ -18,14 +18,9 @@
|
|||
<location>${basedir}/src/test/projects/project-4/project.xml</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>src-test-resources</name>
|
||||
<name>src-main-java</name>
|
||||
<type>2</type>
|
||||
<location>${basedir}/src/test/projects/project-4/src/test/resources</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>src-test-java</name>
|
||||
<type>2</type>
|
||||
<location>${basedir}/src/test/projects/project-4/src/test/java</location>
|
||||
<location>${basedir}/src/test/projects/project-4/src/main/java</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>src-main-resources</name>
|
||||
|
@ -33,9 +28,14 @@
|
|||
<location>${basedir}/src/test/projects/project-4/src/main/resources</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>src-main-java</name>
|
||||
<name>src-test-java</name>
|
||||
<type>2</type>
|
||||
<location>${basedir}/src/test/projects/project-4/src/main/java</location>
|
||||
<location>${basedir}/src/test/projects/project-4/src/test/java</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>src-test-resources</name>
|
||||
<type>2</type>
|
||||
<location>${basedir}/src/test/projects/project-4/src/test/resources</location>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
|
|
Loading…
Reference in New Issue