test output placed before production output in classpath for consistency

This commit is contained in:
nik
2010-06-30 10:17:19 +04:00
parent f4164a76e5
commit f37ffe483d
3 changed files with 48 additions and 21 deletions
@@ -300,13 +300,15 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
OrderRootType.COMPILATION_CLASSES.equals(type) ||
OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final ArrayList<VirtualFile> result = new ArrayList<VirtualFile>();
final VirtualFile outputPathForTests = OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type) ? null : getCompilerOutputPathForTests();
if (outputPathForTests != null) {
result.add(outputPathForTests);
}
VirtualFile outputRoot = getCompilerOutputPath();
if (outputRoot != null) result.add(outputRoot);
if (!OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final VirtualFile outputPathForTests = getCompilerOutputPathForTests();
if (outputPathForTests != null && !outputPathForTests.equals(outputRoot)) {
result.add(outputPathForTests);
}
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
result.add(outputRoot);
}
return VfsUtil.toVirtualFileArray(result);
}
@@ -319,13 +321,15 @@ public class CompilerModuleExtensionImpl extends CompilerModuleExtension {
OrderRootType.COMPILATION_CLASSES.equals(type) ||
OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final List<String> result = new ArrayList<String>();
final String outputPathForTests = OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type) ? null : getCompilerOutputUrlForTests();
if (outputPathForTests != null) {
result.add(outputPathForTests);
}
String outputRoot = getCompilerOutputUrl();
if (outputRoot != null) result.add(outputRoot);
if (!OrderRootType.PRODUCTION_COMPILATION_CLASSES.equals(type)) {
final String outputPathForTests = getCompilerOutputUrlForTests();
if (outputPathForTests != null && !outputPathForTests.equals(outputRoot)) {
result.add(outputPathForTests);
}
if (outputRoot != null && !outputRoot.equals(outputPathForTests)) {
result.add(outputRoot);
}
return ArrayUtil.toStringArray(result);
}
@@ -3,9 +3,10 @@ package com.intellij.roots;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderEnumerator;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.roots.ModuleRootManagerTestCase;
import com.intellij.util.PathsList;
/**
* @author nik
@@ -28,8 +29,8 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
assertOrderFiles(OrderRootType.CLASSES, getRtJar());
assertOrderFiles(OrderRootType.SOURCES, srcRoot, testRoot);
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), output, testOutput);
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), output, testOutput);
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), testOutput, output);
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), testOutput, output);
assertOrderFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES, getRtJar(), output);
}
@@ -54,8 +55,8 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
assertOrderFiles(OrderRootType.CLASSES, getRtJar(), getJDomJar());
assertOrderFiles(OrderRootType.SOURCES, srcRoot, testRoot, getJDomSources());
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), output, testOutput, getJDomJar());
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), output, testOutput, getJDomJar());
assertOrderFiles(OrderRootType.CLASSES_AND_OUTPUT, getRtJar(), testOutput, output, getJDomJar());
assertOrderFiles(OrderRootType.COMPILATION_CLASSES, getRtJar(), testOutput, output, getJDomJar());
assertOrderFiles(OrderRootType.PRODUCTION_COMPILATION_CLASSES, getRtJar(), output, getJDomJar());
}
@@ -85,6 +86,27 @@ public class OrderEntriesTest extends ModuleRootManagerTestCase {
private void assertOrderFiles(final OrderRootType type, VirtualFile... files) {
assertOrderedEquals(ModuleRootManager.getInstance(myModule).getFiles(type), files);
assertRoots(collectByOrderEnumerator(type), files);
}
private PathsList collectByOrderEnumerator(OrderRootType type) {
final OrderEnumerator base = OrderEnumerator.orderEntries(myModule);
if (type == OrderRootType.CLASSES_AND_OUTPUT) {
return base.recursively().getPathsList();
}
if (type == OrderRootType.COMPILATION_CLASSES) {
return base.recursively().exportedOnly().getPathsList();
}
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
return base.productionOnly().recursively().exportedOnly().getPathsList();
}
if (type == OrderRootType.CLASSES) {
return base.withoutModuleSourceEntries().recursively().exportedOnly().getPathsList();
}
if (type == OrderRootType.SOURCES) {
return base.recursively().exportedOnly().getSourcePathsList();
}
throw new AssertionError(type);
}
}
@@ -42,7 +42,7 @@ public class OrderRootType {
* Runtime classpath.
* Includes:
* <li> production and test output for modules
* <li> classes roots for libraries unless scope is 'provided'
* <li> classes roots for libraries and jdk unless scope is 'provided'
* <li> recursively for module dependencies with scope != 'provided'
*/
public static final OrderRootType CLASSES_AND_OUTPUT = new OrderRootType("CLASSES_AND_OUTPUT");
@@ -51,7 +51,7 @@ public class OrderRootType {
* Classpath for compilation.
* Includes:
* <li> production and test output for modules
* <li> classes roots for libraries
* <li> classes roots for libraries and jdk
* <li> recursively for module dependencies: only exported items
*/
public static final OrderRootType COMPILATION_CLASSES = new OrderRootType("COMPILATION_CLASSES");
@@ -60,7 +60,7 @@ public class OrderRootType {
* Classpath for compilation without tests.
* Includes:
* <li> production output for modules
* <li> classes roots for libraries with scope suitable for production compile
* <li> classes roots for libraries and jdk with scope suitable for production compile
* <li> recursively for module dependencies with scope suitable for production compile: only exported items
*/
public static final OrderRootType PRODUCTION_COMPILATION_CLASSES = new OrderRootType("PRODUCTION_COMPILATION_CLASSES");
@@ -68,7 +68,7 @@ public class OrderRootType {
/**
* Classpath without output directories for this module.
* Includes:
* <li> classes roots for libraries
* <li> classes roots for libraries and jdk
* <li> recursively for module dependencies: only exported items
*/
public static final OrderRootType CLASSES = new PersistentOrderRootType("CLASSES", "classPath", null, "classPathEntry");
@@ -77,6 +77,7 @@ public class OrderRootType {
* Sources.
* Includes:
* <li> production and test source roots for modules
* <li> source roots for libraries and jdk
* <li> recursively for module dependencies: only exported items
*/
public static final OrderRootType SOURCES = new PersistentOrderRootType("SOURCES", "sourcePath", null, "sourcePathEntry");