Skip to content

Commit

Permalink
package application into jar
Browse files Browse the repository at this point in the history
  • Loading branch information
c-eg committed Apr 5, 2023
1 parent 7bdc26f commit cf84370
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ hs_err_pid*
# End of https://www.toptal.com/developers/gitignore/api/intellij,java
target/
.idea/
/dependency-reduced-pom.xml
63 changes: 52 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
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>

<name>ShowRenamer</name>
<groupId>uk.co.conoregan.show-renamer</groupId>
<artifactId>show-renamer</artifactId>
<version>0.7.0-ALPHA</version>
<name>ShowRenamer</name>

<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<maven.compiler.java.version>19</maven.compiler.java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.8.2</junit.version>
<javafx.version>19</javafx.version>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-shade-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
</dependency>

<!-- SLF4J https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -59,6 +65,26 @@
<version>${javafx.version}</version>
</dependency>

<!-- JavaFX: cross-platform fat jar -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
<classifier>mac</classifier>
</dependency>

<!-- Google Find Bugs https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305 -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand All @@ -81,17 +107,32 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>19</source>
<target>19</target>
<source>${maven.compiler.java.version}</source>
<target>${maven.compiler.java.version}</target>
<release>${maven.compiler.java.version}</release>
</configuration>
</plugin>

<!-- Fat/Shaded jar -->
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>uk.co.conoregan.showrenamer.ShowRenamerApplication</mainClass>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>uk.co.conoregan.showrenamer.ShowRenamerLauncher</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URL;

/**
* The starting point of the ShowRenamer application.
*/
Expand All @@ -52,15 +50,7 @@ public static void main(String[] 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 Parent root = FXMLLoader.load(getClass().getResource("/view/rename.fxml"));
final Scene scene = new Scene(root, WIDTH, HEIGHT);

primaryStage.setMinWidth(WIDTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,14 @@ public class TMDBSuggestionProvider implements ShowSuggestionProvider {

static {
// load properties config
final String apiKeysPath = "properties/api_keys.properties";
final URL res = RenameController.class.getClassLoader().getResource(apiKeysPath);
if (res == null) {
throw new UncheckedIOException(new FileNotFoundException(apiKeysPath));
}

final URI uri;
try {
uri = res.toURI();
} catch (URISyntaxException ex) {
throw new IllegalArgumentException(ex);
}
final String apiKeysPath = "/properties/api_keys.properties";
final InputStream res = TMDBSuggestionProvider.class.getResourceAsStream(apiKeysPath);

final Properties properties = new Properties();
try (InputStream is = Files.newInputStream(Paths.get(uri))) {
properties.load(is);
try {
properties.load(res);
} catch (IOException e) {
throw new UncheckedIOException("Failed to load resource", e);
throw new RuntimeException(e);
}

// make tmdb api
Expand Down

0 comments on commit cf84370

Please sign in to comment.