Java Code Examples for org.eclipse.jdt.launching.JavaRuntime#resolveRuntimeClasspath()
The following examples show how to use
org.eclipse.jdt.launching.JavaRuntime#resolveRuntimeClasspath() .
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: FatJarPackageWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 2
Source File: FatJarAntExporter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 3
Source File: FixedFatJarExportPage.java From sarl with Apache License 2.0 | 6 votes |
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 4
Source File: ExportSarlApplicationPage.java From sarl with Apache License 2.0 | 6 votes |
@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 5
Source File: ReportStandardAppLaunchDelegate.java From birt with Eclipse Public License 1.0 | 6 votes |
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 6
Source File: ResolveClasspathsHandler.java From java-debug with Eclipse Public License 1.0 | 5 votes |
/** * Compute runtime classpath of a java project. * * @param javaProject java project * @param excludeTestCode whether to exclude the test code and test dependencies * @param mappedResources the associated resources with the application * @return class path * @throws CoreException * CoreException */ private static String[][] computeClassPath(IJavaProject javaProject, String mainType, boolean excludeTestCode, List<IResource> mappedResources) throws CoreException { if (javaProject == null) { throw new IllegalArgumentException("javaProject is null"); } ILaunchConfiguration launchConfig = new JavaApplicationLaunchConfiguration(javaProject.getProject(), mainType, excludeTestCode, mappedResources); IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(launchConfig); IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspath(unresolved, launchConfig); Set<String> classpaths = new LinkedHashSet<>(); Set<String> modulepaths = new LinkedHashSet<>(); for (IRuntimeClasspathEntry entry : resolved) { String location = entry.getLocation(); if (location != null) { if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES || entry.getClasspathProperty() == IRuntimeClasspathEntry.CLASS_PATH) { classpaths.add(location); } else if (entry.getClasspathProperty() == IRuntimeClasspathEntry.MODULE_PATH) { modulepaths.add(location); } } } return new String[][] { modulepaths.toArray(new String[modulepaths.size()]), classpaths.toArray(new String[classpaths.size()]) }; }
Example 7
Source File: AbstractSARLLaunchConfigurationDelegate.java From sarl with Apache License 2.0 | 5 votes |
/** 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 8
Source File: AbstractSARLLaunchConfigurationDelegate.java From sarl with Apache License 2.0 | 5 votes |
/** 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 9
Source File: ReportLaunchHelper.java From birt with Eclipse Public License 1.0 | 5 votes |
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 10
Source File: AbstractSARLLaunchConfigurationDelegate.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings("checkstyle:npathcomplexity") private void getBootpathExtForJRE(ILaunchConfiguration configuration, IRuntimeClasspathEntry[] entries, IRuntimeClasspathEntry jreEntry, int idx, String[] entriesPrep, IRuntimeClasspathEntry[] bootEntriesPrep, String[][] bootpathInfo) throws CoreException { int index = idx; final List<IRuntimeClasspathEntry> bootEntriesAppend = new ArrayList<>(); for (; index < entries.length; index++) { final IRuntimeClasspathEntry entry = entries[index]; if (entry.getClasspathProperty() == IRuntimeClasspathEntry.BOOTSTRAP_CLASSES) { bootEntriesAppend.add(entry); } } bootpathInfo[0] = entriesPrep; final IRuntimeClasspathEntry[] bootEntriesApp = JavaRuntime .resolveRuntimeClasspath( bootEntriesAppend .toArray(new IRuntimeClasspathEntry[bootEntriesAppend .size()]), configuration); if (bootEntriesApp.length > 0) { bootpathInfo[2] = new String[bootEntriesApp.length]; for (int i = 0; i < bootEntriesApp.length; i++) { bootpathInfo[2][i] = bootEntriesApp[i].getLocation(); } } final IVMInstall install = getVMInstall(configuration); final LibraryLocation[] libraryLocations = install.getLibraryLocations(); if (libraryLocations != null) { // determine if explicit bootpath should be used if (!JRERuntimeClasspathEntryResolver.isSameArchives(libraryLocations, install.getVMInstallType().getDefaultLibraryLocations(install.getInstallLocation()))) { // resolve bootpath entries in JRE entry final IRuntimeClasspathEntry[] bootEntries; if (jreEntry.getType() == IRuntimeClasspathEntry.CONTAINER) { final IRuntimeClasspathEntry bootEntry = JavaRuntime.newRuntimeContainerClasspathEntry( jreEntry.getPath(), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES, getJavaProject(configuration)); bootEntries = JavaRuntime.resolveRuntimeClasspathEntry(bootEntry, configuration); } else { bootEntries = JavaRuntime.resolveRuntimeClasspathEntry(jreEntry, configuration); } // non-default JRE libraries - use explicit bootpath only final String[] bootpath = new String[bootEntriesPrep.length + bootEntries.length + bootEntriesApp.length]; if (bootEntriesPrep.length > 0) { System.arraycopy(bootpathInfo[0], 0, bootpath, 0, bootEntriesPrep.length); } int dest = bootEntriesPrep.length; for (int i = 0; i < bootEntries.length; i++) { bootpath[dest] = bootEntries[i].getLocation(); dest++; } if (bootEntriesApp.length > 0) { System.arraycopy(bootpathInfo[2], 0, bootpath, dest, bootEntriesApp.length); } bootpathInfo[0] = null; bootpathInfo[1] = bootpath; bootpathInfo[2] = null; } } }