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
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-05-02 16:15:01 -04:00
parent ffb7d2d9f1
commit f861445697
4 changed files with 113 additions and 93 deletions

185
pom.xml
View File

@ -1,91 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?> <?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" <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/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>tech.bitgoblin</groupId> <groupId>tech.bitgoblin</groupId>
<artifactId>Dragoon</artifactId> <artifactId>Dragoon</artifactId>
<version>0.1.0</version> <version>0.1.0</version>
<name>Dragoon</name> <name>Dragoon</name>
<url>https://www.bitgoblin.tech</url> <url>https://www.bitgoblin.tech</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.tomlj</groupId> <groupId>org.tomlj</groupId>
<artifactId>tomlj</artifactId> <artifactId>tomlj</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.11</version> <version>4.11</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins> <plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin> <plugin>
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version> <version>3.1.0</version>
</plugin> </plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin> <plugin>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <version>3.8.0</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version> <version>2.22.1</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
<configuration> <configuration>
<!-- DO NOT include log4j.properties file in your Jar --> <!-- DO NOT include log4j.properties file in your Jar -->
<excludes> <excludes>
<exclude>**/log4j.properties</exclude> <exclude>**/log4j.properties</exclude>
</excludes> </excludes>
<archive> <archive>
<manifest> <manifest>
<!-- Jar file entry point --> <!-- Jar file entry point -->
<mainClass>tech.bitgoblin.App</mainClass> <mainClass>tech.bitgoblin.App</mainClass>
</manifest> </manifest>
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version> <executions>
</plugin> <execution>
<plugin> <phase>package</phase>
<artifactId>maven-deploy-plugin</artifactId> <goals>
<version>2.8.2</version> <goal>single</goal>
</plugin> </goals>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> </execution>
<plugin> </executions>
<artifactId>maven-site-plugin</artifactId> <configuration>
<version>3.7.1</version> <archive>
</plugin> <manifest>
<plugin> <mainClass>tech.bitgoblin.App</mainClass>
<artifactId>maven-project-info-reports-plugin</artifactId> </manifest>
<version>3.0.0</version> </archive>
</plugin> <descriptorRefs>
</plugins> <descriptorRef>jar-with-dependencies</descriptorRef>
</pluginManagement> </descriptorRefs>
</build> </configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project> </project>

View File

@ -15,8 +15,8 @@ public class App {
// read our config file // read our config file
Config c = new Config(configFile); Config c = new Config(configFile);
// create new Transcoder object and start the service // create new Transcoder object and start the service
//Transcoder t = new Transcoder("~/dragoon"); Transcoder t = new Transcoder(c);
//t.transcode(); t.transcode();
} }
} }

View File

@ -10,7 +10,7 @@ import tech.bitgoblin.io.IOUtils;
public class Config { public class Config {
private String configPath; private final String configPath;
private TomlParseResult result; private TomlParseResult result;
public Config(String path) { public Config(String path) {
@ -18,8 +18,6 @@ public class Config {
// parse config file // parse config file
try { try {
this.parseConfig(); this.parseConfig();
String value = this.result.getString("repo");
System.out.println(value);
} catch (IOException e) { } catch (IOException e) {
System.out.println("Unable to read config file; please check that " + this.configPath + " is available."); System.out.println("Unable to read config file; please check that " + this.configPath + " is available.");
System.exit(1); System.exit(1);
@ -30,6 +28,10 @@ public class Config {
return this.result.getString(key); return this.result.getString(key);
} }
public boolean contains(String key) {
return this.result.contains(key);
}
private void parseConfig() throws IOException { private void parseConfig() throws IOException {
// parse config file // parse config file
Path source = Paths.get(this.configPath); Path source = Paths.get(this.configPath);

View File

@ -25,12 +25,9 @@ public class Transcoder {
public Transcoder(Config config) { public Transcoder(Config config) {
this.config = config; this.config = config;
this.repo_dir = IOUtils.resolveTilda(config.getString("transcoder.repo_path")); this.repo_dir = IOUtils.resolveTilda(config.getString("transcoder.repo_path"));
this.initDirectory(); if (this.config.contains("transcoder.ffmpeg_path")) {
} this.ffmpeg_path = config.getString("transcoder.ffmpeg_path");
// 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;
this.initDirectory(); this.initDirectory();
} }