From da5dcb968eb264a2f5f9460a272eaed5de09db81 Mon Sep 17 00:00:00 2001
From: Conor Egan <68134729+c-eg@users.noreply.github.com>
Date: Wed, 5 Apr 2023 18:35:05 +0100
Subject: [PATCH] undo previous work
jlink cannot be used because certain dependencies do not have a module-info in their project, and instead of hacking something together with jdeps and moditect, I'm just going to create a 'fat' jar and package it with jpackage, but that required a main class that doesn't extend Application.
---
pom.xml | 43 +----------
src/main/java/module-info.java | 16 ----
.../showrenamer/JavaFxApplication.java | 77 +++++++++++++++++++
.../showrenamer/ShowRenamerApplication.java | 61 +++------------
.../suggestion/TMDBSuggestionProvider.java | 14 +---
.../showrenamer/util/ShowInfoMatcherTest.java | 2 +-
6 files changed, 92 insertions(+), 121 deletions(-)
delete mode 100644 src/main/java/module-info.java
create mode 100644 src/main/java/uk/co/conoregan/showrenamer/JavaFxApplication.java
diff --git a/pom.xml b/pom.xml
index a408ed8..14b2428 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,7 @@
19
UTF-8
5.8.2
+ 19
@@ -50,34 +51,12 @@
org.openjfx
javafx-controls
- 19
+ ${javafx.version}
org.openjfx
javafx-fxml
- 19
-
-
- org.controlsfx
- controlsfx
- 11.1.1
-
-
- org.kordamp.ikonli
- ikonli-javafx
- 12.3.1
-
-
- org.kordamp.bootstrapfx
- bootstrapfx-core
- 0.4.0
-
-
-
-
- com.googlecode.json-simple
- json-simple
- 1.1.1
+ ${javafx.version}
@@ -87,20 +66,6 @@
3.0.2
-
-
- org.json
- json
- 20200518
-
-
-
-
- com.github.ben-manes.caffeine
- caffeine
- 3.1.5
-
-
com.github.holgerbrandl
@@ -125,7 +90,7 @@
javafx-maven-plugin
0.0.8
- uk.co.conoregan.showrenamer.ShowRenamerApplication
+ uk.co.conoregan.showrenamer.JavaFxApplication
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
deleted file mode 100644
index 88ada36..0000000
--- a/src/main/java/module-info.java
+++ /dev/null
@@ -1,16 +0,0 @@
-module ShowRenamer {
- requires javafx.controls;
- requires javafx.fxml;
- requires org.slf4j;
- requires jsr305;
- requires themoviedbapi;
- requires com.github.benmanes.caffeine;
-
- opens uk.co.conoregan.showrenamer to javafx.graphics;
- opens uk.co.conoregan.showrenamer.controller to javafx.fxml;
- opens images;
- opens properties;
- opens style;
- opens view;
- exports uk.co.conoregan.showrenamer;
-}
\ No newline at end of file
diff --git a/src/main/java/uk/co/conoregan/showrenamer/JavaFxApplication.java b/src/main/java/uk/co/conoregan/showrenamer/JavaFxApplication.java
new file mode 100644
index 0000000..210385d
--- /dev/null
+++ b/src/main/java/uk/co/conoregan/showrenamer/JavaFxApplication.java
@@ -0,0 +1,77 @@
+/*
+ * This file is part of ShowRenamer.
+ *
+ * ShowRenamer is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * ShowRenamer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with ShowRenamer. If not, see .
+ */
+
+package uk.co.conoregan.showrenamer;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+
+/**
+ * The starting point of the ShowRenamer application.
+ */
+public class JavaFxApplication extends Application {
+ /**
+ * The logger.
+ */
+ private static final Logger LOGGER = LoggerFactory.getLogger(JavaFxApplication.class);
+
+ /**
+ * The screen width.
+ */
+ private static final int WIDTH = 1280;
+
+ /**
+ * The screen height.
+ */
+ private static final int HEIGHT = 720;
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ final String viewPath = "view/rename.fxml";
+ final URL startView = getClass().getClassLoader().getResource(viewPath);
+
+ if (startView == null) {
+ LOGGER.error(String.format("The resource: %s was not found.", viewPath));
+ System.exit(0);
+ }
+
+ final Parent root = FXMLLoader.load(startView);
+ final Scene scene = new Scene(root, WIDTH, HEIGHT);
+
+ primaryStage.setMinWidth(WIDTH);
+ primaryStage.setMinHeight(HEIGHT);
+ primaryStage.setTitle("Show Renamer");
+ primaryStage.setScene(scene);
+ // primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("images/icon.png")));
+
+ primaryStage.show();
+ LOGGER.info("Show Renamer successfully started.");
+ }
+}
+
+
diff --git a/src/main/java/uk/co/conoregan/showrenamer/ShowRenamerApplication.java b/src/main/java/uk/co/conoregan/showrenamer/ShowRenamerApplication.java
index 4fea956..c4aeb04 100644
--- a/src/main/java/uk/co/conoregan/showrenamer/ShowRenamerApplication.java
+++ b/src/main/java/uk/co/conoregan/showrenamer/ShowRenamerApplication.java
@@ -17,61 +17,18 @@
package uk.co.conoregan.showrenamer;
-import javafx.application.Application;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Parent;
-import javafx.scene.Scene;
-import javafx.stage.Stage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URL;
-
/**
- * The starting point of the ShowRenamer application.
+ * This is a class to call the main function from a class that doesn't extend Application. It is needed in order to run the app without
+ * module-info. I don't want to add module info until all dependencies have it too, in order to generate a runtime image with jlink.
+ * For now, I will create a 'fat' jar and use jpackage to generate an installer.
*/
-public class ShowRenamerApplication extends Application {
- /**
- * The logger.
- */
- private static final Logger LOGGER = LoggerFactory.getLogger(ShowRenamerApplication.class);
-
+public class ShowRenamerApplication {
/**
- * The screen width.
+ * Start function.
+ *
+ * @param args the args.
*/
- private static final int WIDTH = 1280;
-
- /**
- * The screen height.
- */
- private static final int HEIGHT = 720;
-
public static void main(String[] args) {
- launch(args);
+ JavaFxApplication.main(args);
}
-
- @Override
- public void start(Stage primaryStage) throws Exception {
- final String viewPath = "view/rename.fxml";
- final URL startView = getClass().getClassLoader().getResource(viewPath);
-
- if (startView == null) {
- LOGGER.error(String.format("The resource: %s was not found.", viewPath));
- System.exit(0);
- }
-
- final Parent root = FXMLLoader.load(startView);
- final Scene scene = new Scene(root, WIDTH, HEIGHT);
-
- primaryStage.setMinWidth(WIDTH);
- primaryStage.setMinHeight(HEIGHT);
- primaryStage.setTitle("Show Renamer");
- primaryStage.setScene(scene);
- // primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("images/icon.png")));
-
- primaryStage.show();
- LOGGER.info("Show Renamer successfully started.");
- }
-}
-
-
+}
\ No newline at end of file
diff --git a/src/main/java/uk/co/conoregan/showrenamer/suggestion/TMDBSuggestionProvider.java b/src/main/java/uk/co/conoregan/showrenamer/suggestion/TMDBSuggestionProvider.java
index 9fc47a6..b3a5661 100644
--- a/src/main/java/uk/co/conoregan/showrenamer/suggestion/TMDBSuggestionProvider.java
+++ b/src/main/java/uk/co/conoregan/showrenamer/suggestion/TMDBSuggestionProvider.java
@@ -17,8 +17,6 @@
package uk.co.conoregan.showrenamer.suggestion;
-import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
import info.movito.themoviedbapi.TmdbApi;
import info.movito.themoviedbapi.model.MovieDb;
import info.movito.themoviedbapi.model.Multi;
@@ -55,10 +53,6 @@ public class TMDBSuggestionProvider implements ShowSuggestionProvider {
*/
private static final TmdbApi TMDB_API;
- private static final Cache> SHOW_RESULTS_CACHE;
-
- private static final int SHOW_RESULT_CACHE_MAX_SIZE = 10_000;
-
static {
// load properties config
final String apiKeysPath = "properties/api_keys.properties";
@@ -90,10 +84,6 @@ public class TMDBSuggestionProvider implements ShowSuggestionProvider {
System.exit(0);
}
TMDB_API = new TmdbApi(tmdbApiKey);
-
- SHOW_RESULTS_CACHE = Caffeine.newBuilder()
- .maximumSize(SHOW_RESULT_CACHE_MAX_SIZE)
- .build();
}
@Override
@@ -105,9 +95,7 @@ public Optional getSuggestion(@Nonnull final String fileName) {
return Optional.empty();
}
- // todo: check this is working as expected as it is run by a thread.
- final List results = SHOW_RESULTS_CACHE.get(matchedTitle.get(), t ->
- TMDB_API.getSearch().searchMulti(matchedTitle.get(), "en-US", 1).getResults());
+ final List results = TMDB_API.getSearch().searchMulti(matchedTitle.get(), "en-US", 1).getResults();
if (!ResultValidator.isGenericListValid(results)) {
LOGGER.info(String.format("No result found for title: %s", matchedTitle.get()));
diff --git a/src/test/java/uk/co/conoregan/showrenamer/util/ShowInfoMatcherTest.java b/src/test/java/uk/co/conoregan/showrenamer/util/ShowInfoMatcherTest.java
index e672bbe..fdd5502 100644
--- a/src/test/java/uk/co/conoregan/showrenamer/util/ShowInfoMatcherTest.java
+++ b/src/test/java/uk/co/conoregan/showrenamer/util/ShowInfoMatcherTest.java
@@ -17,7 +17,7 @@
package uk.co.conoregan.showrenamer.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import java.util.ArrayList;