问题
In the Gradle build file below the fileTree dependency is loading some local jars, but compilation fails with errors like 'package groovy.text is declared in the unnamed module, but module groovy.text does not read it'. I am not sure where the problem reside, could it be that I have to add also something to the compileJava task ? The current configuration is used for a JavaFx application, as discussed in this thread
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
}
}
apply plugin: 'application'
apply plugin: 'com.google.osdetector'
ext.platform = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
repositories {
mavenCentral()
flatDir {
dirs 'src/main/lib'
}
}
dependencies {
compile fileTree(dir: 'src/main/lib', include: ['*.jar'])
compile "org.openjfx:javafx-base:11:$platform"
compile "org.openjfx:javafx-graphics:11:$platform"
compile "org.openjfx:javafx-controls:11:$platform"
compile "org.openjfx:javafx-web:11:$platform"
}
compileJava {
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.controls',
'--add-modules', 'javafx.graphics',
'--add-modules', 'javafx.web'
]
}
}
run {
doFirst {
jvmArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.controls'
]
}
}
mainClassName = 'HelloFX'
来源:https://stackoverflow.com/questions/53164973/gradle-migration-to-java-11