Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
GOUVILLE Tom
template-JavaFX
Commits
7cdd7be8
Verified
Commit
7cdd7be8
authored
Dec 16, 2021
by
GOUVILLE Tom
🤞
Browse files
[ADD] Simplifiying build jar system
parent
586deec5
Pipeline
#24784
passed with stage
in 1 minute and 5 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
31 deletions
+33
-31
README.md
README.md
+2
-2
build.gradle
build.gradle
+5
-10
src/main/java/example/Main.java
src/main/java/example/Main.java
+2
-19
src/main/java/example/MainApp.java
src/main/java/example/MainApp.java
+24
-0
No files found.
README.md
View file @
7cdd7be8
...
...
@@ -23,11 +23,11 @@ Pour utiliser utiliser un fichier (image, texte...) depuis Java, placez-le dans
## Compiler fichier .jar
```
bash
./gradlew
buildJ
ar
./gradlew
j
ar
```
Pour lancer le fichier :
```
bash
java
--module-path
PATH/TO/JAVAFX
--add-modules
javafx.controls,javafx.base,javafx.graphics,javafx.web,javafx.swing,javafx.media
-jar
build/libs/<projectname>
-all
.jar
java
-jar
build/libs/<projectname>.jar
```
build.gradle
View file @
7cdd7be8
...
...
@@ -30,25 +30,20 @@ test {
apply
plugin:
'java'
mainClassName
=
'example.Main'
jar
{
manifest
{
attributes
'Main-Class'
:
"$mainClassName"
}
}
javafx
{
version
=
17
;
modules
=
[
'javafx.controls'
,
'javafx.base'
,
'javafx.graphics'
,
'javafx.web'
,
'javafx.swing'
,
'javafx.media'
,
'javafx.fxml'
]
}
task
buildJar
(
type:
Jar
)
{
manifest
.
from
jar
.
manifest
classifier
=
'all'
duplicatesStrategy
=
DuplicatesStrategy
.
EXCLUDE
jar
{
duplicatesStrategy
=
DuplicatesStrategy
.
INCLUDE
manifest
{
attributes
'Main-Class'
:
"$mainClassName"
}
from
{
configurations
.
runtimeClasspath
.
collect
{
it
.
isDirectory
()
?
it
:
zipTree
(
it
)
}
}
with
jar
}
testlogger
{
...
...
src/main/java/example/Main.java
View file @
7cdd7be8
package
example
;
import
javafx.application.Application
;
import
javafx.stage.Stage
;
import
javafx.scene.Scene
;
import
javafx.scene.control.Label
;
import
javafx.geometry.Pos
;
public
class
Main
extends
Application
{
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
Application
.
launch
(
args
);
}
@Override
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
primaryStage
.
setTitle
(
"JavaFX Application"
);
primaryStage
.
setWidth
(
300
);
primaryStage
.
setHeight
(
200
);
Label
helloWorldLabel
=
new
Label
(
"Yes"
);
helloWorldLabel
.
setAlignment
(
Pos
.
CENTER
);
Scene
primaryScene
=
new
Scene
(
helloWorldLabel
);
primaryStage
.
setScene
(
primaryScene
);
primaryStage
.
show
();
MainApp
.
main
(
args
);
}
}
src/main/java/example/MainApp.java
0 → 100644
View file @
7cdd7be8
package
example
;
import
javafx.application.Application
;
import
javafx.stage.Stage
;
import
javafx.scene.Scene
;
import
javafx.scene.control.Label
;
import
javafx.geometry.Pos
;
public
class
MainApp
extends
Application
{
public
static
void
main
(
String
[]
args
)
{
Application
.
launch
(
args
);
}
@Override
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
primaryStage
.
setTitle
(
"JavaFX Application"
);
primaryStage
.
setWidth
(
300
);
primaryStage
.
setHeight
(
200
);
Label
helloWorldLabel
=
new
Label
(
"Yes"
);
helloWorldLabel
.
setAlignment
(
Pos
.
CENTER
);
Scene
primaryScene
=
new
Scene
(
helloWorldLabel
);
primaryStage
.
setScene
(
primaryScene
);
primaryStage
.
show
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment