JavaFX Maven Plugin on Netbeans
はじめに Introduction
Netbeansで作成したMaven形式のJavaFXプロジェクトを速くビルドできるプラグインを見つけました.
I found a plugin to build Maven JavaFX project faster on Netbeans.
問題 What's the problem ?
Netbeansで作成したMaven形式のJavaFXプロジェクトを実行しようとすると, pom.xmlが初期のままだと, 毎回とても長い時間がかかってしまいます. maven-dependency-pluginプラグインのunpack-dependenciesのUnpackingの処理に長い時間がかかっている様です. 依存するライブラリが増えるとより多くの時間がかかってしまいます. 実行する度にビルドに長い時間がかかるのはデバッグが面倒くさく, これは問題です.
It takes much time to execute Maven JavaFX project with initial pom.xml on Netbeans. It seams that unpacking of unpack-dependencies of maven-dependency-plugin takes much time. The more dependencies increase, the more time It takes. It is a serious problem that you should wait building every time you execute because debug is bothersome.
解決策 The Solution
1. NetbeansでMaven形式のJavaプロジェクトを作成 Create Maven Java Application on Netbeans
"ファイル"-->"新規プロジェクト"-->"Maven"-->"Javaアプリケーション"-->"次へ"...と作成します.
"File"-->"New Project"-->"Maven"-->"JavaApplication"-->"Next", and create a project.
2. pom.xmlを修正 Change pom.xml
pom.xmlを修正します. <build></build>タグに挟まれた部分を下記のように変更します.
Change <build></build> tag of pom.xml into as follows.
<build> <plugins> <plugin> <groupId>com.zenjava</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>8.1.2</version> <configuration> <mainClass>メインクラス Your main class</mainClass> </configuration> </plugin> </plugins> </build>
<mainClass><mainClass>タグにはパッケージ名を含めたメインクラス名を入力します.
At <mainClass><mainClass> tag, input the name of your main class with its package.
実行してみる Execute
package packageofmain; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.web.WebView; public class YourMainClass extends Application { @Override public void start(Stage primaryStage) { try { WebView webView = new WebView(); webView.getEngine().load("https://www.google.co.jp/"); primaryStage.setScene(new Scene(webView)); primaryStage.show(); } catch(Exception e) { } } public static void main(String... args) { launch(args); } }
参考 Bibliography
こちらを参考にしました. 詳しくは次のページを見て下さい.
To get detail information, see the following.
JavaFX Maven Plugin のご紹介 - notepad
Bug 247290 – Update Maven JavaFX Application template
NetBeans JavaFXアプリケーションのビルドをmavenで行う - ソフトウェアエンジニアリング - Torutk