org.eclipse.jdt.launching.IRuntimeClasspathEntry Java Examples

The following examples show how to use org.eclipse.jdt.launching.IRuntimeClasspathEntry. 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: MavenClasspathProvider.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@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()]);
}
 
Example #2
Source File: AbstractSARLLaunchConfigurationDelegate.java    From sarl with Apache License 2.0 6 votes vote down vote up
private static Pair<IRuntimeClasspathEntry, Integer> getJreEntry(IRuntimeClasspathEntry[] entries,
		List<IRuntimeClasspathEntry> bootEntriesPrepend) {
	int index = 0;
	IRuntimeClasspathEntry jreEntry = null;
	while (jreEntry == null && index < entries.length) {
		final IRuntimeClasspathEntry entry = entries[index++];
		if (entry.getClasspathProperty() == IRuntimeClasspathEntry.BOOTSTRAP_CLASSES
				|| entry.getClasspathProperty() == IRuntimeClasspathEntry.STANDARD_CLASSES) {
			if (JavaRuntime.isVMInstallReference(entry)) {
				jreEntry = entry;
			} else {
				bootEntriesPrepend.add(entry);
			}
		}
	}
	return Pair.of(jreEntry, index);
}
 
Example #3
Source File: WebAppProjectCreatorRunner.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: GWTProjectsRuntime.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: AbstractSARLLaunchConfigurationDelegate.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Compute the class path for the given launch configuration.
 *
 * @param configuration the configuration that provides the classpath.
 * @param configAccessor the accessor to the SRE configuration.
 * @param projectAccessor the accessor to the Java project.
 * @return the filtered entries.
 * @throws CoreException if impossible to get the classpath.
 */
public static IRuntimeClasspathEntry[] computeUnresolvedSARLRuntimeClasspath(ILaunchConfiguration configuration,
		ILaunchConfigurationAccessor configAccessor,
		IJavaProjectAccessor projectAccessor) throws CoreException {
	// Get the classpath from the configuration.
	final IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(configuration);
	//
	final List<IRuntimeClasspathEntry> filteredEntries = new ArrayList<>();
	List<IRuntimeClasspathEntry> sreClasspathEntries = null;
	// Filtering the entries by replacing the "SARL Libraries" with the SARL runtime environment.
	for (final IRuntimeClasspathEntry entry : entries) {
		if (entry.getPath().equals(SARLClasspathContainerInitializer.CONTAINER_ID)) {
			if (sreClasspathEntries == null) {
				sreClasspathEntries = getSREClasspathEntries(configuration, configAccessor, projectAccessor);
			}
			filteredEntries.addAll(sreClasspathEntries);
		} else {
			filteredEntries.add(entry);
		}
	}
	return filteredEntries.toArray(new IRuntimeClasspathEntry[filteredEntries.size()]);
}
 
Example #6
Source File: AbstractSARLLaunchConfigurationDelegate.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Replies the class path for the SARL application.
 *
 * @param configuration the configuration that provides the classpath.
 * @return the filtered entries.
 * @throws CoreException if impossible to get the classpath.
 */
private IRuntimeClasspathEntry[] getOrComputeUnresolvedSARLRuntimeClasspath(ILaunchConfiguration configuration)
		throws CoreException {
	// Get the buffered entries
	IRuntimeClasspathEntry[] entries = null;
	synchronized (this) {
		if (this.unresolvedClasspathEntries != null) {
			entries = this.unresolvedClasspathEntries.get();
		}
	}
	if (entries != null) {
		return entries;
	}
	// Get the classpath from the configuration.
	entries = computeUnresolvedSARLRuntimeClasspath(configuration, this.configAccessor, cfg -> getJavaProject(cfg));
	//
	synchronized (this) {
		this.unresolvedClasspathEntries = new SoftReference<>(entries);
	}
	return entries;
}
 
Example #7
Source File: AbstractSREInstall.java    From sarl with Apache License 2.0 6 votes vote down vote up
/**
 * Change the library locations of this ISREInstall.
 *
 * @param libraries The library locations of this ISREInstall.
 *     Must not be {@code null}.
 */
@Override
public void setClassPathEntries(List<IRuntimeClasspathEntry> libraries) {
	if (isDirty()) {
		setDirty(false);
		resolveDirtyFields(true);
	}
	if ((libraries == null && this.classPathEntries != null)
			|| (libraries != null
				&& (this.classPathEntries == null
					|| libraries != this.classPathEntries))) {
		final PropertyChangeEvent event = new PropertyChangeEvent(
				this, ISREInstallChangedListener.PROPERTY_LIBRARY_LOCATIONS,
				this.classPathEntries, libraries);
		this.classPathEntries = libraries;
		if (this.notify) {
			SARLRuntime.fireSREChanged(event);
		}
	}
}
 
Example #8
Source File: RuntimeClasspathEntryResolver.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: FixedFatJarExportPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
protected IPath[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
	IRuntimeClasspathEntry[] entries= JavaRuntime.computeUnresolvedRuntimeClasspath(configuration);
	entries= JavaRuntime.resolveRuntimeClasspath(entries, configuration);

	boolean isModularConfig= JavaRuntime.isModularConfiguration(configuration);
	ArrayList<IPath> userEntries= new ArrayList<>(entries.length);
	for (int i= 0; i < entries.length; i++) {
		int classPathProperty= entries[i].getClasspathProperty();
		if ((!isModularConfig && classPathProperty == IRuntimeClasspathEntry.USER_CLASSES)
				|| (isModularConfig && (classPathProperty == IRuntimeClasspathEntry.CLASS_PATH || classPathProperty == IRuntimeClasspathEntry.MODULE_PATH))) {

			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()]);
}
 
Example #10
Source File: ExportSarlApplicationPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
protected IPath[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
	IRuntimeClasspathEntry[] entries = AbstractSARLLaunchConfigurationDelegate.computeUnresolvedSARLRuntimeClasspath(
			configuration, this.configAccessor, cfg -> getJavaProject(cfg));

	entries = JavaRuntime.resolveRuntimeClasspath(entries, configuration);

	final boolean isModularConfig = JavaRuntime.isModularConfiguration(configuration);
	final List<IPath> userEntries = new ArrayList<>(entries.length);
	for (int i = 0; i < entries.length; i++) {
		final int classPathProperty = entries[i].getClasspathProperty();
		if ((!isModularConfig && classPathProperty == IRuntimeClasspathEntry.USER_CLASSES)
				|| (isModularConfig && (classPathProperty == IRuntimeClasspathEntry.CLASS_PATH
				|| classPathProperty == IRuntimeClasspathEntry.MODULE_PATH))) {

			final String location = entries[i].getLocation();
			if (location != null) {
				final IPath entry = Path.fromOSString(location);
				if (!userEntries.contains(entry)) {
					userEntries.add(entry);
				}
			}
		}
	}
	return userEntries.toArray(new IPath[userEntries.size()]);
}
 
Example #11
Source File: JavadocStandardWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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));
					}
				}
			}
		}
	}
}
 
Example #12
Source File: FatJarPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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()]);
}
 
Example #13
Source File: FatJarAntExporter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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()]);
}
 
Example #14
Source File: MyMvnSourceContainer.java    From m2e.sourcelookup with Eclipse Public License 1.0 6 votes vote down vote up
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);
  }
 
Example #15
Source File: MyMvnSourceContainer.java    From m2e.sourcelookup with Eclipse Public License 1.0 6 votes vote down vote up
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[] {};
}
 
Example #16
Source File: ReportStandardAppLaunchDelegate.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public String[] getClasspath( ILaunchConfiguration configuration )
		throws CoreException
{
	ScriptDebugClasspathProvider provider = new ScriptDebugClasspathProvider( );
	IRuntimeClasspathEntry[] entries = provider.computeExtraBootClasspath( configuration );
	entries = JavaRuntime.resolveRuntimeClasspath( entries, configuration );
	List userEntries = new ArrayList( entries.length );
	Set set = new HashSet( 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 )
			{
				if ( !set.contains( location ) )
				{
					userEntries.add( location );
					set.add( location );
				}
			}
		}
	}

	return (String[]) userEntries.toArray( new String[userEntries.size( )] );
}
 
Example #17
Source File: AbstractSREInstall.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public List<IRuntimeClasspathEntry> getClassPathEntries() {
	if (isDirty()) {
		setDirty(false);
		resolveDirtyFields(true);
	}
	if (this.classPathEntries == null) {
		return new ArrayList<>();
	}
	return this.classPathEntries;
}
 
Example #18
Source File: AbstractSARLLaunchConfigurationDelegate.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Copied from JDT's super class, and patched for invoking
 * {@link #getOrComputeUnresolvedSARLRuntimeClasspath(ILaunchConfiguration)}.
 * {@inheritDoc}
 */
@Override
public String[] getBootpath(ILaunchConfiguration configuration) throws CoreException {
	final String[][] paths = getBootpathExt(configuration);
	final String[] pre = paths[0];
	final String[] main = paths[1];
	final String[] app = paths[2];
	if (pre == null && main == null && app == null) {
		// default
		return null;
	}
	IRuntimeClasspathEntry[] entries = getOrComputeUnresolvedSARLRuntimeClasspath(configuration);
	entries = JavaRuntime.resolveRuntimeClasspath(entries, configuration);
	final List<String> bootEntries = new ArrayList<>(entries.length);
	boolean empty = true;
	boolean allStandard = true;
	for (int i = 0; i < entries.length; i++) {
		if (entries[i].getClasspathProperty() != IRuntimeClasspathEntry.USER_CLASSES) {
			final String location = entries[i].getLocation();
			if (location != null) {
				empty = false;
				bootEntries.add(location);
				allStandard = allStandard
						&& entries[i].getClasspathProperty() == IRuntimeClasspathEntry.STANDARD_CLASSES;
			}
		}
	}
	if (empty) {
		return new String[0];
	} else if (allStandard) {
		return null;
	} else {
		return bootEntries.toArray(new String[bootEntries.size()]);
	}
}
 
Example #19
Source File: AbstractSARLLaunchConfigurationDelegate.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Copied from JDT's super class, and patched for invoking
 * {@link #getOrComputeUnresolvedSARLRuntimeClasspath(ILaunchConfiguration)}.
 * {@inheritDoc}
 */
@Override
public String[][] getBootpathExt(ILaunchConfiguration configuration)
		throws CoreException {
	final String[][] bootpathInfo = new String[3][];
	final IRuntimeClasspathEntry[] entries = getOrComputeUnresolvedSARLRuntimeClasspath(configuration);
	final List<IRuntimeClasspathEntry> bootEntriesPrepend = new ArrayList<>();
	final IRuntimeClasspathEntry jreEntry;
	final int index;
	final Pair<IRuntimeClasspathEntry, Integer> pair = getJreEntry(entries, bootEntriesPrepend);
	jreEntry = pair.getKey();
	index = pair.getValue().intValue();
	final IRuntimeClasspathEntry[] bootEntriesPrep = JavaRuntime
			.resolveRuntimeClasspath(
					bootEntriesPrepend
					.toArray(new IRuntimeClasspathEntry[bootEntriesPrepend
					                                    .size()]), configuration);
	String[] entriesPrep = null;
	if (bootEntriesPrep.length > 0) {
		entriesPrep = new String[bootEntriesPrep.length];
		for (int i = 0; i < bootEntriesPrep.length; i++) {
			entriesPrep[i] = bootEntriesPrep[i].getLocation();
		}
	}
	if (jreEntry != null) {
		getBootpathExtForJRE(configuration, entries, jreEntry, index, entriesPrep, bootEntriesPrep, bootpathInfo);
	} else {
		if (entriesPrep == null) {
			bootpathInfo[1] = new String[0];
		} else {
			bootpathInfo[1] = entriesPrep;
		}
	}
	return bootpathInfo;
}
 
Example #20
Source File: JreServiceProjectSREProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Construct a SRE installation.
 *
 * @param id the identifier of this SRE installation.
 * @param name the human readable name of this SRE installation.
 * @param location is the location of this SRE installation.
 * @param bootstrap the bootstrap of the SRE installation.
 * @param classpath the libraries on the classpath.
 */
BootstrappedSREInstall(String id, String name, String location, String bootstrap, List<IRuntimeClasspathEntry> classpath) {
	super(id);
	setName(name);
	this.location = location;
	setBootstrap(bootstrap);
	setMainClass(SRE.class.getName());
	setClassPathEntries(classpath);
}
 
Example #21
Source File: AbstractSARLLaunchConfigurationDelegate.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies if the given classpath entry is a SRE.
 *
 * @param entry the entry.
 * @return <code>true</code> if the entry points to a SRE;
 * <code>false</code> otherwise.
 */
private static boolean isNotSREEntry(IRuntimeClasspathEntry entry) {
	try {
		final File file = new File(entry.getLocation());
		if (file.isDirectory()) {
			return !SARLRuntime.isUnpackedSRE(file);
		} else if (file.canRead()) {
			return !SARLRuntime.isPackedSRE(file);
		}
	} catch (Throwable e) {
		SARLEclipsePlugin.getDefault().log(e);
	}
	return true;
}
 
Example #22
Source File: AbstractSREInstall.java    From sarl with Apache License 2.0 5 votes vote down vote up
private IStatus getLibraryLocationValidity(int ignoreCauses) {
	final List<IRuntimeClasspathEntry> locations = getClassPathEntries();
	if ((locations == null || locations.isEmpty()) &&  (ignoreCauses & CODE_LIBRARY_LOCATION) == 0) {
		return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, CODE_LIBRARY_LOCATION,
				Messages.AbstractSREInstall_4);
	}
	return null;
}
 
Example #23
Source File: JdtUtils.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Compute the possible source containers that the specified project could be associated with.
 * <p>
 * If the project name is specified, it will put the source containers parsed from the specified project's
 * classpath entries in the front of the result, then the other projects at the same workspace.
 * </p>
 * <p>
 * Otherwise, just loop every projects at the current workspace and combine the parsed source containers directly.
 * </p>
 * @param projectName
 *                  the project name.
 * @return the possible source container list.
 */
public static ISourceContainer[] getSourceContainers(String projectName) {
    Set<ISourceContainer> containers = new LinkedHashSet<>();
    List<IProject> projects = new ArrayList<>();

    // If the project name is specified, firstly compute the source containers from the specified project's
    // classpath entries so that they can be placed in the front of the result.
    IProject targetProject = JdtUtils.getProject(projectName);
    if (targetProject != null) {
        projects.add(targetProject);
    }

    List<IProject> workspaceProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
    projects.addAll(workspaceProjects);

    Set<IRuntimeClasspathEntry> calculated = new LinkedHashSet<>();

    projects.stream().distinct().map(project -> JdtUtils.getJavaProject(project))
        .filter(javaProject -> javaProject != null && javaProject.exists())
        .forEach(javaProject -> {
            // Add source containers associated with the project's runtime classpath entries.
            containers.addAll(Arrays.asList(getSourceContainers(javaProject, calculated)));
            // Add source containers associated with the project's source folders.
            containers.add(new JavaProjectSourceContainer(javaProject));
        });

    return containers.toArray(new ISourceContainer[0]);
}
 
Example #24
Source File: ISREInstall.java    From sarl with Apache License 2.0 5 votes vote down vote up
/**
 * Change the library locations of this ISREInstall.
 *
 * @param libraries The library locations of this ISREInstall.
 *     Must not be {@code null}.
 */
default void setClassPathEntries(Iterable<IRuntimeClasspathEntry> libraries) {
	final List<IRuntimeClasspathEntry> list;
	if (libraries == null) {
		list = null;
	} else if (libraries instanceof List<?>) {
		list = (List<IRuntimeClasspathEntry>) libraries;
	} else {
		list = new ArrayList<>();
		for (final IRuntimeClasspathEntry cpe : libraries) {
			list.add(cpe);
		}
	}
	setClassPathEntries(list);
}
 
Example #25
Source File: BundleUtil.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** The runtime class path entry for the bundle.
 *
 * @return the runtime classpath entry.
 */
public IRuntimeClasspathEntry getRuntimeClassPathEntry() {
	if (this.classpathEntry != null && this.runtimeClasspathEntry == null) {
		this.runtimeClasspathEntry = new RuntimeClasspathEntry(this.classpathEntry);
	}
	return this.runtimeClasspathEntry;
}
 
Example #26
Source File: StandardSREInstallTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Test
public void getClassPathEntry() {
	
	List<IRuntimeClasspathEntry> locations = new ArrayList<>();
	LibraryLocation location = new LibraryLocation(this.path, Path.EMPTY, Path.EMPTY);
	IClasspathEntry cpEntry = JavaCore.newLibraryEntry(
			location.getSystemLibraryPath(),
			location.getSystemLibrarySourcePath(),
			location.getPackageRootPath());
	IRuntimeClasspathEntry rtcpEntry = new RuntimeClasspathEntry(cpEntry);			
	rtcpEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
	locations.add(rtcpEntry);
	
	assertEquals(locations, this.sre.getClassPathEntries());
}
 
Example #27
Source File: ScriptSourcePathComputerDelegate.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public ISourceContainer[] computeSourceContainers(
		ILaunchConfiguration configuration, IProgressMonitor monitor )
		throws CoreException
{
	List containers = new ArrayList( );

	String path = getPath( configuration );

	if ( path != null )
	{
		containers.add( new ScriptDirectorySourceContainer( new File( path ),
				false ) );
	}

	// always use standard source path provider to avoid PDE setting overwritten
	IRuntimeClasspathProvider scp = new StandardSourcePathProvider( );

	IRuntimeClasspathEntry[] entries = scp.computeUnresolvedClasspath( configuration );
	IRuntimeClasspathEntry[] resolved = scp.resolveClasspath( entries,
			configuration );
	ISourceContainer[] cts = JavaRuntime.getSourceContainers( resolved );

	if ( cts != null )
	{
		for ( int i = 0; i < cts.length; i++ )
		{
			containers.add( cts[i] );
		}
	}

	return (ISourceContainer[]) containers.toArray( new ISourceContainer[containers.size( )] );
}
 
Example #28
Source File: ReportLaunchHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private static String[] getUserClasspath( ILaunchConfiguration configuration )
{
	try
	{
		ScriptDebugClasspathProvider provider = new ScriptDebugClasspathProvider( );
		IRuntimeClasspathEntry[] entries = provider.computeUserClasspath( configuration );
		entries = JavaRuntime.resolveRuntimeClasspath( entries,
				configuration );

		List userEntries = new ArrayList( );

		Set set = new HashSet( 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 )
				{
					if ( !set.contains( location ) )
					{
						userEntries.add( location );
						set.add( location );
					}
				}
			}
		}

		return (String[]) userEntries.toArray( new String[userEntries.size( )] );
	}
	catch ( CoreException e )
	{
		e.printStackTrace( );
	}

	return null;
}
 
Example #29
Source File: ScriptMainTab.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void addEngineLibHomeClassPath( String fileDirectory, List list )
{
	File file = new File( fileDirectory );
	if ( !file.exists( ) || !file.isDirectory( ) )
	{
		return;
	}

	IPath path = new Path( fileDirectory );

	String[] files = file.list( );
	if ( files == null )
	{
		return;
	}
	int len = files.length;
	for ( int i = 0; i < len; i++ )
	{
		IPath temp = path.append( files[i] ).makeAbsolute( );
		if ( temp.toFile( ).exists( ) && isJarFile( temp ) )
		{
			try
			{
				IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry( temp );
				String mometo = entry.getMemento( );
				if ( !list.contains( mometo ) )
				{
					list.add( mometo );
				}
			}
			catch ( CoreException e )
			{

			}
		}
	}
}
 
Example #30
Source File: JreServiceProjectSREProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Construct a SRE installation provider.
 *
 * @param id the identifier of this SRE installation.
 * @param name the human readable name of this SRE installation.
 * @param location is the location of this SRE installation.
 * @param bootstrap the bootstrap of the SRE installation.
 * @param classpath the classpath associated to the provided SRE.
 */
public JreServiceProjectSREProvider(String id, String name, String location, String bootstrap,
		List<IRuntimeClasspathEntry> classpath) {
	this.id = id;
	this.name = name;
	this.location = location;
	this.bootstrap = bootstrap;
	this.classpath = classpath;
}