Skip to content

Commit

Permalink
Added config to be able to generate executable jar
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc committed Nov 8, 2020
1 parent 09afc19 commit e0d7ef8
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ hs_err_pid*
*.lst
*/target/*
*/.attach*
target/*
53 changes: 53 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.log</groupId>
<artifactId>LogAnalyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<manifestEntries>
<Main-Class>org.log.Main</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>org.log.presentation.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

40 changes: 23 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.log</groupId>
<artifactId>LogAnalyzer</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>

<properties>
Expand All @@ -18,11 +18,6 @@
<artifactId>javafx-controls</artifactId>
<version>15</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
Expand All @@ -47,18 +42,29 @@
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.log.presentation.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.log.Main</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.log.presentation.App

9 changes: 9 additions & 0 deletions src/main/java/org/log/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.log;

import org.log.presentation.App;

public class Main {
public static void main(String[] args) {
App.main(args);
}
}
10 changes: 6 additions & 4 deletions src/main/java/org/log/presentation/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;
import java.nio.file.Paths;

public class App extends Application {

Expand All @@ -18,8 +16,12 @@ public class App extends Application {
public void start(Stage stage) throws IOException {
window = stage;

URL url = Paths.get("./src/main/resources/Main.fxml").toUri().toURL();
Parent root = FXMLLoader.load(url);
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/Main.fxml"));
Parent root = loader.load();

//URL url = Paths.get("./src/main/resources/Main.fxml").toUri().toURL();
//Parent root = FXMLLoader.load(url);
//Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("/Main.fxml"));
window.setTitle("Log Analyzer");
Scene scene = new Scene(root);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/log/presentation/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.log.presentation.App

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.IOException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.List;
import java.util.ResourceBundle;

Expand Down Expand Up @@ -81,8 +80,13 @@ public void handleOnSaveFilterClick(ActionEvent actionEvent) {

public void handleOnCreateFilterClick(ActionEvent actionEvent) {
try {
URL url = Paths.get("./src/main/resources/NewFilterDialog.fxml").toUri().toURL();
Parent newFilterScene = FXMLLoader.load(url);
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/NewFilterDialog.fxml"));
Parent newFilterScene = loader.load();

//URL url = Paths.get("./src/main/resources/NewFilterDialog.fxml").toUri().toURL();
//Parent newFilterScene = FXMLLoader.load(url);

Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.initStyle(StageStyle.UTILITY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.*;

public class MainController implements Initializable {
Expand Down Expand Up @@ -149,8 +148,13 @@ public void handleExitMenuClick(ActionEvent actionEvent) {

public void handleOnEditFiltersClick(ActionEvent actionEvent) {
try {
URL url = Paths.get("./src/main/resources/EditFilters.fxml").toUri().toURL();
Parent editScene = FXMLLoader.load(url);
//URL url = Paths.get("./src/main/resources/EditFilters.fxml").toUri().toURL();
//Parent editScene = FXMLLoader.load(url);

FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/EditFilters.fxml"));
Parent editScene = loader.load();

Stage stage = new Stage();
stage.initOwner((menuBar.getScene().getWindow()));
stage.initModality(Modality.APPLICATION_MODAL);
Expand Down

0 comments on commit e0d7ef8

Please sign in to comment.