Filter some characters out of module names passed to Kotlin from Gradle

This addresses the cases when a module name contains a slash
 (e.g. when the Gradle project name was set this way to point
Gradle to the directory), which led to Kotlin module file being placed
under a subdirectory of META-INF and thus undiscoverable for the
compiler and reflect.

Additionally, this fix removes characters \n, \r, \t whose
presence in a module name caused compilation failures.

Issue #KT-20608 Fixed
This commit is contained in:
Sergey Igushkin
2017-10-25 16:22:07 +03:00
parent a8ad980910
commit 093842932f
2 changed files with 20 additions and 1 deletions
@@ -771,4 +771,18 @@ class KotlinGradleIT : BaseGradleIT() {
}
}
}
@Test
fun testModuleNameFiltering() = with(Project("typeAlias")) { // Use a Project with a top-level typealias
setupWorkingDir()
gradleBuildScript().appendText("\n" + """archivesBaseName = 'a/really\\tricky\n\rmodule\tname'""")
build("classes") {
assertSuccessful()
val metaInfDir = File(projectDir, kotlinClassesDir() + "META-INF")
assertNotNull(metaInfDir.listFiles().singleOrNull { it.name.endsWith(".kotlin_module") })
}
}
}