在gradle应用程序中找不到ant-javafx

在使用JavaFX编写我的第一个应用程序时,我确保JAVA_HOME安装正确,并将javafx-gradle-plugin到我的应用程序中,但是在我的JDK中有一个缺少实际可用的ant-javafx-library的错误:

我的build.gradle和我得到的错误信息如下:

 // set up the kotlin-gradle plugin buildscript { ext.kotlin_version = '1.1.60' repositories { mavenLocal() // mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2" } } // apply the kotlin-gradle plugin apply plugin: "kotlin" apply plugin: 'javafx-gradle-plugin' // add kotlin-stdlib dependencies. repositories { mavenLocal() // mavenCentral() } dependencies { //dependencies from a remote repositor compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "no.tornado:tornadofx:1.7.12" compile "de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2" } jar { manifest { //Define mainClassName as: '[your_namespace].[your_arctifact]Kt' attributes ('Main-Class': 'MyAppKt', "Implementation-Title": "Gradle", "Implementation-Version": 1) } // NEW LINE HERE !!! from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } } sourceSets { main.kotlin.srcDirs += 'src/kotlin' main.resources.srcDirs += 'src/resources' } kotlin { experimental.coroutines 'enable' } compileKotlin { kotlinOptions.jvmTarget= 1.8 // optional, Minimum jvmTarget of 1.8 needed since Kotlin 1.1 kotlinOptions.suppressWarnings = true } 

在这里输入图像说明

我能够解决它,从这里下载javafx.plugin

然后创建一个“插件”文件夹,并在其中复制该文件。

最后,我将这个插件安装到我的gradle.build如下所示:

 apply from: "plugins/javafx.plugin" 

所以,我的最后一个gradle.build是:

 // set up the kotlin-gradle plugin buildscript { ext.kotlin_version = '1.1.60' repositories { mavenLocal() // mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // classpath files('plugins/javafx.plugin') } } // apply the kotlin-gradle plugin apply plugin: "kotlin" apply from: "plugins/javafx.plugin" // apply from: "http://dl.bintray.com/content/shemnon/javafx-gradle/8.1.1/javafx.plugin" // add kotlin-stdlib dependencies. repositories { mavenLocal() // mavenCentral() } dependencies { //dependencies from a remote repositor compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "no.tornado:tornadofx:1.7.12" } jar { manifest { //Define mainClassName as: '[your_namespace].[your_arctifact]Kt' attributes ('Main-Class': 'MainKt', "Implementation-Title": "Gradle", "Implementation-Version": 1) } // NEW LINE HERE !!! from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } } sourceSets { main.kotlin.srcDirs += 'src/kotlin' main.resources.srcDirs += 'src/resources' } kotlin { experimental.coroutines 'enable' } compileKotlin { kotlinOptions.jvmTarget= 1.8 // optional, Minimum jvmTarget of 1.8 needed since Kotlin 1.1 kotlinOptions.suppressWarnings = true } 

和我的应用程序结构是:

在这里输入图像说明

更新 选项2

在这里安装新的插件:

 buildscript { repositories { mavenCentral() // or mavenLocal() } dependencies { compile "de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2" } } 

如果有兴趣使用mavenLocal()那么可以使用下面的命令来下载:

 mvn dependency:get -DrepoUrl=https://mvnrepository.com/artifact/de.dynamicfiles.projects.gradle.plugins/javafx-gradle-plugin/8.8.2 -Dartifact=de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2 

为了得到mvn命令行,你可以从这里下载它,把它添加到你的path然后从任何地方调用它。