feat: add ability to build a cross-platform jar
This commit is contained in:
parent
f0006ad764
commit
f94b78948e
4 changed files with 48 additions and 8 deletions
20
README.md
20
README.md
|
@ -28,7 +28,7 @@ Follow [this link](https://gluonhq.com/products/scene-builder/) to download and
|
|||
|
||||
#### Build and Run
|
||||
|
||||
Run this command
|
||||
Run this command
|
||||
|
||||
```shell script
|
||||
./gradlew run
|
||||
|
@ -36,6 +36,24 @@ Run this command
|
|||
|
||||
Or in Intellij, open the gradle window and click on `clavardator -> Tasks -> application -> run`.
|
||||
|
||||
#### Generate cross-platform jar
|
||||
|
||||
Run this command
|
||||
|
||||
```shell script
|
||||
./gradlew build
|
||||
```
|
||||
|
||||
This will generate a jar file under `build/libs`.
|
||||
|
||||
You can then copy this file and place it on any Linux/Windows/Mac environment with at least Java 11 installed.
|
||||
|
||||
You can then run this jar file with this command:
|
||||
|
||||
```shell script
|
||||
java -jar <JAR-NAME>.jar
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
* [OpenJDK](https://adoptopenjdk.net/releases.html)
|
||||
|
|
27
build.gradle
27
build.gradle
|
@ -4,25 +4,38 @@ plugins {
|
|||
}
|
||||
|
||||
group 'fr.insa.clavardator'
|
||||
version '1.0-SNAPSHOT'
|
||||
version '0.0.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.xerial:sqlite-jdbc:3.32.3'
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
}
|
||||
|
||||
javafx {
|
||||
version = "11.0.2"
|
||||
modules = [ 'javafx.controls', 'javafx.fxml' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:win"
|
||||
runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:linux"
|
||||
runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:mac"
|
||||
implementation 'org.xerial:sqlite-jdbc:3.32.3'
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
}
|
||||
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Main-Class': 'fr.insa.clavardator.Launcher'
|
||||
}
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
}
|
||||
|
||||
mainClassName = 'fr.insa.clavardator.MainApp'
|
7
src/main/java/fr/insa/clavardator/Launcher.java
Normal file
7
src/main/java/fr/insa/clavardator/Launcher.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package fr.insa.clavardator;
|
||||
|
||||
public class Launcher {
|
||||
public static void main(String[] args) {
|
||||
MainApp.main(args);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
package fr.insa.clavardator;
|
||||
|
||||
import fr.insa.clavardator.TestClass;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
Loading…
Reference in a new issue