Skip to content

Commit

Permalink
Build distributable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithanim committed Feb 20, 2022
1 parent 3164527 commit 06316b6
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 204 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build-jpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# https://github.com/sualeh/build-jpackage/blob/master/.github/workflows/build-jpackage.yml

name: Build Installers

on:
workflow_dispatch:

jobs:
build-linux-installer:
name: Build Installer on Linux
runs-on: ubuntu-latest
steps:

- id: checkout-code
name: Checkout code
uses: actions/checkout@v2
- id: setup-jdk
name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: 17

- id: build
name: Build distribution
run: |
mvn package -Ppackage
jpackage --verbose "@jpackage.cfg" "@jpackage-linux.cfg"
- id: upload-installer
name: Upload installer
uses: actions/upload-artifact@v2
with:
name: debian_x86_64
path: distributions/*
retention-days: 3


build-windows-installer:
name: Build Installer on Windows
runs-on: windows-latest
steps:

- id: checkout-code
name: Checkout code
uses: actions/checkout@v2
- id: setup-jdk
name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: 17

- id: build
name: Build distribution
run: |
mvn package -Ppackage
jpackage --verbose "@jpackage.cfg" "@jpackage-windows.cfg"
- id: upload-installer
name: Upload installer
uses: actions/upload-artifact@v2
with:
name: windows_x86_64
path: distributions/*
retention-days: 3

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
!/.mvn
!/formats
!/gui
!/package
!/.github
!/.gitignore
!/pom.xml
!/mvnw
Expand All @@ -12,3 +12,5 @@
!/README.md
!/start
!/start.cmd
!/jpackage*
/jpackage.cfg
2 changes: 1 addition & 1 deletion formats/format-bmd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.22</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion formats/format-cif/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.22</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion formats/format-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.22</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion formats/format-pcx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.22</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
5 changes: 0 additions & 5 deletions formats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
104 changes: 102 additions & 2 deletions gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.22</version>
</path>
<path>
<groupId>info.picocli</groupId>
Expand All @@ -96,9 +96,109 @@
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
<mainClass>me.nithanim.cultures.multitool.Main</mainClass>
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>package</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/distribution</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>validate</phase>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
<configuration>
<propertyPrefix>parsedVersion</propertyPrefix>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>../jpackage.template.cfg</file>
<outputFile>../jpackage.cfg</outputFile>
<replacements>
<replacement>
<token>VERSION</token>
<!-- ${project.version} potentially has "-SNAPSHOT" and windows msi does not like that -->
<value>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</value>
</replacement>
<replacement>
<token>MAINCLASS</token>
<value>${mainClass}</value>
</replacement>
<replacement>
<token>MAINJAR</token>
<value>./${project.build.finalName}.jar</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-files-on-build</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/distribution/</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<mainClass>me.nithanim.cultures.multitool.Main</mainClass>
</properties>
</project>
32 changes: 2 additions & 30 deletions gui/src/main/java/me/nithanim/cultures/multitool/Main.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
package me.nithanim.cultures.multitool;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import picocli.CommandLine;

public class Main extends Application {

public class Main {
public static void main(String[] args) {
Application.launch(Main.class, args);
}

@Override
public void start(Stage stage) throws Exception {
Cli cli = new Cli();
new CommandLine(cli).parseArgs(getParameters().getRaw().toArray(String[]::new));

MainController controller = new MainController();

FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/fxml/main.fxml"));
loader.setController(controller);
loader.setClassLoader(this.getClass().getClassLoader());
Parent root = loader.load();
Scene scene = new Scene(root);
scene.getStylesheets().add(this.getClass().getResource("/styles/styles.css").toString());
stage.setTitle("Cultures Multitool");
stage.setScene(scene);
stage.show();

if (cli.fileToOpen != null) {
controller.openFile(cli.fileToOpen);
}
Application.launch(MainFx.class, args);
}
}
32 changes: 32 additions & 0 deletions gui/src/main/java/me/nithanim/cultures/multitool/MainFx.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package me.nithanim.cultures.multitool;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import picocli.CommandLine;

public class MainFx extends Application {
@Override
public void start(Stage stage) throws Exception {
Cli cli = new Cli();
new CommandLine(cli).parseArgs(getParameters().getRaw().toArray(String[]::new));

MainController controller = new MainController();

FXMLLoader loader = new FXMLLoader(this.getClass().getResource("/fxml/main.fxml"));
loader.setController(controller);
loader.setClassLoader(this.getClass().getClassLoader());
Parent root = loader.load();
Scene scene = new Scene(root);
scene.getStylesheets().add(this.getClass().getResource("/styles/styles.css").toString());
stage.setTitle("Cultures Multitool");
stage.setScene(scene);
stage.show();

if (cli.fileToOpen != null) {
controller.openFile(cli.fileToOpen);
}
}
}
4 changes: 4 additions & 0 deletions jpackage-linux.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#--linux-package-name cultures-multitool
--linux-deb-maintainer "Nithanim"
--linux-shortcut
#--icon icon.png
4 changes: 4 additions & 0 deletions jpackage-windows.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--win-shortcut
#--win-console
--type msi
#--icon icon.ico
8 changes: 8 additions & 0 deletions jpackage.template.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--input ./gui/target/distribution
--main-jar "MAINJAR"
--main-class "MAINCLASS"
--name "Cultures Multitool"
--app-version VERSION
#--description ""
--dest ./distributions
--vendor "Nithanim
4 changes: 0 additions & 4 deletions package/.gitignore

This file was deleted.

Loading

0 comments on commit 06316b6

Please sign in to comment.