blob: a1b7d30fd8059a693fecd6f4cb6089bea60497e5 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010 Stephan Herrmann.
* 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
*
* Contributors:
* Stephan Herrmann <stephan@cs.tu-berlin.de> - inconsistent initialization of classpath container backed by external class folder, see https://bugs.eclipse.org/320618
*******************************************************************************/
package org.eclipse.jdt.core.tests.extensions;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ClasspathContainerInitializer;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
public class TestExternalLibContainerInitializer extends ClasspathContainerInitializer {
IClasspathEntry[] entries;
public void initialize(final IPath containerName, IJavaProject project)
throws CoreException {
IPath ws = ResourcesPlugin.getWorkspace().getRoot().getLocation();
final IPath containerPath = ws.append("../TestContainer/");
IClasspathContainer container = new IClasspathContainer() {
public IPath getPath() {
return containerName;
}
public int getKind() {
return IClasspathContainer.K_APPLICATION;
}
public String getDescription() {
return "Test Container";
}
public IClasspathEntry[] getClasspathEntries() {
if (TestExternalLibContainerInitializer.this.entries == null) {
TestExternalLibContainerInitializer.this.entries = new IClasspathEntry[] {
JavaCore.newLibraryEntry(containerPath, null, null)
};
}
return TestExternalLibContainerInitializer.this.entries;
}
};
JavaCore.setClasspathContainer(containerName, new IJavaProject[]{ project}, new IClasspathContainer[] { container }, null);
}
}