Skip to content

Commit 0890c97

Browse files
committed
initial commit demonstrating fat/uber/shade jar with javafx
0 parents  commit 0890c97

File tree

7 files changed

+498
-0
lines changed

7 files changed

+498
-0
lines changed

.gitignore

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
2+
# my own addition. i prefer 0 IDE files committed.
3+
.idea/
4+
5+
# Created by https://www.gitignore.io/api/java,linux,macos,maven,gradle,windows,eclipse,netbeans,intellij
6+
# Edit at https://www.gitignore.io/?templates=java,linux,macos,maven,gradle,windows,eclipse,netbeans,intellij
7+
8+
### Eclipse ###
9+
10+
.metadata
11+
bin/
12+
tmp/
13+
*.tmp
14+
*.bak
15+
*.swp
16+
*~.nib
17+
local.properties
18+
.settings/
19+
.loadpath
20+
.recommenders
21+
22+
# External tool builders
23+
.externalToolBuilders/
24+
25+
# Locally stored "Eclipse launch configurations"
26+
*.launch
27+
28+
# PyDev specific (Python IDE for Eclipse)
29+
*.pydevproject
30+
31+
# CDT-specific (C/C++ Development Tooling)
32+
.cproject
33+
34+
# CDT- autotools
35+
.autotools
36+
37+
# Java annotation processor (APT)
38+
.factorypath
39+
40+
# PDT-specific (PHP Development Tools)
41+
.buildpath
42+
43+
# sbteclipse plugin
44+
.target
45+
46+
# Tern plugin
47+
.tern-project
48+
49+
# TeXlipse plugin
50+
.texlipse
51+
52+
# STS (Spring Tool Suite)
53+
.springBeans
54+
55+
# Code Recommenders
56+
.recommenders/
57+
58+
# Annotation Processing
59+
.apt_generated/
60+
61+
# Scala IDE specific (Scala & Java development for Eclipse)
62+
.cache-main
63+
.scala_dependencies
64+
.worksheet
65+
66+
### Eclipse Patch ###
67+
# Eclipse Core
68+
.project
69+
70+
# JDT-specific (Eclipse Java Development Tools)
71+
.classpath
72+
73+
# Annotation Processing
74+
.apt_generated
75+
76+
.sts4-cache/
77+
78+
### Intellij ###
79+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
80+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
81+
82+
# User-specific stuff
83+
.idea/**/workspace.xml
84+
.idea/**/tasks.xml
85+
.idea/**/usage.statistics.xml
86+
.idea/**/dictionaries
87+
.idea/**/shelf
88+
89+
# Generated files
90+
.idea/**/contentModel.xml
91+
92+
# Sensitive or high-churn files
93+
.idea/**/dataSources/
94+
.idea/**/dataSources.ids
95+
.idea/**/dataSources.local.xml
96+
.idea/**/sqlDataSources.xml
97+
.idea/**/dynamic.xml
98+
.idea/**/uiDesigner.xml
99+
.idea/**/dbnavigator.xml
100+
101+
# Gradle
102+
.idea/**/gradle.xml
103+
.idea/**/libraries
104+
105+
# Gradle and Maven with auto-import
106+
# When using Gradle or Maven with auto-import, you should exclude module files,
107+
# since they will be recreated, and may cause churn. Uncomment if using
108+
# auto-import.
109+
.idea/modules.xml
110+
.idea/*.iml
111+
.idea/modules
112+
113+
# CMake
114+
cmake-build-*/
115+
116+
# Mongo Explorer plugin
117+
.idea/**/mongoSettings.xml
118+
119+
# File-based project format
120+
*.iws
121+
122+
# IntelliJ
123+
out/
124+
125+
# mpeltonen/sbt-idea plugin
126+
.idea_modules/
127+
128+
# JIRA plugin
129+
atlassian-ide-plugin.xml
130+
131+
# Cursive Clojure plugin
132+
.idea/replstate.xml
133+
134+
# Crashlytics plugin (for Android Studio and IntelliJ)
135+
com_crashlytics_export_strings.xml
136+
crashlytics.properties
137+
crashlytics-build.properties
138+
fabric.properties
139+
140+
# Editor-based Rest Client
141+
.idea/httpRequests
142+
143+
# Android studio 3.1+ serialized cache file
144+
.idea/caches/build_file_checksums.ser
145+
146+
### Intellij Patch ###
147+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
148+
149+
*.iml
150+
modules.xml
151+
.idea/misc.xml
152+
*.ipr
153+
154+
# Sonarlint plugin
155+
.idea/sonarlint
156+
157+
### Java ###
158+
# Compiled class file
159+
*.class
160+
161+
# Log file
162+
*.log
163+
164+
# BlueJ files
165+
*.ctxt
166+
167+
# Mobile Tools for Java (J2ME)
168+
.mtj.tmp/
169+
170+
# Package Files #
171+
*.jar
172+
*.war
173+
*.nar
174+
*.ear
175+
*.zip
176+
*.tar.gz
177+
*.rar
178+
179+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
180+
hs_err_pid*
181+
182+
### Linux ###
183+
*~
184+
185+
# temporary files which can be created if a process still has a handle open of a deleted file
186+
.fuse_hidden*
187+
188+
# KDE directory preferences
189+
.directory
190+
191+
# Linux trash folder which might appear on any partition or disk
192+
.Trash-*
193+
194+
# .nfs files are created when an open file is removed but is still being accessed
195+
.nfs*
196+
197+
### macOS ###
198+
# General
199+
.DS_Store
200+
.AppleDouble
201+
.LSOverride
202+
203+
# Icon must end with two \r
204+
Icon
205+
206+
# Thumbnails
207+
._*
208+
209+
# Files that might appear in the root of a volume
210+
.DocumentRevisions-V100
211+
.fseventsd
212+
.Spotlight-V100
213+
.TemporaryItems
214+
.Trashes
215+
.VolumeIcon.icns
216+
.com.apple.timemachine.donotpresent
217+
218+
# Directories potentially created on remote AFP share
219+
.AppleDB
220+
.AppleDesktop
221+
Network Trash Folder
222+
Temporary Items
223+
.apdisk
224+
225+
### Maven ###
226+
target/
227+
pom.xml.tag
228+
pom.xml.releaseBackup
229+
pom.xml.versionsBackup
230+
pom.xml.next
231+
release.properties
232+
dependency-reduced-pom.xml
233+
buildNumber.properties
234+
.mvn/timing.properties
235+
.mvn/wrapper/maven-wrapper.jar
236+
237+
### NetBeans ###
238+
**/nbproject/private/
239+
**/nbproject/Makefile-*.mk
240+
**/nbproject/Package-*.bash
241+
build/
242+
nbbuild/
243+
dist/
244+
nbdist/
245+
.nb-gradle/
246+
247+
### Windows ###
248+
# Windows thumbnail cache files
249+
Thumbs.db
250+
ehthumbs.db
251+
ehthumbs_vista.db
252+
253+
# Dump file
254+
*.stackdump
255+
256+
# Folder config file
257+
[Dd]esktop.ini
258+
259+
# Recycle Bin used on file shares
260+
$RECYCLE.BIN/
261+
262+
# Windows Installer files
263+
*.cab
264+
*.msi
265+
*.msix
266+
*.msm
267+
*.msp
268+
269+
# Windows shortcuts
270+
*.lnk
271+
272+
### Gradle ###
273+
.gradle
274+
/build/
275+
276+
# Ignore Gradle GUI config
277+
gradle-app.setting
278+
279+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
280+
!gradle-wrapper.jar
281+
282+
# Cache of project
283+
.gradletasknamecache
284+
285+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
286+
# gradle/wrapper/gradle-wrapper.properties
287+
288+
### Gradle Patch ###
289+
**/build/
290+
291+
# End of https://www.gitignore.io/api/java,linux,macos,maven,gradle,windows,eclipse,netbeans,intellij

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# dice-notation-javafx
2+
3+
this is to demonstrate how to create a java jar that has all dependencies and can be executed on multiple platforms.
4+
5+
Leverages:
6+
- Java 11 (non-module config)
7+
- Maven
8+
- javafx (with multiple OS specific dependencies)
9+
- maven-shade-plugin
10+
11+
When importing into your IDE "Open" or "Import" the `pom.xml` file to create a new project.
12+
13+
Most of the interesting work is in the `pom.xml` file. Also, there is a funny situation that requires the use of a seperate class with a `main` method. See the comments in `FatJarLauncher.java`
14+
15+
execute maven (`mvn`) with the `package` goal then locate your jar in the `target/` dir.
16+
17+
mvn package
18+
19+
This little app is just a simple ui for [Bernardo-MG/dice-notation-java](https://github.com/Bernardo-MG/dice-notation-java). That lib has a handful of transitive dependencies so this demonstrates how `maven-shade-plugin` creates a jar with ALL the necessary dependencies.
20+
21+
A compiled version of this is over in the [Releases](https://github.com/danlangford/dice-notation-javafx/releases).
22+
23+
The only dependency that is not included in Java 11 itself. It is possible to include that but then you would not be using the shade plugin, you would be using all proper java modules and `jlink`. I'll demonstrate that another time.

pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.github.danlangford</groupId>
4+
<artifactId>dice-notation-javafx</artifactId>
5+
<version>0.0.1</version>
6+
<properties>
7+
<maven.compiler.source>11</maven.compiler.source>
8+
<maven.compiler.target>11</maven.compiler.target>
9+
<javafx.version>11.0.1</javafx.version>
10+
</properties>
11+
<dependencies>
12+
13+
<!-- app specific dependencies -->
14+
<dependency>
15+
<groupId>com.bernardomg.tabletop</groupId>
16+
<artifactId>dice</artifactId>
17+
<version>1.3.0</version>
18+
</dependency>
19+
20+
<!-- javafx dependencies -->
21+
<dependency>
22+
<groupId>org.openjfx</groupId>
23+
<artifactId>javafx-controls</artifactId>
24+
<version>${javafx.version}</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.openjfx</groupId>
28+
<artifactId>javafx-fxml</artifactId>
29+
<version>${javafx.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.openjfx</groupId>
33+
<artifactId>javafx-graphics</artifactId>
34+
<version>${javafx.version}</version>
35+
</dependency>
36+
37+
<!-- adding all the platform libs only adds a couple more MB -->
38+
<dependency>
39+
<groupId>org.openjfx</groupId>
40+
<artifactId>javafx-graphics</artifactId>
41+
<version>${javafx.version}</version>
42+
<classifier>win</classifier>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.openjfx</groupId>
46+
<artifactId>javafx-graphics</artifactId>
47+
<version>${javafx.version}</version>
48+
<classifier>mac</classifier>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.openjfx</groupId>
52+
<artifactId>javafx-graphics</artifactId>
53+
<version>${javafx.version}</version>
54+
<classifier>linux</classifier>
55+
</dependency>
56+
57+
</dependencies>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<artifactId>maven-shade-plugin</artifactId>
62+
<executions>
63+
<execution>
64+
<phase>package</phase>
65+
<goals>
66+
<goal>shade</goal>
67+
</goals>
68+
<configuration>
69+
<transformers>
70+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
71+
<mainClass>com.github.danlangford.dicefx.FatJarLauncher</mainClass>
72+
</transformer>
73+
</transformers>
74+
</configuration>
75+
</execution>
76+
</executions>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
</project>

0 commit comments

Comments
 (0)