# javafx-maven-plugin **Repository Path**: openjfxcn/javafx-maven-plugin ## Basic Information - **Project Name**: javafx-maven-plugin - **Description**: javafx maven 插件 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2019-12-11 - **Last Updated**: 2022-09-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 用于 JavaFX 的 Maven 插件 运行 JavaFX 11+ 应用的 Maven 插件 [![Maven Central](https://img.shields.io/maven-central/v/org.openjfx/javafx-maven-plugin.svg?color=%234DC71F)](https://search.maven.org/#search|ga|1|org.openjfx.javafx-maven-plugin) [![Travis CI](https://api.travis-ci.com/openjfx/javafx-maven-plugin.svg?branch=master)](https://travis-ci.com/openjfx/javafx-maven-plugin) [![Apache License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) ## 安装 该插件在Maven仓库可以找到。 如果要build和install最新的快照, 你可以clone本项目, 并设置成JDK 11运行 ``` mvn install ``` ## 用法 创建一个 Maven 项目,使用现有的项目,例如:[HelloFX](https://gitee.com/openjfx/samples/tree/master/CommandLine/Modular/Maven/hellofx),或者使用 [archetype](https://gitee.com/openjfx/javafx-maven-archetypes) 。 该项目可以是模块化的也可以是非模块化的。 添加 JavaFX 依赖项: ``` org.openjfx javafx-controls 12.0.2 ``` 添加插件: ``` org.openjfx javafx-maven-plugin 0.0.3 hellofx/org.openjfx.App ``` 编译项目 (可选): ``` mvn javafx:compile ``` 或者使用 `maven-compiler-plugin`: ``` mvn compile ``` Note that including this plugin is convenient for a better project integration within your IDE. 运行项目: ``` mvn javafx:run ``` For modular projects, to create and run a custom image: ``` mvn javafx:jlink target/image/bin/java -m hellofx/org.openjfx.App ``` ### javafx:compile options When compiling with ``javafx:compile``, the source level, target level and/or the release level for the Java compiler can be set. The default value is 11. This configuration changes these levels to 12, for instance: ``` org.openjfx javafx-maven-plugin 0.0.3 12 12 12 org.openjfx.hellofx/org.openjfx.App ``` If required, compiler arguments can be set. For instance: ``` org.openjfx javafx-maven-plugin 0.0.3 --add-exports javafx.graphics/com.sun.glass.ui=org.openjfx.hellofx org.openjfx.hellofx/org.openjfx.App ``` ### javafx:run options The plugin includes by default: `--module-path`, `--add-modules` and `-classpath` options. Optionally, the configuration can be modified with: - `mainClass`: The main class, fully qualified name, with or without module name - `workingDirectory`: The current working directory - `skip`: Skip the execution. Values: false (default), true - `outputFile` File to redirect the process output - `options`: A list of VM options passed to the executable. - `commandlineArgs`: Arguments separated by space for the executed program - `includePathExceptionsInClasspath`: When resolving the module-path, setting this value to true will include the dependencies that generate path exceptions in the classpath. By default the value is false, and these dependencies won't be included. For instance, the following configuration adds some VM options and a command line argument: ``` org.openjfx javafx-maven-plugin 0.0.3 org.openjfx.hellofx/org.openjfx.App -Xmx1024m ``` **注意** 可以使用本地SDK代替 Maven Central。 This is helpful for developers trying to test a local build of OpenJFX. Since transitive dependencies are not resolved, all the required jars needs to be added as a separate dependency, like: ``` /path/to/javafx-sdk org.openjfx javafx.base 1.0 system ${sdk}/lib/javafx.base.jar ... ``` ### javafx:jlink 选项 The same command line options for `jlink` can be set: - `stripDebug`: Strips debug information out. Values: false (default) or true - `compress`: Compression level of the resources being used. Values: 0 (default), 1, 2. - `noHeaderFiles`: Removes the `includes` directory in the resulting runtime image. Values: false (default) or true - `noManPages`: Removes the `man` directory in the resulting runtime image. Values: false (default) or true - `bindServices`: Adds the option to bind services. Values: false (default) or true - `ignoreSigningInformation`: Adds the option to ignore signing information. Values: false (default) or true - `jlinkVerbose`: Adds the verbose option. Values: false (default) or true - `launcher`: Adds a launcher script with the given name. - If `options` are defined, these will be passed to the launcher script as vm options. - If `commandLineArgs` are defined, these will be passed to the launcher script as command line arguments. - `jlinkImageName`: The name of the folder with the resulting runtime image - `jlinkZipName`: When set, creates a zip of the resulting runtime image - `jlinkExecutable`: The `jlink` executable. It can be a full path or the name of the executable, if it is in the PATH. - `jmodsPath`: When using a local JavaFX SDK, sets the path to the local JavaFX jmods For instance, with the following configuration: ``` org.openjfx javafx-maven-plugin 0.0.3 true 2 true true hellofx hello hellozip hellofx/org.openjfx.MainApp ``` a custom image can be created and run as: ``` mvn clean javafx:jlink target/hello/bin/hellofx ``` ## 反馈问题 ## 可以将问题提交到 [Issues 跟踪器](https://gitee.com/openjfx/javafx-maven-plugin/issues/). Contributions can be submitted via [Pull 请求](https://gitee.com/openjfx/javafx-maven-plugin/pulls/), providing you have signed the [Gluon Individual Contributor License Agreement (CLA)](https://docs.google.com/forms/d/16aoFTmzs8lZTfiyrEm8YgMqMYaGQl0J8wA0VJE2LCCY).