From f8614456974a1dc73856d4e5f7e71eb80eef29df Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Mon, 2 May 2022 16:15:01 -0400 Subject: [PATCH] Added Maven step to compile a .jar file with all dependencies (for easy deployment); Added code to define the FFMPEG binary path and video repository through a TOML file --- pom.xml | 185 ++++++++++-------- src/main/java/tech/bitgoblin/App.java | 4 +- .../java/tech/bitgoblin/config/Config.java | 8 +- .../java/tech/bitgoblin/video/Transcoder.java | 9 +- 4 files changed, 113 insertions(+), 93 deletions(-) diff --git a/pom.xml b/pom.xml index 45b577d..347a2f4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,91 +1,112 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - tech.bitgoblin - Dragoon - 0.1.0 + tech.bitgoblin + Dragoon + 0.1.0 - Dragoon - https://www.bitgoblin.tech + Dragoon + https://www.bitgoblin.tech - - UTF-8 - 11 - 11 - + + UTF-8 + 11 + 11 + - - - org.tomlj - tomlj - 1.0.0 - - - junit - junit - 4.11 - test - - + + + org.tomlj + tomlj + 1.0.0 + + + junit + junit + 4.11 + test + + - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - - **/log4j.properties - - - - - tech.bitgoblin.App - - - - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + + **/log4j.properties + + + + + tech.bitgoblin.App + + + + + + maven-assembly-plugin + + + package + + single + + + + + + + tech.bitgoblin.App + + + + jar-with-dependencies + + + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + diff --git a/src/main/java/tech/bitgoblin/App.java b/src/main/java/tech/bitgoblin/App.java index 0bcb610..9a36d98 100644 --- a/src/main/java/tech/bitgoblin/App.java +++ b/src/main/java/tech/bitgoblin/App.java @@ -15,8 +15,8 @@ public class App { // read our config file Config c = new Config(configFile); // create new Transcoder object and start the service - //Transcoder t = new Transcoder("~/dragoon"); - //t.transcode(); + Transcoder t = new Transcoder(c); + t.transcode(); } } diff --git a/src/main/java/tech/bitgoblin/config/Config.java b/src/main/java/tech/bitgoblin/config/Config.java index f6efc2a..03060f0 100644 --- a/src/main/java/tech/bitgoblin/config/Config.java +++ b/src/main/java/tech/bitgoblin/config/Config.java @@ -10,7 +10,7 @@ import tech.bitgoblin.io.IOUtils; public class Config { - private String configPath; + private final String configPath; private TomlParseResult result; public Config(String path) { @@ -18,8 +18,6 @@ public class Config { // parse config file try { this.parseConfig(); - String value = this.result.getString("repo"); - System.out.println(value); } catch (IOException e) { System.out.println("Unable to read config file; please check that " + this.configPath + " is available."); System.exit(1); @@ -30,6 +28,10 @@ public class Config { return this.result.getString(key); } + public boolean contains(String key) { + return this.result.contains(key); + } + private void parseConfig() throws IOException { // parse config file Path source = Paths.get(this.configPath); diff --git a/src/main/java/tech/bitgoblin/video/Transcoder.java b/src/main/java/tech/bitgoblin/video/Transcoder.java index a02968b..dfa3f9f 100644 --- a/src/main/java/tech/bitgoblin/video/Transcoder.java +++ b/src/main/java/tech/bitgoblin/video/Transcoder.java @@ -25,12 +25,9 @@ public class Transcoder { public Transcoder(Config config) { this.config = config; this.repo_dir = IOUtils.resolveTilda(config.getString("transcoder.repo_path")); - this.initDirectory(); - } - // define a custom FFMPEG binary path - public Transcoder(String repo_dir, String ffmpeg_path) { - this.repo_dir = IOUtils.resolveTilda(repo_dir); - this.ffmpeg_path = ffmpeg_path; + if (this.config.contains("transcoder.ffmpeg_path")) { + this.ffmpeg_path = config.getString("transcoder.ffmpeg_path"); + } this.initDirectory(); }