-
Notifications
You must be signed in to change notification settings - Fork 25
/
gradle.html
116 lines (104 loc) · 3.31 KB
/
gradle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<h2>Run HelloWorld using Gradle</h2>
<p>
Similar to Maven, we can declare the required JavaFX modules in the <kbd>build.gradle</kbd> file.
However, for Gradle we need to apply the JavaFX gradle plugin:
</p>
<pre><code>
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '<span class="JFX_PLUGIN_VERSION">0.0.5</span>'
}
</code></pre>
<p>
Next, we add the required modules. For instance, if we only need the <kbd>javafx.controls</kbd>
module, we will include:
</p>
<pre><code>
javafx {
version = "<span class="JFX_VERSION">12</span>"
modules = [ 'javafx.controls' ]
}
</code></pre>
<p>
<b>Important</b>: Note that transitive dependencies are automatically resolved
(for instance, there is no need to add a dependency for the <kbd>javafx.graphics</kbd> module, since it is
<a href="https://openjfx.io/javadoc/23/javafx.controls/module-summary.html" target="_blank">transitively</a> resolved by the
<kbd>javafx.controls</kbd> module). But if your application is using <kbd>FXML</kbd>, you will need to
add the <kbd>javafx.fxml</kbd> module as well.
</p>
<p>
You can specify a distinct version of JavaFX. For example, if you want to stick to JavaFX 17.0.8:
</p>
<pre><code>
javafx {
version = "17.0.8"
modules = [ 'javafx.controls' ]
}
</code></pre>
<p>
Here is a <a class="samples" href="https://github.com/openjfx/samples/blob/master/HelloFX/Gradle/hellofx/build.gradle" target="_blank">build.gradle</a>
file which shows how to achieve this, taken from
this <a class="samples" href="https://github.com/openjfx/samples/blob/master/HelloFX/Gradle" target="_blank">sample</a>.
</p>
<p>
Run the application (e.g. use <a class="samples" href="https://github.com/openjfx/samples/blob/master/HelloFX/Gradle/hellofx/src/main/java/HelloFX.java" target="_blank">HelloFX.java</a>
from the given sample) using:
</p>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#nix-grad" data-toggle="tab">Linux/Mac</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#win-grad" data-toggle="tab">Windows</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="nix-grad">
<pre class="no-border-radius"><code>
./gradlew run
</code></pre>
</div>
<div class="tab-pane" id="win-grad">
<pre><code>
gradlew run
</code></pre>
</div>
</div>
<div class="alert alert-warning">
<strong>Note: </strong>
Our recommendation for the minimum Gradle version against each JDK is as follows:
<table class="jdk-gradle-version">
<tr>
<th>JDK version</th>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
<td>17</td>
<td>18</td>
<td>19</td>
<td>20</td>
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr>
<th>Gradle Version</th>
<td>5.0</td>
<td>5.4</td>
<td>6.0</td>
<td>6.3</td>
<td>6.7</td>
<td>7.0</td>
<td>7.3</td>
<td>7.5</td>
<td>7.6</td>
<td>8.3</td>
<td>8.5</td>
<td>8.8</td>
<td>8.10</td>
</tr>
</table>
</div>