Java Code Examples for org.eclipse.jdt.core.JavaCore#setClasspathVariable()
The following examples show how to use
org.eclipse.jdt.core.JavaCore#setClasspathVariable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationClasspathInitializer.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private void setVariable(String fullPath, String variableName) { if (fullPath == null) { FindbugsPlugin.getDefault().logError("Unable to find path for variable: " + variableName); return; } try { JavaCore.setClasspathVariable(variableName, new Path(fullPath), null); } catch (JavaModelException e1) { FindbugsPlugin.getDefault().logException(e1, "Unable to set annotations classpath"); } }
Example 2
Source File: GWTCompileRunnerTest.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Tests variable support when computing classpaths. */ public void testComputeClasspathForVariables() throws CoreException, IOException { // Create the classpath variable Random rand = new Random(); String varName = null; while (varName == null) { String curVarName = this.getName() + rand.nextInt(); if (JavaCore.getClasspathVariable(curVarName) == null) { varName = curVarName; } } File systemTempFile = File.createTempFile(this.getName(), ".temp"); JavaCore.setClasspathVariable(varName, Path.fromOSString(systemTempFile.getAbsolutePath()), new NullProgressMonitor()); try { // Create a variable entry and add it to the raw classpath JavaProjectUtilities.addRawClassPathEntry(javaProjectA, JavaCore.newVariableEntry(new Path(varName), null, null, true)); // Get the computed classpath List<File> actualCp = getListOfFiles( GWTCompileRunner.computeClasspath(javaProjectA)); // Ensure the paths and ordering are all the same List<File> expectedCp = new ArrayList<File>(); expectedCp.add(systemTempFile); assertEquals(expectedCp, actualCp); } finally { JavaCore.removeClasspathVariable(varName, new NullProgressMonitor()); } }
Example 3
Source File: GwtTestUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Sets up workspace variables to point at the the {@code GWT_ROOT} and {@code GWT_TOOLS} * environment variables, which point at a local clone of the GWT git repository. If those * environment variables are not set, extracts a snapshot of the GWT source tree that * is bundled with this plug-in and sets the environment variables to point at it. */ private static void setupWorkspaceVariables() throws CoreException { IPathVariableManager variableManager = ResourcesPlugin.getWorkspace().getPathVariableManager(); String gwtRoot = System.getenv("GWT_ROOT"); if (gwtRoot == null) { System.out.println("The GWT_ROOT environment variable is not set, using test bundle version"); gwtRoot = TestEnvironmentUtil.installTestSdk( GwtTestingPlugin.getDefault().getBundle(), Path.fromPortableString("/resources/gwt-root.zip")).append("trunk").toOSString(); TestEnvironmentUtil.updateEnvironmentVariable("GWT_ROOT", gwtRoot); System.out.println("The GWT_ROOT environment variable is now set"); } IPath gwtRootPath = Path.fromOSString(gwtRoot); if (variableManager.getURIValue("GWT_ROOT") == null) { CorePluginLog.logInfo("Setting GWT_ROOT = " + gwtRootPath.toOSString()); variableManager.setURIValue("GWT_ROOT", gwtRootPath.toFile().toURI()); } String gwtTools = System.getenv("GWT_TOOLS"); if (gwtTools == null) { System.out.println("The GWT_TOOLS environment variable is not set, using GWT_ROOT as a base"); gwtTools = gwtRoot + "/tools"; TestEnvironmentUtil.updateEnvironmentVariable("GWT_TOOLS", gwtTools); } IPath gwtToolsPath = Path.fromOSString(gwtTools); if (JavaCore.getClasspathVariable("GWT_TOOLS") == null) { CorePluginLog.logInfo("Setting GWT_TOOLS = " + gwtToolsPath.toOSString()); JavaCore.setClasspathVariable("GWT_TOOLS", gwtToolsPath, null); } }
Example 4
Source File: JavaUtils.java From developer-studio with Apache License 2.0 | 5 votes |
public static boolean addClasspathVariable(String variableName, IPath path) { try { if (JavaCore.getClasspathVariable(variableName)!=null){ JavaCore.removeClasspathVariable(variableName, new NullProgressMonitor()); } JavaCore.setClasspathVariable(variableName, path, new NullProgressMonitor()); return true; } catch (JavaModelException e) { return false; } }