Verified Commit 7cdd7be8 authored by GOUVILLE Tom's avatar GOUVILLE Tom 🤞
Browse files

[ADD] Simplifiying build jar system

parent 586deec5
Pipeline #24784 passed with stage
in 1 minute and 5 seconds
......@@ -23,11 +23,11 @@ Pour utiliser utiliser un fichier (image, texte...) depuis Java, placez-le dans
## Compiler fichier .jar
```bash
./gradlew buildJar
./gradlew jar
```
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
```
......@@ -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 {
......
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);
}
}
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();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment