private void addJreClasspath() { try { IRuntimeClasspathEntry computeJREEntry = JavaRuntime.computeJREEntry(javaProject); if (computeJREEntry == null) { return; } IRuntimeClasspathEntry[] jreEntries = JavaRuntime.resolveRuntimeClasspathEntry(computeJREEntry, javaProject); if (jreEntries.length != 0) { for (IRuntimeClasspathEntry jreEntry : jreEntries) { addToClasspath(jreEntry.getClasspathEntry().getPath().toFile()); } return; } } catch (JavaModelException e) { KotlinLogger.logAndThrow(e); } catch (CoreException e) { KotlinLogger.logAndThrow(e); } }
protected void computeRuntimeClassPath() throws CoreException { runtimeDependencies = new ArrayList<String>(); IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(javaProject); IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(javaProject); List<IRuntimeClasspathEntry> resolved = new ArrayList<IRuntimeClasspathEntry>(); // Resolve all runtime entries, and skip the jre entry for (IRuntimeClasspathEntry rcEntry : unresolved) { if (rcEntry.equals(jreEntry)) { continue; } else { IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspathEntry(rcEntry, javaProject); if (entries != null) { resolved.addAll(Arrays.asList(entries)); } } } // Separate dependency entries like archives from other runtime entries List<IRuntimeClasspathEntry> toSeparate = new ArrayList<IRuntimeClasspathEntry>(resolved); for (IRuntimeClasspathEntry entry : resolved) { String entryLocation = entry.getLocation(); if (isAccessibleFile(entryLocation)) { toSeparate.remove(entry); runtimeDependencies.add(entry.getLocation()); } } resolved = toSeparate; if (shouldSkipTestSources()) { // The special case to consider is if both the test source and non // test source have the same output location // if that is the case, the runtime entry associated with that // output location CANNOT be skipped. The only time // the test source entry can be skipped is if the output location // for that entry is NOT also used by a non test source entry Collection<String> testSourceOutputLocations = getTestSourceOutputLocations(); Collection<String> nonTestSourceOutputLocations = getNonTestSourceOutputLocations(); List<IRuntimeClasspathEntry> nonTestEntries = new ArrayList<IRuntimeClasspathEntry>(resolved); for (IRuntimeClasspathEntry entry : resolved) { String entryLocation = entry.getLocation(); if (testSourceOutputLocations.contains(entryLocation) && !nonTestSourceOutputLocations.contains(entryLocation)) { nonTestEntries.remove(entry); } } resolved = nonTestEntries; } Set<String> resolvedEntryLocations = new HashSet<String>(resolved.size()); for (IRuntimeClasspathEntry entry : resolved) { resolvedEntryLocations.add(entry.getLocation()); } runtimeSource = new ArrayList<String>(resolvedEntryLocations); }