mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not include JDK classes from module dependencies to classpath
This commit is contained in:
+3
-3
@@ -30,13 +30,13 @@ public class JavaParametersTest extends ModuleRootManagerTestCase {
|
||||
public void testLibrary() throws Exception {
|
||||
ModuleRootModificationUtil.addDependency(myModule, createJDomLibrary());
|
||||
assertClasspath(myModule, JavaParameters.JDK_AND_CLASSES_AND_TESTS,
|
||||
getRtJar(), getJDomJar());
|
||||
getRtJarJdk17(), getJDomJar());
|
||||
assertClasspath(myModule, JavaParameters.CLASSES_ONLY,
|
||||
getJDomJar());
|
||||
assertClasspath(myModule, JavaParameters.CLASSES_AND_TESTS,
|
||||
getJDomJar());
|
||||
assertClasspath(myProject, JavaParameters.JDK_AND_CLASSES_AND_TESTS,
|
||||
getRtJar(), getJDomJar());
|
||||
getRtJarJdk17(), getJDomJar());
|
||||
}
|
||||
|
||||
public void testModuleSourcesAndOutput() throws Exception {
|
||||
@@ -50,7 +50,7 @@ public class JavaParametersTest extends ModuleRootManagerTestCase {
|
||||
assertClasspath(myModule, JavaParameters.CLASSES_AND_TESTS,
|
||||
testOutput, output);
|
||||
assertClasspath(myModule, JavaParameters.JDK_AND_CLASSES_AND_TESTS,
|
||||
getRtJar(), testOutput, output);
|
||||
getRtJarJdk17(), testOutput, output);
|
||||
}
|
||||
|
||||
public void testLibraryScope() throws Exception {
|
||||
|
||||
@@ -9,9 +9,11 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.ModuleTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.PathsList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -25,7 +27,20 @@ public abstract class ModuleRootManagerTestCase extends ModuleTestCase {
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectJdk() {
|
||||
final Sdk jdk = super.getTestProjectJdk();
|
||||
return getMockJdk17WithRtJarOnly();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Sdk getMockJdk17WithRtJarOnly() {
|
||||
return retainRtJarOnly(IdeaTestUtil.getMockJdk17());
|
||||
}
|
||||
|
||||
protected Sdk getMockJdk18WithRtJarOnly() {
|
||||
return retainRtJarOnly(IdeaTestUtil.getMockJdk18());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Sdk retainRtJarOnly(Sdk jdk) {
|
||||
final SdkModificator modificator = jdk.getSdkModificator();
|
||||
VirtualFile rtJar = null;
|
||||
for (VirtualFile root : modificator.getRoots(OrderRootType.CLASSES)) {
|
||||
@@ -41,8 +56,12 @@ public abstract class ModuleRootManagerTestCase extends ModuleTestCase {
|
||||
return jdk;
|
||||
}
|
||||
|
||||
protected VirtualFile getRtJar() {
|
||||
return getTestProjectJdk().getRootProvider().getFiles(OrderRootType.CLASSES)[0];
|
||||
protected VirtualFile getRtJarJdk17() {
|
||||
return getMockJdk17WithRtJarOnly().getRootProvider().getFiles(OrderRootType.CLASSES)[0];
|
||||
}
|
||||
|
||||
protected VirtualFile getRtJarJdk18() {
|
||||
return getMockJdk18WithRtJarOnly().getRootProvider().getFiles(OrderRootType.CLASSES)[0];
|
||||
}
|
||||
|
||||
protected VirtualFile getJDomJar() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.intellij.util.PathsList;
|
||||
public class OrderEntriesTest extends ModuleRootManagerTestCase {
|
||||
public void testLibrary() throws Exception {
|
||||
ModuleRootModificationUtil.addDependency(myModule, createJDomLibrary());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJar(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJarJdk17(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.SOURCES, getJDomSources());
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
|
||||
final VirtualFile srcRoot = addSourceRoot(myModule, false);
|
||||
final VirtualFile testRoot = addSourceRoot(myModule, true);
|
||||
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJar());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJarJdk17());
|
||||
assertOrderFiles(OrderRootType.SOURCES, srcRoot, testRoot);
|
||||
}
|
||||
|
||||
public void testLibraryScope() throws Exception {
|
||||
ModuleRootModificationUtil.addDependency(myModule, createJDomLibrary(), DependencyScope.TEST, false);
|
||||
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJar(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJarJdk17(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.SOURCES, getJDomSources());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
|
||||
ModuleRootModificationUtil.addDependency(dep, createJDomLibrary(), DependencyScope.COMPILE, true);
|
||||
ModuleRootModificationUtil.addDependency(myModule, dep, DependencyScope.COMPILE, false);
|
||||
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJar(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJarJdk17(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.SOURCES, srcRoot, testRoot, getJDomSources());
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
|
||||
ModuleRootModificationUtil.addDependency(dep, createJDomLibrary(), DependencyScope.COMPILE, true);
|
||||
ModuleRootModificationUtil.addDependency(myModule, dep, DependencyScope.TEST, true);
|
||||
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJar(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJarJdk17(), getJDomJar());
|
||||
assertOrderFiles(OrderRootType.SOURCES, getJDomSources());
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
|
||||
ModuleRootModificationUtil.addDependency(dep, createJDomLibrary(), DependencyScope.COMPILE, false);
|
||||
ModuleRootModificationUtil.addDependency(myModule, dep, DependencyScope.COMPILE, false);
|
||||
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJar());
|
||||
assertOrderFiles(OrderRootType.CLASSES, getRtJarJdk17());
|
||||
assertOrderFiles(OrderRootType.SOURCES);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ public class OrderEnumeratorTest extends ModuleRootManagerTestCase {
|
||||
public void testLibrary() throws Exception {
|
||||
ModuleRootModificationUtil.addDependency(myModule, createJDomLibrary());
|
||||
|
||||
assertClassRoots(orderEntries(myModule), getRtJar(), getJDomJar());
|
||||
assertClassRoots(orderEntries(myModule), getRtJarJdk17(), getJDomJar());
|
||||
assertClassRoots(orderEntries(myModule).withoutSdk(), getJDomJar());
|
||||
assertClassRoots(orderEntries(myModule).withoutSdk().productionOnly().runtimeOnly(), getJDomJar());
|
||||
assertClassRoots(orderEntries(myModule).withoutLibraries(), getRtJar());
|
||||
assertClassRoots(orderEntries(myModule).withoutLibraries(), getRtJarJdk17());
|
||||
assertSourceRoots(orderEntries(myModule), getJDomSources());
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class OrderEnumeratorTest extends ModuleRootManagerTestCase {
|
||||
|
||||
public void testCaching() throws Exception {
|
||||
final VirtualFile[] roots = orderEntries(myModule).classes().usingCache().getRoots();
|
||||
assertOrderedEquals(roots, getRtJar());
|
||||
assertOrderedEquals(roots, getRtJarJdk17());
|
||||
assertEquals(roots, orderEntries(myModule).classes().usingCache().getRoots());
|
||||
final VirtualFile[] rootsWithoutSdk = orderEntries(myModule).withoutSdk().classes().usingCache().getRoots();
|
||||
assertEmpty(rootsWithoutSdk);
|
||||
@@ -128,13 +128,13 @@ public class OrderEnumeratorTest extends ModuleRootManagerTestCase {
|
||||
|
||||
ModuleRootModificationUtil.addDependency(myModule, createJDomLibrary());
|
||||
|
||||
assertRoots(orderEntries(myModule).classes().usingCache().getPathsList(), getRtJar(), getJDomJar());
|
||||
assertRoots(orderEntries(myModule).classes().usingCache().getPathsList(), getRtJarJdk17(), getJDomJar());
|
||||
assertRoots(orderEntries(myModule).withoutSdk().classes().usingCache().getPathsList(), getJDomJar());
|
||||
}
|
||||
|
||||
public void testCachingUrls() throws Exception {
|
||||
final String[] urls = orderEntries(myModule).classes().usingCache().getUrls();
|
||||
assertOrderedEquals(urls, getRtJar().getUrl());
|
||||
assertOrderedEquals(urls, getRtJarJdk17().getUrl());
|
||||
assertSame(urls, orderEntries(myModule).classes().usingCache().getUrls());
|
||||
|
||||
final String[] sourceUrls = orderEntries(myModule).sources().usingCache().getUrls();
|
||||
@@ -143,7 +143,7 @@ public class OrderEnumeratorTest extends ModuleRootManagerTestCase {
|
||||
assertSame(sourceUrls, orderEntries(myModule).sources().usingCache().getUrls());
|
||||
|
||||
ModuleRootModificationUtil.addDependency(myModule, createJDomLibrary());
|
||||
assertOrderedEquals(orderEntries(myModule).classes().usingCache().getUrls(), getRtJar().getUrl(), getJDomJar().getUrl());
|
||||
assertOrderedEquals(orderEntries(myModule).classes().usingCache().getUrls(), getRtJarJdk17().getUrl(), getJDomJar().getUrl());
|
||||
assertOrderedEquals(orderEntries(myModule).sources().usingCache().getUrls(), getJDomSources().getUrl());
|
||||
}
|
||||
|
||||
@@ -173,6 +173,15 @@ public class OrderEnumeratorTest extends ModuleRootManagerTestCase {
|
||||
srcRoot, testRoot, getJDomSources());
|
||||
}
|
||||
|
||||
public void testDoNotAddJdkRootFromModuleDependency() {
|
||||
final Module dep = createModule("dep");
|
||||
ModuleRootModificationUtil.addDependency(myModule, dep);
|
||||
ModuleRootModificationUtil.setModuleSdk(dep, getMockJdk17WithRtJarOnly());
|
||||
ModuleRootModificationUtil.setModuleSdk(myModule, getMockJdk18WithRtJarOnly());
|
||||
assertClassRoots(orderEntries(dep), getRtJarJdk17());
|
||||
assertClassRoots(orderEntries(myModule).recursively(), getRtJarJdk18());
|
||||
}
|
||||
|
||||
private static void assertClassRoots(final OrderEnumerator enumerator, VirtualFile... files) {
|
||||
assertEnumeratorRoots(enumerator.classes(), files);
|
||||
}
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume
|
||||
for (OrderEntry entry : rootModel.getOrderEntries()) {
|
||||
if (myCondition != null && !myCondition.value(entry)) continue;
|
||||
|
||||
if (myWithoutJdk && entry instanceof JdkOrderEntry) continue;
|
||||
if (entry instanceof JdkOrderEntry && (myWithoutJdk || !firstLevel)) continue;
|
||||
if (myWithoutLibraries && entry instanceof LibraryOrderEntry) continue;
|
||||
if (myWithoutDepModules) {
|
||||
if (!myRecursively && entry instanceof ModuleOrderEntry) continue;
|
||||
|
||||
Reference in New Issue
Block a user