do not copy js files from libraries in case of compile errors
This commit is contained in:
@@ -142,7 +142,11 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
||||
if (compilationErrors) {
|
||||
return ABORT
|
||||
}
|
||||
|
||||
|
||||
if (JpsUtils.isJsKotlinModule(chunk.representativeTarget())) {
|
||||
copyJsLibraryFilesIfNeeded(chunk, project)
|
||||
}
|
||||
|
||||
if (IncrementalCompilation.ENABLED) {
|
||||
if (recompilationDecision == IncrementalCacheImpl.RecompilationDecision.RECOMPILE_ALL) {
|
||||
allCompiledFiles.clear()
|
||||
@@ -304,13 +308,19 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
||||
val k2JsArguments = JpsKotlinCompilerSettings.getK2JsCompilerArguments(project)
|
||||
|
||||
runK2JsCompiler(commonArguments, k2JsArguments, compilerSettings, messageCollector, environment, outputItemCollector, sourceFiles, libraryFiles, outputFile)
|
||||
return outputItemCollector
|
||||
}
|
||||
|
||||
private fun copyJsLibraryFilesIfNeeded(chunk: ModuleChunk, project: JpsProject) {
|
||||
val representativeTarget = chunk.representativeTarget()
|
||||
val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(representativeTarget)
|
||||
val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(project)
|
||||
if (compilerSettings.copyJsLibraryFiles) {
|
||||
val outputLibraryRuntimeDirectory = File(outputDir, compilerSettings.outputDirectoryForJsLibraryFiles).getAbsolutePath()
|
||||
val libraryFilesToCopy = arrayListOf<String>()
|
||||
JpsJsModuleUtils.getLibraryFiles(representativeTarget, libraryFilesToCopy)
|
||||
LibraryUtils.copyJsFilesFromLibraries(libraryFilesToCopy, outputLibraryRuntimeDirectory)
|
||||
}
|
||||
return outputItemCollector
|
||||
}
|
||||
|
||||
// if null is returned, nothing was done
|
||||
|
||||
@@ -185,6 +185,16 @@ public class KotlinJpsBuildTest extends AbstractKotlinJpsBuildTestCase {
|
||||
checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME));
|
||||
}
|
||||
|
||||
public void testKotlinJavaScriptProjectWithLibraryAndErrors() {
|
||||
initProject();
|
||||
addKotlinJavaScriptStdlibDependency();
|
||||
createKotlinJavaScriptLibraryArchive();
|
||||
addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, new File(workDir, KOTLIN_JS_LIBRARY_JAR));
|
||||
makeAll().assertFailed();
|
||||
|
||||
assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME));
|
||||
}
|
||||
|
||||
public void testExcludeFolderInSourceRoot() {
|
||||
doTest();
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?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" />
|
||||
<orderEntry type="module" module-name="kotlinProject" />
|
||||
</component>
|
||||
</module>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
</component>
|
||||
<component name="KotlinCompilerSettings">
|
||||
<option name="copyJsLibraryFiles" value="false" />
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.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,7 @@
|
||||
import library.sample.pairAdd
|
||||
|
||||
fun foo() {
|
||||
val p = Pair1(10, 20)
|
||||
val x = pairAdd(p)
|
||||
println("x=$x")
|
||||
}
|
||||
Reference in New Issue
Block a user