mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-13 11:09:10 +01:00
Merge pull request #6838 from alvasw/jlink_task_make_java_modules_optional
JLinkTask: Make Java Modules Optional
This commit is contained in:
commit
5738d07b45
1 changed files with 14 additions and 3 deletions
|
@ -5,6 +5,7 @@ import org.gradle.api.file.DirectoryProperty
|
|||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.Optional
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -14,8 +15,9 @@ abstract class JLinkTask : DefaultTask() {
|
|||
@get:InputDirectory
|
||||
abstract val jdkDirectory: DirectoryProperty
|
||||
|
||||
@get:Optional
|
||||
@get:InputDirectory
|
||||
abstract val javaFxJmodsDirectory: DirectoryProperty
|
||||
abstract val javaModulesDirectory: DirectoryProperty
|
||||
|
||||
@get:InputFile
|
||||
abstract val jDepsOutputFile: RegularFileProperty
|
||||
|
@ -33,7 +35,6 @@ abstract class JLinkTask : DefaultTask() {
|
|||
val processBuilder = ProcessBuilder(
|
||||
jLinkPath.toAbsolutePath().toString(),
|
||||
|
||||
"--module-path", javaFxJmodsDirectory.asFile.get().absolutePath,
|
||||
"--add-modules", parseUsedJavaModulesFromJDepsOutput(),
|
||||
|
||||
"--strip-native-commands",
|
||||
|
@ -43,6 +44,13 @@ abstract class JLinkTask : DefaultTask() {
|
|||
|
||||
"--output", outputDirectoryFile.absolutePath
|
||||
)
|
||||
|
||||
if (javaModulesDirectory.isPresent) {
|
||||
val commands = processBuilder.command()
|
||||
commands.add("--module-path")
|
||||
commands.add(javaModulesDirectory.asFile.get().absolutePath)
|
||||
}
|
||||
|
||||
processBuilder.inheritIO()
|
||||
|
||||
val process = processBuilder.start()
|
||||
|
@ -55,7 +63,10 @@ abstract class JLinkTask : DefaultTask() {
|
|||
}
|
||||
|
||||
private fun parseUsedJavaModulesFromJDepsOutput(): String {
|
||||
val readLines = jDepsOutputFile.asFile.get().readLines()
|
||||
var readLines = jDepsOutputFile.asFile.get().readLines()
|
||||
if (!javaModulesDirectory.isPresent) {
|
||||
readLines = readLines.filter { it.startsWith("java.") }
|
||||
}
|
||||
return readLines.joinToString(",")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue