本文整理汇总了Java中org.eclipse.jdt.launching.IRuntimeClasspathEntry类的典型用法代码示例。如果您正苦于以下问题:Java IRuntimeClasspathEntry类的具体用法?Java IRuntimeClasspathEntry怎么用?Java IRuntimeClasspathEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IRuntimeClasspathEntry类属于org.eclipse.jdt.launching包,在下文中一共展示了IRuntimeClasspathEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProjectClassPath
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
public static void getProjectClassPath(IJavaProject project, List<File> dst) throws Exception {
IRuntimeClasspathEntry [] rentries = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
for (IRuntimeClasspathEntry entry : rentries) {
switch (entry.getType()) {
case IClasspathEntry.CPE_SOURCE:
break;
case IClasspathEntry.CPE_PROJECT:
break;
case IClasspathEntry.CPE_LIBRARY:
break;
case IClasspathEntry.CPE_VARIABLE:
// JRE like entries
IRuntimeClasspathEntry [] variableEntries = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
break;
case IClasspathEntry.CPE_CONTAINER:
IRuntimeClasspathEntry [] containerEntries = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
for (IRuntimeClasspathEntry containerentry : containerEntries) {
dst.add(new File (containerentry.getLocation()));
}
break;
default:
throw new Exception("unsupported classpath entry "+entry);
}
}
}
示例2: computeUnresolvedClasspath
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
@Override
public IRuntimeClasspathEntry[] computeUnresolvedClasspath(final ILaunchConfiguration configuration)
throws CoreException {
boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
if(useDefault) {
IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(configuration);
IRuntimeClasspathEntry projectEntry = JavaRuntime.newProjectRuntimeClasspathEntry(javaProject);
IRuntimeClasspathEntry mavenEntry = JavaRuntime.newRuntimeContainerClasspathEntry(new Path(
IClasspathManager.CONTAINER_ID), IRuntimeClasspathEntry.USER_CLASSES);
if(jreEntry == null) {
return new IRuntimeClasspathEntry[] {projectEntry, mavenEntry};
}
return new IRuntimeClasspathEntry[] {jreEntry, projectEntry, mavenEntry};
}
return recoverRuntimePath(configuration, IJavaLaunchConfigurationConstants.ATTR_CLASSPATH);
}
示例3: resolveClasspath0
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
IRuntimeClasspathEntry[] resolveClasspath0(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration,
IProgressMonitor monitor) throws CoreException {
int scope = getArtifactScope(configuration);
Set<IRuntimeClasspathEntry> all = new LinkedHashSet<>(entries.length);
for(IRuntimeClasspathEntry entry : entries) {
if(entry.getType() == IRuntimeClasspathEntry.CONTAINER
&& MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath())) {
addMavenClasspathEntries(all, entry, configuration, scope, monitor);
} else if(entry.getType() == IRuntimeClasspathEntry.PROJECT) {
IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
if(javaProject.getPath().equals(entry.getPath())) {
addProjectEntries(all, entry.getPath(), scope, THIS_PROJECT_CLASSIFIER, configuration, monitor);
} else {
addStandardClasspathEntries(all, entry, configuration);
}
} else {
addStandardClasspathEntries(all, entry, configuration);
}
}
return all.toArray(new IRuntimeClasspathEntry[all.size()]);
}
示例4: addMavenClasspathEntries
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
private void addMavenClasspathEntries(Set<IRuntimeClasspathEntry> resolved,
IRuntimeClasspathEntry runtimeClasspathEntry, ILaunchConfiguration configuration, int scope,
IProgressMonitor monitor) throws CoreException {
IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
MavenJdtPlugin plugin = MavenJdtPlugin.getDefault();
IClasspathManager buildpathManager = plugin.getBuildpathManager();
IClasspathEntry[] cp = buildpathManager.getClasspath(javaProject.getProject(), scope, false, monitor);
for(IClasspathEntry entry : cp) {
switch(entry.getEntryKind()) {
case IClasspathEntry.CPE_PROJECT:
addProjectEntries(resolved, entry.getPath(), scope, getArtifactClassifier(entry), configuration, monitor);
break;
case IClasspathEntry.CPE_LIBRARY:
resolved.add(JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()));
break;
// case IClasspathEntry.CPE_SOURCE:
// resolved.add(newSourceClasspathEntry(javaProject, cp[i]));
// break;
}
}
}
示例5: getRuntimeClasspaths
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
protected IPath[] getRuntimeClasspaths(ILaunchConfiguration configuration)
throws CoreException {
IRuntimeClasspathEntry[] entries = JavaRuntime
.computeUnresolvedRuntimeClasspath(configuration);
entries = JavaRuntime.resolveRuntimeClasspath(entries, configuration);
ArrayList<IPath> userEntries = new ArrayList<IPath>(entries.length);
for (int i = 0; i < entries.length; i++) {
if (entries[i].getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
String location = entries[i].getLocation();
if (location != null) {
IPath entry = Path.fromOSString(location);
if (!userEntries.contains(entry)) {
userEntries.add(entry);
}
}
}
}
return userEntries.toArray(new IPath[userEntries.size()]);
}
示例6: computeSourceContainers
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor)
throws CoreException {
List<IRuntimeClasspathEntry> entries = new ArrayList<IRuntimeClasspathEntry>();
IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(configuration);
if (jreEntry != null) {
entries.add(jreEntry);
}
String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
if (projectName == null) {
return null;
}
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
IJavaProject javaProject = JavaCore.create(project);
if (javaProject != null && javaProject.isOpen() && ("".equals(projectName) || projectName.equals(javaProject.getElementName()))) { //$NON-NLS-1$
entries.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject));
}
}
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath( //
entries.toArray(new IRuntimeClasspathEntry[entries.size()]), configuration);
return JavaRuntime.getSourceContainers(resolved);
}
示例7: fromJavaRuntimeResolver
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
private ISourceContainer[] fromJavaRuntimeResolver() throws CoreException {
for (final IClasspathEntry cpe : jp.getRawClasspath()) {
if (IClasspathEntry.CPE_CONTAINER == cpe.getEntryKind() && //
IClasspathManager.CONTAINER_ID.equals(cpe.getPath().toString())) {
final IRuntimeClasspathEntry newRuntimeContainerClasspathEntry = JavaRuntime.newRuntimeContainerClasspathEntry(cpe.getPath(),
IRuntimeClasspathEntry.USER_CLASSES, jp);
final IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry = JavaRuntime.resolveRuntimeClasspathEntry(
newRuntimeContainerClasspathEntry, jp);
// there is only one maven2 classpath container in a project return
return JavaRuntime.getSourceContainers(resolveRuntimeClasspathEntry);
}
}
return new ISourceContainer[] {};
}
示例8: fromMavenSourcePathProvider
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
private ISourceContainer[] fromMavenSourcePathProvider() throws CoreException {
final IRuntimeClasspathEntry mavenEntry = JavaRuntime.newRuntimeContainerClasspathEntry(new Path(IClasspathManager.CONTAINER_ID),
IRuntimeClasspathEntry.USER_CLASSES);
final ILaunchConfiguration launchConfiguration = getDirector().getLaunchConfiguration();
// final ILaunchConfigurationWorkingCopy wc = launchConfiguration.getWorkingCopy();
// wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, getProjectName());
// final ILaunchConfiguration doSave = wc.doSave();
final ILaunchConfiguration javaProjectLaunchConfiguration = new JavaProjectLaunchConfiguration(launchConfiguration, this);
final IRuntimeClasspathEntry[] resolved = mavenRuntimeClasspathProvider.resolveClasspath(new IRuntimeClasspathEntry[] {
mavenEntry
}, javaProjectLaunchConfiguration);
// final IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedSourceLookupPath(doSave);
// final IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, doSave);
return JavaRuntime.getSourceContainers(resolved);
}
示例9: resolveClasspath
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
@Override
public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries,
ILaunchConfiguration configuration) throws CoreException {
IRuntimeClasspathEntry[] resolvedEntries = super.resolveClasspath(entries, configuration);
IJavaProject proj = JavaRuntime.getJavaProject(configuration);
if (proj == null) {
return resolvedEntries;
}
List<IRuntimeClasspathEntry> resolvedEntriesList =
new ArrayList<IRuntimeClasspathEntry>(Arrays.asList(resolvedEntries));
return resolvedEntriesList.toArray(new IRuntimeClasspathEntry[resolvedEntriesList.size()]);
}
示例10: createClassLoader
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
@Override
public URLClassLoader createClassLoader() throws SdkException, MalformedURLException {
IJavaProject userProject = findUserProject();
if (userProject != null) {
IRuntimeClasspathEntry outputEntry = JavaRuntime.newDefaultProjectClasspathEntry(userProject);
try {
IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry =
JavaRuntime.resolveRuntimeClasspathEntry(outputEntry, userProject);
List<URL> urls = new ArrayList<URL>();
for (IRuntimeClasspathEntry entry : resolveRuntimeClasspathEntry) {
urls.add(new File(entry.getLocation()).toURI().toURL());
}
return new URLClassLoader(urls.toArray(NO_URLS), null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// TODO Auto-generated method stub
return null;
}
示例11: computeClasspath
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
private static String computeClasspath(GwtSdk gwtRuntime, String[] extraClassPath)
throws CoreException {
List<String> cpPaths = new ArrayList<String>();
for (IClasspathEntry c : gwtRuntime.getClasspathEntries()) {
if (c.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
IJavaProject javaProject = JavaProjectUtilities.findJavaProject(c.getPath().toOSString());
IRuntimeClasspathEntry projectRuntimeEntry = JavaRuntime.newDefaultProjectClasspathEntry(javaProject);
IRuntimeClasspathEntry[] resolvedEntries = JavaRuntime.resolveRuntimeClasspathEntry(
projectRuntimeEntry, javaProject);
for (IRuntimeClasspathEntry resolvedEntry : resolvedEntries) {
cpPaths.add(resolvedEntry.getLocation());
}
} else {
cpPaths.add(c.getPath().toFile().getAbsolutePath());
}
}
if (extraClassPath != null) {
cpPaths.addAll(Arrays.asList(extraClassPath));
}
return ProcessUtilities.buildClasspathString(cpPaths);
}
示例12: resolveClasspathEntries
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
/**
* Given a list of IClasspathEntry, produce an array of IRuntimeClasspathEntry based on that list.
*/
private IRuntimeClasspathEntry[] resolveClasspathEntries(List<IClasspathEntry> classpathEntries)
throws CoreException {
LinkedHashSet<IRuntimeClasspathEntry> runtimeClasspathEntries = new LinkedHashSet<IRuntimeClasspathEntry>();
for (IClasspathEntry classpathEntry : classpathEntries) {
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
String projectName = classpathEntry.getPath().lastSegment();
IJavaProject theproject = JavaProjectUtilities.findJavaProject(projectName);
IRuntimeClasspathEntry projectEntry = JavaRuntime.newProjectRuntimeClasspathEntry(theproject);
runtimeClasspathEntries.add(projectEntry);
runtimeClasspathEntries.addAll(dependenciesForProject(theproject));
} else {
runtimeClasspathEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(classpathEntry.getPath()));
}
}
return runtimeClasspathEntries.toArray(NO_ENTRIES);
}
示例13: prependClasspath
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
@Override
public LaunchConfiguration prependClasspath(final String classPathEntry) {
final IRuntimeClasspathEntry newEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(classPathEntry));
try {
this.workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
final List<String> entries =
this.workingCopy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, new ArrayList<>());
if (entries.isEmpty()) {
entries.add(JavaRuntime.newDefaultProjectClasspathEntry(this.launchedProject).getMemento());
}
entries.add(0, newEntry.getMemento());
this.workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, entries);
} catch (final CoreException coreException) {
final FailureReport<LaunchConfiguration> failure =
new FailureReport<LaunchConfiguration>().cause(coreException);
return FAILURE_HANDLER.handle(failure);
}
return this;
}
示例14: collectReferencedElements
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
private void collectReferencedElements(IJavaProject project, HashSet<JavadocLinkRef> result) throws CoreException {
IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
for (int i= 0; i < unresolved.length; i++) {
IRuntimeClasspathEntry curr= unresolved[i];
if (curr.getType() == IRuntimeClasspathEntry.PROJECT) {
result.add(new JavadocLinkRef(JavaCore.create((IProject) curr.getResource())));
} else {
IRuntimeClasspathEntry[] entries= JavaRuntime.resolveRuntimeClasspathEntry(curr, project);
for (int k = 0; k < entries.length; k++) {
IRuntimeClasspathEntry entry= entries[k];
if (entry.getType() == IRuntimeClasspathEntry.PROJECT) {
result.add(new JavadocLinkRef(JavaCore.create((IProject) entry.getResource())));
} else if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) {
IClasspathEntry classpathEntry= entry.getClasspathEntry();
if (classpathEntry != null) {
IPath containerPath= null;
if (curr.getType() == IRuntimeClasspathEntry.CONTAINER) {
containerPath= curr.getPath();
}
result.add(new JavadocLinkRef(containerPath, classpathEntry, project));
}
}
}
}
}
}
示例15: getClasspath
import org.eclipse.jdt.launching.IRuntimeClasspathEntry; //导入依赖的package包/类
private static IPath[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
IRuntimeClasspathEntry[] entries= JavaRuntime.computeUnresolvedRuntimeClasspath(configuration);
entries= JavaRuntime.resolveRuntimeClasspath(entries, configuration);
ArrayList<IPath> userEntries= new ArrayList<IPath>(entries.length);
for (int i= 0; i < entries.length; i++) {
if (entries[i].getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
String location= entries[i].getLocation();
if (location != null) {
IPath entry= Path.fromOSString(location);
if (!userEntries.contains(entry)) {
userEntries.add(entry);
}
}
}
}
return userEntries.toArray(new IPath[userEntries.size()]);
}