Fixed kotlin module errors (the name must be the same throughout the project, otherwise it won't load correctly)
This commit is contained in:
parent
917c32720b
commit
6e6ec96663
@ -716,7 +716,8 @@ open class StaticMethodsAndTools(private val project: Project) {
|
||||
println("\tAllowing kotlin internal access for $moduleName")
|
||||
|
||||
project.tasks.withType(KotlinCompile::class.java).forEach {
|
||||
it.kotlinOptions.moduleName = moduleName // must be the same module name for everything!
|
||||
// must be the same module name as the regular one (which is the project name). If it is a different name, it crashes at runtime
|
||||
it.kotlinOptions.moduleName = moduleName
|
||||
}
|
||||
|
||||
accessGroup.forEach {
|
||||
|
@ -49,7 +49,7 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
val nameX = "_$ver"
|
||||
|
||||
// If the kotlin plugin is applied, and there is a compileKotlin task.. Then kotlin is enabled
|
||||
val hasKotlin = StaticMethodsAndTools.hasKotlin(project)
|
||||
val hasKotlin: Boolean
|
||||
|
||||
val moduleFile = project.projectDir.walkTopDown().find { it.name == "module-info.java" }
|
||||
var moduleName: String
|
||||
@ -95,6 +95,8 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
throw GradleException("The module name must be specified in the module-info file! Verify file: $moduleFile")
|
||||
}
|
||||
|
||||
hasKotlin = StaticMethodsAndTools.hasKotlin(project)
|
||||
|
||||
val info = when {
|
||||
hasKotlin -> "Initializing JPMS $ver, Java/Kotlin [$moduleName]"
|
||||
else -> "Initializing JPMS $ver, Java [$moduleName]"
|
||||
@ -208,7 +210,8 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
sourceCompatibility = ver
|
||||
targetCompatibility = ver
|
||||
kotlinOptions.jvmTarget = ver
|
||||
kotlinOptions.moduleName = compileMainKotlin.kotlinOptions.moduleName // must be the same module name
|
||||
// must be the same module name as the regular one (which is the project name). If it is a different name, it crashes at runtime
|
||||
kotlinOptions.moduleName = project.name
|
||||
}
|
||||
|
||||
compileTestXKotlin.apply {
|
||||
@ -216,7 +219,8 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
sourceCompatibility = ver
|
||||
targetCompatibility = ver
|
||||
kotlinOptions.jvmTarget = ver
|
||||
kotlinOptions.moduleName = compileTestKotlin.kotlinOptions.moduleName // must be the same module name
|
||||
// must be the same module name as the regular one (which is the project name). If it is a different name, it crashes at runtime
|
||||
kotlinOptions.moduleName = project.name
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,22 +238,9 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
mainX.allSource.srcDirs
|
||||
)
|
||||
|
||||
val allCompiled = if (hasKotlin) {
|
||||
proj.files(
|
||||
compileMainJava.destinationDir,
|
||||
compileMainKotlin.destinationDir
|
||||
)
|
||||
} else {
|
||||
proj.files(
|
||||
compileMainJava.destinationDir
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
source = allSource.asFileTree // the files live in this location
|
||||
include("**/module-info.java")
|
||||
|
||||
|
||||
sourceCompatibility = ver
|
||||
targetCompatibility = ver
|
||||
|
||||
@ -261,6 +252,12 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
|
||||
// modules require this!
|
||||
doFirst {
|
||||
val allCompiled = if (hasKotlin) {
|
||||
proj.files(compileMainJava.destinationDir, compileMainKotlin.destinationDir)
|
||||
} else {
|
||||
proj.files(compileMainJava.destinationDir)
|
||||
}
|
||||
|
||||
// the SOURCE of the module-info.java file. It uses **EVERYTHING**
|
||||
options.sourcepath = allSource
|
||||
options.compilerArgs.addAll(listOf(
|
||||
@ -315,6 +312,10 @@ class JavaXConfiguration(javaVersion: JavaVersion, private val project: Project)
|
||||
val length = details.path.length + 1
|
||||
|
||||
val sourceDir = absolutePath.substring(0, absolutePath.length - length)
|
||||
|
||||
// println("checking file: $absolutePath")
|
||||
// println("checking file: $sourceDir")
|
||||
|
||||
if (sourcePaths.contains(sourceDir)) {
|
||||
// println("Moving: " + absolutePath)
|
||||
// println(" : " + details.path)
|
||||
|
Loading…
Reference in New Issue
Block a user