Gradle Migration to Java 11

孤人 提交于 2019-12-12 17:31:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!