Skip to content

Commit

Permalink
undo previous work
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
c-eg committed Apr 5, 2023
1 parent 04037db commit da5dcb9
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 121 deletions.
43 changes: 4 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.8.2</junit.version>
<javafx.version>19</javafx.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -50,34 +51,12 @@
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>19</version>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.1.1</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<version>12.3.1</version>
</dependency>
<dependency>
<groupId>org.kordamp.bootstrapfx</groupId>
<artifactId>bootstrapfx-core</artifactId>
<version>0.4.0</version>
</dependency>

<!-- Google Json Simple https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<version>${javafx.version}</version>
</dependency>

<!-- Google Find Bugs https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305 -->
Expand All @@ -87,20 +66,6 @@
<version>3.0.2</version>
</dependency>

<!-- Json https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>

<!-- Caffeine Cache https://search.maven.org/artifact/com.github.ben-manes.caffeine/caffeine/3.1.5/jar?eh= -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.5</version>
</dependency>

<!-- The Movie Database API Wrapper https://github.com/holgerbrandl/themoviedbapi -->
<dependency>
<groupId>com.github.holgerbrandl</groupId>
Expand All @@ -125,7 +90,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>uk.co.conoregan.showrenamer.ShowRenamerApplication</mainClass>
<mainClass>uk.co.conoregan.showrenamer.JavaFxApplication</mainClass>
</configuration>
</plugin>
</plugins>
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/module-info.java

This file was deleted.

77 changes: 77 additions & 0 deletions src/main/java/uk/co/conoregan/showrenamer/JavaFxApplication.java
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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.");
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,10 +53,6 @@ public class TMDBSuggestionProvider implements ShowSuggestionProvider {
*/
private static final TmdbApi TMDB_API;

private static final Cache<String, List<Multi>> 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";
Expand Down Expand Up @@ -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
Expand All @@ -105,9 +95,7 @@ public Optional<String> getSuggestion(@Nonnull final String fileName) {
return Optional.empty();
}

// todo: check this is working as expected as it is run by a thread.
final List<Multi> results = SHOW_RESULTS_CACHE.get(matchedTitle.get(), t ->
TMDB_API.getSearch().searchMulti(matchedTitle.get(), "en-US", 1).getResults());
final List<Multi> 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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit da5dcb9

Please sign in to comment.