Skip to content

Commit

Permalink
Merge pull request #341 from yermak/macos
Browse files Browse the repository at this point in the history
MacOS build and config
  • Loading branch information
yermak authored Dec 20, 2021
2 parents 6280247 + bd62c63 commit 1b0ba8f
Show file tree
Hide file tree
Showing 37 changed files with 347 additions and 206 deletions.
8 changes: 4 additions & 4 deletions app/path.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ffmpeg=external/x64/windows/ffmpeg.exe
ffprobe=external/x64/windows/ffprobe.exe
mp4art=external/x64/windows/mp4art.exe
mp4info=external/x64/windows/mp4info.exe
ffmpeg=external/x64/mac/ffmpeg
ffprobe=external/x64/mac/ffprobe
mp4art=external/x64/mac/mp4art
mp4info=external/x64/mac/mp4info
platform=steam
5 changes: 5 additions & 0 deletions idea.txt → build/idea.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
VM Options=--module-path "C:\Users\Yermak\Programs\JavaFX\javafx-sdk-15.0.1\lib" --add-modules javafx.controls,javafx.fxml,javafx.media,javafx.base,javafx.swing,javafx.graphics
Enviromnent var=FFMPEG=external/x64/windows


https://www.reddit.com/r/gamedev/comments/di61ms/have_a_mac_game_on_steam_heres_a_guide_to_signing/


35 changes: 35 additions & 0 deletions build/mac/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
JAVA_HOME=/Users/Yarick_Yermak/Library/Java/JavaVirtualMachines/temurin-17/Contents/Home
JAVA_HOME=$1
JAVAFX_JMODS=jmods/mac
#APP_VERSION=5.6.3

rm -rf target/release
mkdir target/release

rm -rf target/fx-jre
$JAVA_HOME/bin/jlink --module-path $JAVA_HOME/jmods:$JAVAFX_JMODS \
--add-modules java.base,java.sql,javafx.controls,javafx.fxml,javafx.media,javafx.base,javafx.swing,javafx.graphics --output target/fx-jre

rm -rf target/image
$JAVA_HOME/bin/jpackage --app-version $APP_VERSION --icon AudioBookConverter.icns \
--type app-image \
--input target/package/audiobookconverter-$APP_VERSION-mac-installer/audiobookconverter-$APP_VERSION/app \
--main-jar lib/audiobookconverter-$APP_VERSION.jar \
--runtime-image target/fx-jre \
--java-options "--add-exports java.desktop/com.apple.eio=ALL-UNNAMED" \
--dest target/release \
--vendor "Recoupler Limited" \
--app-version $APP_VERSION \
--mac-package-identifier com.recoupler.audiobookconverter \
--mac-package-name AudiobookConverter \
--mac-signing-key-user-name "Developer ID Application: Recoupler Limited" \
--mac-sign


#$JAVA_HOME/bin/jpackage --app-version $(APP_VERSION) --icon AudioBookConverter.icns \
#--type dmg \
#--input target/package/audiobookconverter-$(APP_VERSION)-mac-installer/audiobookconverter-$(APP_VERSION)/app \
#--main-jar lib/audiobookconverter-$(APP_VERSION).jar --runtime-image target/fx-jre --java-options '--enable-preview'
#mkdir target/release


Binary file added external/x64/mac/ffmpeg
Binary file not shown.
Binary file added external/x64/mac/ffprobe
Binary file not shown.
Binary file added external/x64/mac/mp4art
Binary file not shown.
Binary file added external/x64/mac/mp4info
Binary file not shown.
5 changes: 5 additions & 0 deletions external/x64/mac/path.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ffmpeg=Contents/app/external/ffmpeg
ffprobe=Contents/app/external/ffprobe
mp4art=Contents/app/external/mp4art
mp4info=Contents/app/external/mp4info
platform=steam
26 changes: 21 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<groupId>uk.yermak</groupId>
<artifactId>audiobookconverter</artifactId>

<!--
<version>5.5.10</version>
-->
<!-- <version>5.6.3</version>-->

<version>#{APP_VERSION}#</version>

<properties>
Expand Down Expand Up @@ -128,6 +127,23 @@
<version>4.3.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.apple/AppleJavaExtensions -->
<dependency>
<groupId>com.apple</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.4</version>
</dependency>


<!--
<dependency>
<groupId>com.apple</groupId>
<artifactId>javaextensions</artifactId>
<scope>>system</scope>
<systemPath>/Users/Yarick_Yermak/Projects/AudioBookConverter/lib/applejavaextensions-1.4.jar</systemPath>
</dependency>
-->

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand All @@ -144,7 +160,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<mainClass>ConverterApplication</mainClass>
<mainClass>AudioBookConverter</mainClass>
<executable>${java.home}\bin\java</executable>
</configuration>
</plugin>
Expand Down Expand Up @@ -181,7 +197,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>uk.yermak.audiobookconverter.fx.ConverterApplication</mainClass>
<mainClass>uk.yermak.audiobookconverter.AudiobookConverter</mainClass>
</manifest>
</archive>
</configuration>
Expand Down
16 changes: 16 additions & 0 deletions src/main/deploy/assembly/mac-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@
</includes>
<outputDirectory>app</outputDirectory>
</fileSet>
<fileSet>
<directory>external/x64/mac</directory>
<outputDirectory>app/external/</outputDirectory>
<includes>
<include>*</include>
</includes>
</fileSet>
<fileSet>
<directory>external/x64/mac</directory>
<outputDirectory>app</outputDirectory>
<includes>
<include>path.properties</include>
</includes>
</fileSet>


</fileSets>
<dependencySets>
<dependencySet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AppProperties {
loadAppProperties();
}

private static synchronized Properties loadAppProperties() {
static synchronized Properties loadAppProperties() {
if (PROP_FILE.exists()) {
try (FileInputStream in = new FileInputStream(PROP_FILE)) {
applicationProps.load(in);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package uk.yermak.audiobookconverter.fx;/**
package uk.yermak.audiobookconverter;/**
* Created by Yermak on 06-Jan-18.
*/

import com.apple.eio.FileManager;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
Expand All @@ -18,6 +19,8 @@
import uk.yermak.audiobookconverter.AppProperties;
import uk.yermak.audiobookconverter.Utils;
import uk.yermak.audiobookconverter.Version;
import uk.yermak.audiobookconverter.fx.ConversionContext;
import uk.yermak.audiobookconverter.fx.JfxEnv;

import java.io.File;
import java.io.IOException;
Expand All @@ -28,7 +31,7 @@
import java.util.Scanner;
import java.util.concurrent.Executors;

public class ConverterApplication extends Application {
public class AudiobookConverter extends Application {
private static JfxEnv env;

//TODO clean-up
Expand All @@ -42,9 +45,10 @@ public static void initAppHome() {
if (appdata != null) {
appDir = new File(appdata, Version.getVersionString());
} else {
appDir = new File(System.getProperty("user.home"), Version.getVersionString());
File file = new File(".abc", Version.getVersionString());
appDir = new File(System.getProperty("user.home"), file.getPath());
}
if (appDir.exists() || appDir.mkdir()) {
if (appDir.exists() || appDir.mkdirs()) {
System.setProperty("APP_HOME", appDir.getAbsolutePath());
} else {
System.setProperty("APP_HOME", System.getProperty("user.home"));
Expand Down Expand Up @@ -78,7 +82,7 @@ public void start(Stage stage) {
logger.info("Initialising application");

try {
URL resource = ConverterApplication.class.getResource("/uk/yermak/audiobookconverter/fx/fxml_converter.fxml");
URL resource = AudiobookConverter.class.getResource("/uk/yermak/audiobookconverter/fx/fxml_converter.fxml");
root = FXMLLoader.load(resource);

Scene scene = new Scene(root);
Expand All @@ -93,7 +97,7 @@ public void start(Stage stage) {

stage.setOnCloseRequest(event -> {
logger.info("Closing application");
ConverterApplication.getContext().stopConversions();
AudiobookConverter.getContext().stopConversions();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Expand Down Expand Up @@ -136,7 +140,7 @@ static class VersionChecker implements Runnable {
@Override
public void run() {
try {
String platform = Utils.loadAppProperties().getProperty("platform");
String platform = Environment.current.loadAppProperties().getProperty("platform");
if (platform == null) platform = "version";
if ("steam".equals(platform)) return;
String version = readStringFromURL("https://raw.githubusercontent.com/yermak/AudioBookConverter/version/" + platform + ".txt");
Expand All @@ -145,10 +149,12 @@ public void run() {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("New Version Available!");
String path = FileManager.getPathToApplicationBundle();
// alert.setContentText("path:"+ path);
alert.setContentText("Would you like to download new version?");
Optional<ButtonType> result = alert.showAndWait();
if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
ConverterApplication.getEnv().showDocument("https://store.steampowered.com/app/1529240/AudioBookConverter/");
AudiobookConverter.getEnv().showDocument("https://store.steampowered.com/app/1529240/AudioBookConverter/");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.yermak.audiobookconverter.fx.ConversionProgress;
import uk.yermak.audiobookconverter.fx.ConverterApplication;
import uk.yermak.audiobookconverter.fx.ProgressComponent;

import java.io.File;
Expand Down Expand Up @@ -43,7 +42,7 @@ public ConversionProgress start(Convertable convertable, String outputDestinatio

jobs.add(conversionJob);
Executors.newSingleThreadExecutor().execute(conversionProgress);
ConverterApplication.getContext().addJob(conversionJob);
AudiobookConverter.getContext().addJob(conversionJob);
return conversionProgress;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.yermak.audiobookconverter.fx.ConverterApplication;

import java.io.File;
import java.io.PrintWriter;
Expand Down Expand Up @@ -43,7 +42,7 @@ public ConversionJob(ConversionGroup conversionGroup, Convertable convertable, M

addStatusChangeListener((observable, oldValue, newValue) -> {
if (FINISHED.equals(newValue)) {
Platform.runLater(() -> ConverterApplication.showNotification(outputDestination));
Platform.runLater(() -> AudiobookConverter.showNotification(outputDestination));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import net.bramp.ffmpeg.FFprobe;
import net.bramp.ffmpeg.probe.FFmpegProbeResult;
import net.bramp.ffmpeg.probe.FFmpegStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -47,7 +45,7 @@ static long parseDuration(String info) {
public static void mp4v2UpdateDuration(MediaInfo mediaInfo, String outputFileName) throws IOException {
Process process = null;
try {
ProcessBuilder infoProcessBuilder = new ProcessBuilder(Utils.MP4INFO, outputFileName);
ProcessBuilder infoProcessBuilder = new ProcessBuilder(Environment.MP4INFO, outputFileName);
process = infoProcessBuilder.start();
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamCopier.copy(process.getInputStream(), out);
Expand All @@ -69,7 +67,7 @@ public static void mp4v2UpdateDuration(MediaInfo mediaInfo, String outputFileNam

public static void ffMpegUpdateDuration(MediaInfo mediaInfo, String outputFileName) throws IOException {
final Set<String> AUDIO_CODECS = ImmutableSet.of("mp3", "aac", "wmav2", "flac", "alac", "vorbis", "opus");
FFprobe ffprobe = new FFprobe(Utils.FFPROBE);
FFprobe ffprobe = new FFprobe(Environment.FFPROBE);
FFmpegProbeResult probe = ffprobe.probe(outputFileName);
List<FFmpegStream> streams = probe.getStreams();
for (FFmpegStream stream : streams) {
Expand Down
Loading

0 comments on commit 1b0ba8f

Please sign in to comment.