1 Star 6 Fork 2

OpenJFX / javafx-gradle-plugin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

JavaFX Gradle Plugin

Simplifies working with JavaFX 11+ for gradle projects.

Gradle Plugin Portal Github Actions BSD-3 license

Getting started

To use the plugin, apply the following two steps:

1. Apply the plugin

Using the plugins DSL:

Groovy

plugins {
    id 'org.openjfx.javafxplugin' version '0.0.14'
}

Kotlin

plugins {
    id("org.openjfx.javafxplugin") version "0.0.14"
}
Alternatively, you can use the buildscript DSL:

Groovy

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'org.openjfx:javafx-plugin:0.0.14'
    }
}
apply plugin: 'org.openjfx.javafxplugin'

Kotlin

buildscript {
    repositories {
        maven {
            setUrl("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath("org.openjfx:javafx-plugin:0.0.14")
    }
}
apply(plugin = "org.openjfx.javafxplugin")

2. Specify JavaFX modules

Specify all the JavaFX modules that your project uses:

Groovy

javafx {
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

Kotlin

javafx {
    modules("javafx.controls", "javafx.fxml")
}

3. Specify JavaFX version

To override the default JavaFX version, a version string can be declared. This will make sure that all the modules belong to this specific version:

Groovy


javafx {
    version = '17'
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

Kotlin


javafx {
    version = "17"
    modules("javafx.controls", "javafx.fxml")
}

4. Cross-platform projects and libraries

The plugin will include JavaFX dependencies for the current platform. However, a different target platform can also be specified.

Supported targets are:

  • linux
  • linux-aarch64
  • win or windows
  • osx or mac or macos
  • osx-aarch64 or mac-aarch64 or macos-aarch64 (support added in JavaFX 11.0.12 LTS and JavaFX 17 GA)

Groovy


javafx {
    modules = [ 'javafx.controls', 'javafx.fxml' ]
    platform = 'mac'
}

Kotlin


javafx {
    modules("javafx.controls", "javafx.fxml")
    platform = 'mac'
}

5. Dependency scope

JavaFX application require native binaries for each platform to run. By default, the plugin will include these binaries for the target platform. Native dependencies can be avoided by declaring the dependency configuration as compileOnly.

Groovy


javafx {
    modules = [ 'javafx.controls', 'javafx.fxml' ] 
    configuration = 'compileOnly'
}

Kotlin


javafx {
    modules("javafx.controls", "javafx.fxml")
    configuration = "compileOnly"
}

Multiple configurations can also be targeted by using configurations. For example, JavaFX dependencies can be added to both implementation and testImplementation.

Groovy


javafx {
    modules = [ 'javafx.controls', 'javafx.fxml' ]
    configurations = [ 'implementation', 'testImplementation' ]
}

Kotlin


javafx {
    modules("javafx.controls", "javafx.fxml")
    configurations("implementation", "testImplementation")
}

5. Using a local JavaFX SDK

By default, JavaFX modules are retrieved from Maven Central. However, a local JavaFX SDK can be used instead, for instance in the case of a custom build of OpenJFX.

Setting a valid path to the local JavaFX SDK will take precedence:

Groovy


javafx {
    sdk = '/path/to/javafx-sdk'
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

Kotlin


javafx {
    sdk = "/path/to/javafx-sdk"
    modules("javafx.controls", "javafx.fxml")
}

Issues and Contributions

Issues can be reported to the Issue tracker.

Contributions can be submitted via Pull requests, providing you have signed the Gluon Individual Contributor License Agreement (CLA).

Copyright (c) 2018, Gluon All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

javafx 的 gradle 插件 展开 收起
Java
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/openjfx/javafx-gradle-plugin.git
git@gitee.com:openjfx/javafx-gradle-plugin.git
openjfx
javafx-gradle-plugin
javafx-gradle-plugin
master

搜索帮助