forked from tesla/m2e-core-tests
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNGECLIPSE-2144] New versions of the maven-resources-plugin are brok…
…en on Windows
- Loading branch information
bentmann
committed
Mar 16, 2010
1 parent
f73d498
commit 3881e4b
Showing
4 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...e.eclipse.tests/src/org/maven/ide/eclipse/builder/EclipseIncrementalBuildContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2008 Sonatype, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
|
||
package org.maven.ide.eclipse.builder; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import org.codehaus.plexus.util.Scanner; | ||
import org.eclipse.core.resources.IProject; | ||
import org.maven.ide.eclipse.tests.common.AbstractMavenProjectTestCase; | ||
|
||
|
||
@SuppressWarnings("restriction") | ||
public class EclipseIncrementalBuildContextTest extends AbstractMavenProjectTestCase { | ||
|
||
public void testScanner() throws Exception { | ||
IProject project = importProject("projects/MNGECLIPSE-2144/pom.xml"); | ||
|
||
ResourceDeltaStub delta = new ResourceDeltaStub(project); | ||
ResourceDeltaStub child = delta.addChild(new ResourceDeltaStub(project.getFolder("src"))); | ||
child = child.addChild(new ResourceDeltaStub(project.getFolder("src/main"))); | ||
child = child.addChild(new ResourceDeltaStub(project.getFolder("src/main/resources"))); | ||
child = child.addChild(new ResourceDeltaStub(project.getFolder("src/main/resources/sub"))); | ||
child = child.addChild(new ResourceDeltaStub(project.getFolder("src/main/resources/sub/dir"))); | ||
child = child.addChild(new ResourceDeltaStub(project.getFile("src/main/resources/sub/dir/file.txt"))); | ||
|
||
EclipseIncrementalBuildContext context = new EclipseIncrementalBuildContext(delta, new HashMap<String, Object>()); | ||
Scanner scanner; | ||
|
||
scanner = context.newScanner(new File(project.getLocation().toFile(), "src/main/resources"), true); | ||
checkScanner(scanner); | ||
|
||
scanner = context.newScanner(new File(project.getLocation().toFile(), "src/main/resources"), false); | ||
checkScanner(scanner); | ||
} | ||
|
||
private void checkScanner(Scanner scanner) { | ||
// both forward and backward slashes must be understood as separators | ||
scanner.setIncludes(new String[] {"sub/dir\\file.txt"}); | ||
scanner.scan(); | ||
|
||
List<String> included = Arrays.asList(scanner.getIncludedFiles()); | ||
assertTrue(included.toString(), included.contains("sub" + File.separator + "dir" + File.separator + "file.txt")); | ||
} | ||
|
||
} |
128 changes: 128 additions & 0 deletions
128
org.maven.ide.eclipse.tests/src/org/maven/ide/eclipse/builder/ResourceDeltaStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2008 Sonatype, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
|
||
package org.maven.ide.eclipse.builder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.resources.IContainer; | ||
import org.eclipse.core.resources.IMarkerDelta; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.resources.IResourceDelta; | ||
import org.eclipse.core.resources.IResourceDeltaVisitor; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.PlatformObject; | ||
|
||
|
||
class ResourceDeltaStub extends PlatformObject implements IResourceDelta { | ||
|
||
private IResource resource; | ||
|
||
private int kind; | ||
|
||
private int flags; | ||
|
||
private List<IResourceDelta> children = new ArrayList<IResourceDelta>(); | ||
|
||
public ResourceDeltaStub(IResource resource) { | ||
this.resource = resource; | ||
kind = IResourceDelta.CHANGED; | ||
flags = IResourceDelta.CONTENT; | ||
} | ||
|
||
public <T extends IResourceDelta> T addChild(T child) { | ||
children.add(child); | ||
return child; | ||
} | ||
|
||
public void accept(IResourceDeltaVisitor visitor) throws CoreException { | ||
accept(visitor, 0); | ||
} | ||
|
||
public void accept(IResourceDeltaVisitor visitor, boolean includePhantoms) throws CoreException { | ||
accept(visitor, includePhantoms ? IContainer.INCLUDE_PHANTOMS : 0); | ||
} | ||
|
||
public void accept(IResourceDeltaVisitor visitor, int memberFlags) throws CoreException { | ||
if(!visitor.visit(this)) { | ||
return; | ||
} | ||
for(IResourceDelta child : children) { | ||
child.accept(visitor, memberFlags); | ||
} | ||
} | ||
|
||
public IResourceDelta findMember(IPath path) { | ||
int segmentCount = path.segmentCount(); | ||
if(segmentCount == 0) { | ||
return this; | ||
} | ||
|
||
String segment = path.segment(0); | ||
for(IResourceDelta child : children) { | ||
if(child.getFullPath().lastSegment().equals(segment)) { | ||
return child.findMember(path.removeFirstSegments(1)); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public IResourceDelta[] getAffectedChildren() { | ||
return getAffectedChildren(ADDED | REMOVED | CHANGED, IResource.NONE); | ||
} | ||
|
||
public IResourceDelta[] getAffectedChildren(int kindMask) { | ||
return getAffectedChildren(kindMask, IResource.NONE); | ||
} | ||
|
||
public IResourceDelta[] getAffectedChildren(int kindMask, int memberFlags) { | ||
List<IResourceDelta> result = new ArrayList<IResourceDelta>(); | ||
for(IResourceDelta child : children) { | ||
if((child.getKind() & kindMask) != 0) { | ||
result.add(child); | ||
} | ||
} | ||
return result.toArray(new IResourceDelta[result.size()]); | ||
} | ||
|
||
public int getKind() { | ||
return kind; | ||
} | ||
|
||
public int getFlags() { | ||
return flags; | ||
} | ||
|
||
public IPath getFullPath() { | ||
return resource.getFullPath(); | ||
} | ||
|
||
public IPath getProjectRelativePath() { | ||
return resource.getProjectRelativePath(); | ||
} | ||
|
||
public IMarkerDelta[] getMarkerDeltas() { | ||
return new IMarkerDelta[0]; | ||
} | ||
|
||
public IPath getMovedFromPath() { | ||
return null; | ||
} | ||
|
||
public IPath getMovedToPath() { | ||
return null; | ||
} | ||
|
||
public IResource getResource() { | ||
return resource; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters