Load automatic module names correctly

Load the Automatic-Module-Name manifest entry value if it's present (see
http://mail.openjdk.java.net/pipermail/jpms-spec-observers/2017-May/000877.html),
otherwise sanitize the name of the .jar file, throwing out all chars
except alphanumeric, duplicate dots and a version qualifier
This commit is contained in:
Alexander Udalov
2017-06-30 17:37:38 +03:00
parent 612e64d8e3
commit c428505d4d
9 changed files with 84 additions and 18 deletions
@@ -44,11 +44,15 @@ class JavaModuleInfo(
fun create(psiJavaModule: PsiJavaModule): JavaModuleInfo {
return JavaModuleInfo(
psiJavaModule.name,
psiJavaModule.requires.map { statement ->
JavaModuleInfo.Requires(statement.moduleName!!, statement.hasModifierProperty(PsiModifier.TRANSITIVE))
psiJavaModule.requires.mapNotNull { statement ->
statement.moduleName?.let { moduleName ->
JavaModuleInfo.Requires(moduleName, statement.hasModifierProperty(PsiModifier.TRANSITIVE))
}
},
psiJavaModule.exports.map { statement ->
JavaModuleInfo.Exports(FqName(statement.packageName!!), statement.moduleNames)
psiJavaModule.exports.mapNotNull { statement ->
statement.packageName?.let { packageName ->
JavaModuleInfo.Exports(FqName(packageName), statement.moduleNames)
}
}
)
}