JS DCE: drop unknown file report severity to WARNING
*.kjsm and other files might be received when FileCollection is
used in Gradle as a dependency.
Example: `testCompile project(":$coroutines_core").sourceSets.test.output`
(a popular-ish solution to introduce dependencies between tests)
This commit is contained in:
@@ -33,18 +33,11 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
|||||||
|
|
||||||
override fun execImpl(messageCollector: MessageCollector, services: Services, arguments: K2JSDceArguments): ExitCode {
|
override fun execImpl(messageCollector: MessageCollector, services: Services, arguments: K2JSDceArguments): ExitCode {
|
||||||
val baseDir = File(arguments.outputDirectory ?: "min")
|
val baseDir = File(arguments.outputDirectory ?: "min")
|
||||||
var hasErrors = false
|
|
||||||
val files = arguments.freeArgs.flatMap { arg ->
|
val files = arguments.freeArgs.flatMap { arg ->
|
||||||
val files = collectInputFiles(baseDir, arg, messageCollector)
|
collectInputFiles(baseDir, arg, messageCollector)
|
||||||
if (files != null) {
|
|
||||||
files
|
|
||||||
} else {
|
|
||||||
hasErrors = true
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasErrors) return ExitCode.COMPILATION_ERROR
|
if (messageCollector.hasErrors()) return ExitCode.COMPILATION_ERROR
|
||||||
|
|
||||||
if (files.isEmpty() && !arguments.version) {
|
if (files.isEmpty() && !arguments.version) {
|
||||||
messageCollector.report(CompilerMessageSeverity.ERROR, "no source files")
|
messageCollector.report(CompilerMessageSeverity.ERROR, "no source files")
|
||||||
@@ -163,7 +156,7 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectInputFiles(baseDir: File, fileName: String, messageCollector: MessageCollector): List<InputFile>? {
|
private fun collectInputFiles(baseDir: File, fileName: String, messageCollector: MessageCollector): List<InputFile> {
|
||||||
val file = File(fileName)
|
val file = File(fileName)
|
||||||
return when {
|
return when {
|
||||||
file.isDirectory -> {
|
file.isDirectory -> {
|
||||||
@@ -179,16 +172,16 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
|||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
messageCollector.report(
|
messageCollector.report(
|
||||||
CompilerMessageSeverity.ERROR,
|
CompilerMessageSeverity.WARNING,
|
||||||
"invalid file name '$fileName'; must end either with '.js', '.zip' or '.jar'"
|
"invalid file name '${file.absolutePath}'; must end either with '.js', '.zip' or '.jar'"
|
||||||
)
|
)
|
||||||
null
|
emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
messageCollector.report(CompilerMessageSeverity.ERROR, "source file or directory not found: $fileName")
|
messageCollector.report(CompilerMessageSeverity.ERROR, "source file or directory not found: $fileName")
|
||||||
null
|
emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/invalidFilename.args
|
||||||
|
$TESTDATA_DIR$/simple.js
|
||||||
|
-output-dir
|
||||||
|
$TEMP_DIR$/min
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
warning: invalid file name '$TESTDATA_DIR$/invalidFilename.args'; must end either with '.js', '.zip' or '.jar'
|
||||||
|
OK
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
// EXISTS: min/simple.js
|
||||||
@@ -783,6 +783,12 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJsDceTest(fileName);
|
doJsDceTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("invalidFilename.args")
|
||||||
|
public void testInvalidFilename() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js-dce/invalidFilename.args");
|
||||||
|
doJsDceTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jsExtraHelp.args")
|
@TestMetadata("jsExtraHelp.args")
|
||||||
public void testJsExtraHelp() throws Exception {
|
public void testJsExtraHelp() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js-dce/jsExtraHelp.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js-dce/jsExtraHelp.args");
|
||||||
|
|||||||
+21
@@ -279,6 +279,27 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDceFileCollectionDependency() {
|
||||||
|
val project = Project("kotlin2JsDceProject", "2.10", minLogLevel = LogLevel.INFO)
|
||||||
|
|
||||||
|
project.setupWorkingDir()
|
||||||
|
File(project.projectDir, "mainProject/build.gradle").modify {
|
||||||
|
it.replace("compile project(\":libraryProject\")", "compile project(\":libraryProject\").sourceSets.main.output")
|
||||||
|
}
|
||||||
|
|
||||||
|
project.build("runRhino") {
|
||||||
|
assertSuccessful()
|
||||||
|
val pathPrefix = "mainProject/build/kotlin-js-min/main"
|
||||||
|
assertFileExists("$pathPrefix/exampleapp.js.map")
|
||||||
|
assertFileExists("$pathPrefix/examplelib.js.map")
|
||||||
|
assertFileContains("$pathPrefix/exampleapp.js.map", "\"../../../src/main/kotlin/exampleapp/main.kt\"")
|
||||||
|
|
||||||
|
assertFileExists("$pathPrefix/kotlin.js")
|
||||||
|
assertTrue(fileInWorkingDir("$pathPrefix/kotlin.js").length() < 500 * 1000, "Looks like kotlin.js file was not minified by DCE")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Issue: KT-18495 */
|
/** Issue: KT-18495 */
|
||||||
@Test
|
@Test
|
||||||
fun testNoSeparateClassesDirWarning() {
|
fun testNoSeparateClassesDirWarning() {
|
||||||
|
|||||||
Reference in New Issue
Block a user