List of usage examples for org.eclipse.jdt.core JavaCore setClasspathVariable
public static void setClasspathVariable(String variableName, IPath path, IProgressMonitor monitor) throws JavaModelException
From source file:ca.mcgill.sable.soot.SootClasspathVariableInitializer.java
License:Open Source License
@Override public void initialize(String variable) { if (variable.equals(VARIABLE_NAME_CLASSES)) { //$NON-NLS-1$ String jarPath = getSootFilePath(RELATIVE_PATH_CLASSES_JAR); if (jarPath == null) return; try {/*from w w w.j av a 2 s . com*/ JavaCore.setClasspathVariable(VARIABLE_NAME_CLASSES, //$NON-NLS-1$ new Path(jarPath), new NullProgressMonitor()); } catch (JavaModelException e) { e.printStackTrace(); } } if (variable.equals(VARIABLE_NAME_SOURCE)) { //$NON-NLS-1$ String jarPath = getSootFilePath(RELATIVE_PATH_SRC_ZIP); if (jarPath == null) return; try { JavaCore.setClasspathVariable(VARIABLE_NAME_SOURCE, //$NON-NLS-1$ new Path(jarPath), new NullProgressMonitor()); } catch (JavaModelException e) { e.printStackTrace(); } } }
From source file:com.appnativa.studio.preferences.MainPreferencePage.java
License:Open Source License
static void updateSDKPathVariable() { File f = new File(getAppNativaSDKDirectory()); try {// w w w .j a va 2 s .c o m IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPathVariableManager pathMan = workspace.getPathVariableManager(); pathMan.setURIValue("APPNATIVA_SDK", f.toURI()); } catch (Exception e) { e.printStackTrace(); } try { JavaCore.setClasspathVariable("APPNATIVA_SDK", Path.fromOSString(f.getAbsolutePath()), null); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ashigeru.eclipse.util.workspace.applications.MavenRepositoryOperation.java
License:Apache License
@Override public void perform(String value) throws Exception { IWorkspace workspace = ResourcesPlugin.getWorkspace(); try {/* w ww . j av a 2 s. co m*/ IPath path = Path.fromOSString(value); System.out.println(MessageFormat.format("[M2REPO] Registering M2_REPO: {0}", path)); JavaCore.setClasspathVariable("M2_REPO", path, new NullProgressMonitor()); workspace.save(true, new NullProgressMonitor()); } finally { try { workspace.save(true, new NullProgressMonitor()); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.centurylink.mdw.plugin.codegen.Generator.java
License:Apache License
/** * Sets the MDWCommon.jar file as CLASSPATH variable in Eclipse. Needed so * that the JET Emitter framework can find MDWCommon at runtime. *//*from w w w.j av a2s . c o m*/ protected void setMdwCommonClasspathVariable() throws JavaModelException { URL url = null; try { url = PluginUtil.getLocalResourceUrl("base/APP-INF/lib/MDWCommon.jar"); } catch (IOException e) { int code = IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST; JavaModelException jme = new JavaModelException(e, code); throw jme; } IPath path = new Path(url.getFile()); if (!path.equals(JavaCore.getClasspathVariable("MDW_COMMON"))) { JavaCore.setClasspathVariable("MDW_COMMON", path, null); } }
From source file:com.google.gdt.eclipse.core.TestUtilities.java
License:Open Source License
private static void setupWorkspaceVariables() throws CoreException { IPathVariableManager variableManager = ResourcesPlugin.getWorkspace().getPathVariableManager(); IPath gwtRootPath = new Path(getEnvironmentVariable("GWT_ROOT")); if (variableManager.getValue("GWT_ROOT") == null) { CorePluginLog.logInfo("Setting GWT_ROOT = " + gwtRootPath.toOSString()); variableManager.setValue("GWT_ROOT", gwtRootPath); }//from www .j a v a 2 s . com IPath gwtToolsPath = new Path(getEnvironmentVariable("GWT_TOOLS")); if (JavaCore.getClasspathVariable("GWT_TOOLS") == null) { CorePluginLog.logInfo("Setting GWT_TOOLS = " + gwtToolsPath.toOSString()); JavaCore.setClasspathVariable("GWT_TOOLS", gwtToolsPath, null); } }
From source file:com.google.gdt.eclipse.designer.preferences.PreferenceInitializer.java
License:Open Source License
/** * Adds listener that updates "GWT_HOME" class path variable. *//*from w w w . j a v a2 s. c o m*/ private void addClasspathVariableUpdateListener(IPreferenceStore store) { store.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (Constants.P_GWT_LOCATION.equals(event.getProperty())) { String newGwtHome = (String) event.getNewValue(); try { JavaCore.setClasspathVariable(Constants.GWT_HOME_CPE, new Path(newGwtHome), new NullProgressMonitor()); } catch (JavaModelException e) { DesignerPlugin.log(e); } } } }); }
From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Tests variable support when computing classpaths. *//*from w w w. java 2 s.co m*/ 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()); } }
From source file:com.google.gwt.eclipse.testing.GwtTestUtilities.java
License:Open Source License
/** * 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. *//* w ww .j a va2s. c o m*/ 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); } }
From source file:com.nomagic.magicdraw.classpath.MDClasspathContainerPage.java
License:Open Source License
public IPath setMDInstallRootPath(String mdInstallRoot) { fMDInstallRootPath = new Path(mdInstallRoot); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); try {/*from ww w . j av a 2 s . c o m*/ JavaCore.setClasspathVariable(MDVariableInitializer.MD_CLASSPATH_VARIABLE, fMDInstallRootPath, new NullProgressMonitor()); store.setValue(PreferenceConstants.MAGICDRAW_INSTALL_ROOT_PATH, mdInstallRoot); ((IPersistentPreferenceStore) store).save(); } catch (JavaModelException e) { Activator.log(IStatus.ERROR, "MDClasspathContainer (set)", e); throw new RuntimeException(e); } catch (IOException e) { Activator.log(IStatus.ERROR, "MDClasspathContainer (save preference)", e); } return fMDInstallRootPath; }
From source file:com.siteview.mde.internal.core.EclipseHomeInitializer.java
License:Open Source License
public static void resetEclipseHomeVariable() { try {/*from w w w . ja v a2 s . c om*/ MDEPreferencesManager pref = MDECore.getDefault().getPreferencesManager(); String platformHome = pref.getString(ICoreConstants.PLATFORM_PATH); JavaCore.setClasspathVariable(ECLIPSE_HOME_VARIABLE, new Path(platformHome), null); } catch (CoreException e) { } }