Add pom.xml and set up jar packaging

FXML loading needed to change when resources were packaged in jar.
This commit is contained in:
Nathan McRae 2025-03-09 15:15:08 -07:00
parent 81b347eb41
commit 48790790b4
4 changed files with 203 additions and 5 deletions

198
pom.xml Normal file
View File

@ -0,0 +1,198 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>name.nathanmcrae</groupId>
<artifactId>numbersstation</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
<javafx.version>23.0.2</javafx.version>
</properties>
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${project.basedir}/mvn-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>7.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
<version>0.2.23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>wordpress</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>3.1.3</version>
<!-- <scope>system</scope> -->
<!-- <systemPath>${basedir}/lib/xmlrpc-client-3.1.3.jar</systemPath> -->
</dependency>
<dependency>
<groupId>com.tearsofaunicorn.wordpress</groupId>
<artifactId>wordpress-xmlrpc-client</artifactId>
<version>1.1</version>
<!-- <scope>system</scope> -->
<!-- <systemPath>${basedir}/lib/wordpress-xmlrpc-client-1.1-SNAPSHOT.jar</systemPath> -->
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-common</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.leakyabstractions</groupId>
<artifactId>result</artifactId>
<version>1.0.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-compiler-plugin</artifactId> -->
<!-- <version>3.8.1</version> -->
<!-- <configuration> -->
<!-- <source>${maven.compiler.source}</source> -->
<!-- <target>${maven.compiler.target}</target> -->
<!-- <compilerArgs> -->
<!-- <arg>-\-module-path</arg> -->
<!-- <arg>${project.basedir}/lib</arg> -->
<!-- <arg>-\-add-modules</arg> -->
<!-- <arg>com.ctc.wstx,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310,com.jcraft.jsch,javafx.controls,javafx.fxml,org.apache.commons.cli,result,wordpress.xmlrpc.client</arg> -->
<!-- </compilerArgs> -->
<!-- </configuration> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-jar-plugin</artifactId> -->
<!-- <version>3.1.0</version> -->
<!-- <configuration> -->
<!-- <archive> -->
<!-- <manifest> -->
<!-- <addClasspath>true</addClasspath> -->
<!-- <mainClass>name.nathanmcrae.numbersstation.Main</mainClass> -->
<!-- </manifest> -->
<!-- </archive> -->
<!-- </configuration> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <artifactId>maven-assembly-plugin</artifactId> -->
<!-- <configuration> -->
<!-- <archive> -->
<!-- <manifest> -->
<!-- <mainClass>name.nathanmcrae.numbersstation.Main</mainClass> -->
<!-- </manifest> -->
<!-- </archive> -->
<!-- <descriptorRefs> -->
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
<!-- </descriptorRefs> -->
<!-- </configuration> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-assembly-plugin</artifactId> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <phase>package</phase> -->
<!-- <goals> -->
<!-- <goal>single</goal> -->
<!-- </goals> -->
<!-- <configuration> -->
<!-- <archive> -->
<!-- <manifest> -->
<!-- <mainClass> -->
<!-- name.nathanmcrae.numbersstation.Main -->
<!-- </mainClass> -->
<!-- </manifest> -->
<!-- </archive> -->
<!-- <descriptorRefs> -->
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
<!-- </descriptorRefs> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.openjfx</groupId> -->
<!-- <artifactId>javafx-maven-plugin</artifactId> -->
<!-- <version>0.0.8</version> -->
<!-- <configuration> -->
<!-- <mainClass>name.nathanmcrae.numbersstation.Main</mainClass> -->
<!-- </configuration> -->
<!-- </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>name.nathanmcrae.numbersstation.MainRun</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -62,7 +62,7 @@ public class Main extends Application {
try {
if (startParams.notification().isPresent()){
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("NotificationView.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/NotificationView.fxml"));
Parent root = fxmlLoader.load();
NotificationController controller = fxmlLoader.getController();
@ -72,7 +72,7 @@ public class Main extends Application {
primaryStage.setScene(new Scene(root));
primaryStage.show();
} else {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainView.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MainView.fxml"));
Parent root = fxmlLoader.load();
MainController controller = fxmlLoader.getController();

View File

@ -66,7 +66,7 @@ public class MainController implements Initializable {
private void handleStationSettingsButtonPress() {
if (settingsStage == null || !settingsStage.isShowing()) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("StationSettingsView.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/StationSettingsView.fxml"));
Parent root = fxmlLoader.load();
StationSettingsController controller = fxmlLoader.getController();
@ -101,7 +101,7 @@ public class MainController implements Initializable {
private void handleSelectStationButtonPress() throws Exception {
if (selectStationStage == null || !selectStationStage.isShowing()) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("StationSelectionView.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/StationSelectionView.fxml"));
Parent root = fxmlLoader.load();
StationSelectionController controller = fxmlLoader.getController();

View File

@ -357,7 +357,7 @@ public class StationSettingsController {
@FXML
private void handleAddPrefixButtonPress() {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("AddPrefixView.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/AddPrefixView.fxml"));
Parent root = loader.load();
AddPrefixController controller = loader.getController();