/** * @see ITomcatVersionHandler#getRuntimeClasspath(IPath) */ public List getRuntimeClasspath(IPath installPath) { List cp = new ArrayList(); // 6.0 - add bootstrap.jar from the Tomcat bin directory IPath binPath = installPath.append("bin"); if (binPath.toFile().exists()) { IPath path = binPath.append("bootstrap.jar"); cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path)); } return cp; }
/** * @see ITomcatVersionHandler#getRuntimeClasspath(IPath) */ public List getRuntimeClasspath(IPath installPath) { List cp = new ArrayList(); // 4.1 - add bootstrap.jar from the Tomcat bin directory IPath binPath = installPath.append("bin"); if (binPath.toFile().exists()) { IPath path = binPath.append("bootstrap.jar"); cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path)); } return cp; }
/** * @see ITomcatVersionHandler#getRuntimeClasspath(IPath) */ public List getRuntimeClasspath(IPath installPath) { List cp = new ArrayList(); // 5.0 - add bootstrap.jar from the Tomcat bin directory IPath binPath = installPath.append("bin"); if (binPath.toFile().exists()) { IPath path = binPath.append("bootstrap.jar"); cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path)); } return cp; }
/** * @see ITomcatVersionHandler#getRuntimeClasspath(IPath) */ public List getRuntimeClasspath(IPath installPath) { List cp = new ArrayList(); // 4.0 - add bootstrap.jar from the Tomcat bin directory IPath binPath = installPath.append("bin"); if (binPath.toFile().exists()) { IPath path = binPath.append("bootstrap.jar"); cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path)); } return cp; }
public static IRuntimeClasspathEntry[] getLibs(Bundle bundle, String[] filelist) throws MalformedURLException, URISyntaxException { List<IRuntimeClasspathEntry> entries = new ArrayList<IRuntimeClasspathEntry>(); URL installUrl = bundle.getEntry("/"); try { for(String filepath:filelist){ //Note the FileLocator will generate a file for us when we use FileLocator.toFileURL , //it's very important. URL fileUrl = FileLocator.toFileURL(new URL(installUrl,filepath)); entries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(fileUrl.getPath()))); } if(entries.size() == 0 ){ throw new IllegalStateException("RJR finding jar failed"); } } catch (IOException e) { Plugin.logError(e); } return entries.toArray(new IRuntimeClasspathEntry[0]); }
public List<IRuntimeClasspathEntry> getDefaultScanList(ILaunchConfiguration configuration) throws CoreException { IJavaProject proj = JavaRuntime.getJavaProject(configuration); if (proj == null) { Plugin.logError("No project!"); return new ArrayList<IRuntimeClasspathEntry>(); } Set<String> locations = getScanLocations(configuration,proj); List<IRuntimeClasspathEntry> scanlist = new ArrayList<IRuntimeClasspathEntry>(); for(String location:locations){ scanlist.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(location))); } return scanlist; }
/** * @see ITomcatVersionHandler#getRuntimeClasspath(IPath) */ public List getRuntimeClasspath(IPath installPath) { List cp = new ArrayList(); // add all jars from the Tomcat lib directory File libDir = installPath.append("lib").toFile(); if (libDir.exists()) { String[] libs = libDir.list(); for (int i = 0; i < libs.length; i++) { if (libs[i].endsWith("jar")) { IPath path = installPath.append("lib").append(libs[i]); cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path)); } } } return cp; }
public static long[] calculateSerialVersionIds(String[] qualifiedNames, IJavaProject project, final IProgressMonitor monitor) throws CoreException, IOException { final String[] entries= computeUserAndBootClasspath(project); final IRuntimeClasspathEntry[] classpath= new IRuntimeClasspathEntry[entries.length + 2]; classpath[0]= JavaRuntime.newRuntimeContainerClasspathEntry(new Path(JavaRuntime.JRE_CONTAINER), IRuntimeClasspathEntry.STANDARD_CLASSES, project); classpath[1]= JavaRuntime.newArchiveRuntimeClasspathEntry(Path.fromOSString(FileLocator.toFileURL(JavaPlugin.getDefault().getBundle().getEntry(SERIAL_SUPPORT_JAR)).getFile())); for (int index= 2; index < classpath.length; index++) classpath[index]= JavaRuntime.newArchiveRuntimeClasspathEntry(Path.fromOSString(entries[index - 2])); return SerialVersionComputationHelper.computeSerialIDs(classpath, project, qualifiedNames, monitor); }
public static List<IRuntimeClasspathEntry> getWebInfLibRuntimeClasspathEntrys(ILaunchConfiguration configuration){ List<IRuntimeClasspathEntry> result = new ArrayList<IRuntimeClasspathEntry>(); IFolder lib = getWebInfLib(configuration); if (lib == null || !lib.exists()) { return result; } try{ IResource[] resources = lib.members(); for(IResource res:resources){ if("jar".equalsIgnoreCase(res.getFileExtension())){ result.add(JavaRuntime.newArchiveRuntimeClasspathEntry(res)); } } }catch(CoreException e){ e.printStackTrace(); } return result; }
private IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry) throws CoreException{ String variableString = ((VariableClasspathEntry)entry).getVariableString(); String strpath = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(variableString); IPath path = new Path(strpath).makeAbsolute(); IRuntimeClasspathEntry archiveEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(path); return new IRuntimeClasspathEntry[] { archiveEntry }; }
private IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry) throws CoreException{ String variableString = ((VariableClasspathEntry)entry).getVariableString(); String strpath = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(variableString); IPath path = new Path(strpath).makeAbsolute(); IRuntimeClasspathEntry archiveEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(path); return new IRuntimeClasspathEntry[] { archiveEntry }; }
/** * Prompts for a jar to add. * * @see IAction#run() */ public void run() { IPath[] paths = BuildPathDialogAccess.chooseJAREntries(getShell(), null, new IPath[0]); if (paths != null && paths.length > 0) { IRuntimeClasspathEntry[] res= new IRuntimeClasspathEntry[paths.length]; for (int i= 0; i < res.length; i++) { IResource elem= ResourcesPlugin.getWorkspace().getRoot().getFile(paths[i]); res[i]= JavaRuntime.newArchiveRuntimeClasspathEntry(elem); } getViewer().addEntries(res); } }
public String getText(Object element) { if (element instanceof IJavaElement) { IJavaElement parent = ((IJavaElement)element).getParent(); return fJavaLabels.getText(parent); } else if (element instanceof ZipEntryStorage) { ZipEntryStorage storage = (ZipEntryStorage)element; ZipFile zipFile = storage.getArchive(); IPath path = new Path(zipFile.getName()); IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(path); IResource res = entry.getResource(); if (res == null) { // external return zipFile.getName(); } // internal return res.getName(); } else if (element instanceof LocalFileStorage) { LocalFileStorage storage = (LocalFileStorage)element; File extFile = storage.getFile(); return extFile.getParent(); } return super.getText(element); }
private void collectContainerRuntimeClasspath(IClasspathContainer container, List<IRuntimeClasspathEntry> result, boolean includeExportedEntriesOnly, LaunchConfigurationScope configurationScopes) throws CoreException { for (final IClasspathEntry cpe : container.getClasspathEntries()) { if (!includeExportedEntriesOnly || cpe.isExported()) { if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY && configurationScopes.isEntryIncluded(cpe)) { result.add(JavaRuntime.newArchiveRuntimeClasspathEntry(cpe.getPath())); } else if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) { Optional<IProject> candidate = findAccessibleJavaProject(cpe.getPath().segment(0)); if (candidate.isPresent()) { IJavaProject dependencyProject = JavaCore.create(candidate.get()); IRuntimeClasspathEntry projectRuntimeEntry = JavaRuntime.newProjectRuntimeClasspathEntry(dependencyProject); // add the project entry itself so that the source lookup can find the classes // see https://github.com/eclipse/buildship/issues/383 result.add(projectRuntimeEntry); Collections.addAll(result, GradleClasspathProvider.resolveOutputLocations(projectRuntimeEntry, dependencyProject, configurationScopes)); collectContainerRuntimeClasspathIfPresent(dependencyProject, result, true, configurationScopes); } } } } }
private IRuntimeClasspathEntry convertClasspathEntry(IClasspathEntry entry) { if (entry == null) return null; IPath srcPath = entry.getSourceAttachmentPath(); if (srcPath != null && srcPath.segmentCount() > 0) { IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()); rte.setSourceAttachmentPath(srcPath); rte.setSourceAttachmentRootPath(entry.getSourceAttachmentRootPath()); return rte; } return null; }
@Override protected ISourceContainer[] createSourceContainers() throws CoreException { IPath path = JavaCore.getClasspathVariable(fVariable.segment(0)); if (path == null) { return new ISourceContainer[0]; } if (fVariable.segmentCount() > 1) { path = path.append(fVariable.removeFirstSegments(1)); } IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(path); return JavaRuntime.getSourceContainers(new IRuntimeClasspathEntry[]{entry}); } /* (non-Javadoc)
@Override protected ISourceContainer[] createSourceContainers() throws CoreException { IPath path = JavaCore.getClasspathVariable(fVariable.segment(0)); if (path == null) { return new ISourceContainer[0]; } if (fVariable.segmentCount() > 1) { path = path.append(fVariable.removeFirstSegments(1)); } IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(path); return JavaRuntime.getSourceContainers(new IRuntimeClasspathEntry[]{entry}); } /* (non-Javadoc)
/** * Adds runtime classpath entries for binary package fragment roots contained within * the project * * @param jProject * the Java project whose roots are to be enumerated * @param all * a list of accumulated runtime classpath entries * @throws CoreException * if unable to evaluate the package fragment roots */ private void addBinaryPackageFragmentRoots(IJavaProject jProject, List all) throws CoreException { IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots(); for (int j = 0; j < roots.length; j++) { if (roots[j].getKind() == IPackageFragmentRoot.K_BINARY && !PDEJavaHelper.isJRELibrary(roots[j])) { IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(roots[j].getPath()); IPath path = roots[j].getSourceAttachmentPath(); if (path != null) { rte.setSourceAttachmentPath(path); rte.setSourceAttachmentRootPath(roots[j].getSourceAttachmentRootPath()); } if (!all.contains(rte)) all.add(rte); } } } }
/** * Prompts for a folder to add. * * @see IAction#run() */ public void run() { String lastUsedPath= getDialogSetting(LAST_PATH_SETTING); if (lastUsedPath == null) { lastUsedPath= ""; //$NON-NLS-1$ } FileDialog dialog= new FileDialog(getShell(), SWT.MULTI); dialog.setText( "File Selection"); dialog.setFilterPath(lastUsedPath); String res= dialog.open(); if (res == null) { return; } IPath filterPath= new Path(dialog.getFilterPath()); IRuntimeClasspathEntry[] elems= new IRuntimeClasspathEntry[1]; IPath path= new Path(res).makeAbsolute(); elems[0]= JavaRuntime.newArchiveRuntimeClasspathEntry(path); setDialogSetting(LAST_PATH_SETTING, filterPath.toOSString()); getViewer().addEntries(elems); }
/** * Prompts for a folder to add. * * @see IAction#run() */ public void run() { String lastUsedPath= getDialogSetting(LAST_PATH_SETTING); if (lastUsedPath == null) { lastUsedPath= ""; //$NON-NLS-1$ } DirectoryDialog dialog= new DirectoryDialog(getShell(), SWT.MULTI); dialog.setText( "Class Folder Selection"); dialog.setFilterPath(lastUsedPath); String res= dialog.open(); if (res == null) { return; } IPath filterPath= new Path(dialog.getFilterPath()); IRuntimeClasspathEntry[] elems= new IRuntimeClasspathEntry[1]; IPath path= new Path(res).makeAbsolute(); elems[0]= JavaRuntime.newArchiveRuntimeClasspathEntry(path); setDialogSetting(LAST_PATH_SETTING, filterPath.toOSString()); getViewer().addEntries(elems); }