Don't filter class files and jars from build script. Get a warning about their absence.
This commit is contained in:
+11
-1
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import kotlin.KotlinPackage;
|
||||
import kotlin.io.IoPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
@@ -117,7 +118,16 @@ public class KotlinBuilderModuleScriptGenerator {
|
||||
return ContainerUtil.filter(getAllDependencies(target).classes().getRoots(), new Condition<File>() {
|
||||
@Override
|
||||
public boolean value(File file) {
|
||||
return file.exists();
|
||||
if (!file.exists()) {
|
||||
String extension = IoPackage.getExtension(file);
|
||||
|
||||
// Don't filter out files, we want to report warnings about absence through the common place
|
||||
if (!(extension.equals("class") || extension.equals("jar"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,9 +105,13 @@ public abstract class AbstractKotlinJpsBuildTestCase extends JpsBuildTestCase {
|
||||
return addDependency(type, modules, exported, "KotlinJavaScript", PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath());
|
||||
}
|
||||
|
||||
protected static JpsLibrary addDependency(JpsJavaDependencyScope type, Collection<JpsModule> modules, boolean exported, String libraryName, File file) {
|
||||
protected static JpsLibrary addDependency(JpsJavaDependencyScope type, Collection<JpsModule> modules, boolean exported, String libraryName, File... file) {
|
||||
JpsLibrary library = modules.iterator().next().getProject().addLibrary(libraryName, JpsJavaLibraryType.INSTANCE);
|
||||
library.addRoot(file, JpsOrderRootType.COMPILED);
|
||||
|
||||
for (File fileRoot : file) {
|
||||
library.addRoot(fileRoot, JpsOrderRootType.COMPILED);
|
||||
}
|
||||
|
||||
for (JpsModule module : modules) {
|
||||
JpsModuleRootModificationUtil.addDependency(module, library, type, exported);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.junit.Assert
|
||||
import java.io.*
|
||||
import java.util.Arrays
|
||||
import java.util.Collections
|
||||
@@ -592,6 +593,31 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
assertFilesNotExistInOutput(module, "foo/Bar.class")
|
||||
}
|
||||
|
||||
public fun testFileDoesNotExistWarning() {
|
||||
initProject()
|
||||
|
||||
AbstractKotlinJpsBuildTestCase.addDependency(
|
||||
JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "LibraryWithBadRoots",
|
||||
File("badroot.jar"),
|
||||
File("test/other/file.xml"),
|
||||
File("some/test.class"),
|
||||
File("some/other/baddir"))
|
||||
|
||||
val result = makeAll()
|
||||
result.assertSuccessful()
|
||||
|
||||
val warnings = result.getMessages(BuildMessage.Kind.WARNING)
|
||||
|
||||
Assert.assertArrayEquals(
|
||||
arrayOf(
|
||||
"""Classpath entry points to a non-existent location: TEST_PATH/badroot.jar""",
|
||||
"""Classpath entry points to a non-existent location: TEST_PATH/some/test.class"""),
|
||||
warnings.map {
|
||||
it.messageText.replace(File("").absolutePath, "TEST_PATH").replace("\\", "/")
|
||||
}.sort().toTypedArray()
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildCustom(canceledStatus: CanceledStatus, logger: TestProjectBuilderLogger,buildResult: BuildResult) {
|
||||
val scopeBuilder = CompileScopeTestBuilder.make().all()
|
||||
val descriptor = this.createProjectDescriptor(BuildLoggingManager(logger))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA_JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Bar
|
||||
Reference in New Issue
Block a user