From 26e7eafb6a53eca25d6d7b9cb345ee81411cb1ff Mon Sep 17 00:00:00 2001 From: Gabor Bata Date: Thu, 12 Oct 2023 10:35:42 +0200 Subject: [PATCH] Update build scripts to use build folder * Use the same folder hierarchy as Gradle * Fix manifest file --- README.md | 2 +- build-and-run.sh | 22 +++++++++++++++++----- build-jar.sh | 26 ++++++++++++++++++++------ src/Manifest.txt | 2 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index aac0e563..dbb654d7 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ On Linux, two different scripts can be used. 2. `build-jar.sh` which will build a JAR file. You can then run the JAR file as such: - `java -jar mochadoom.jar -iwad wads/DOOM1.WAD`. + `java -jar build/libs/mochadoom.jar -iwad wads/DOOM1.WAD`. This is the preferred way for distributing a Mocha Doom executable. diff --git a/build-and-run.sh b/build-and-run.sh index 5d983fa8..49f5a3ce 100755 --- a/build-and-run.sh +++ b/build-and-run.sh @@ -1,7 +1,19 @@ -#!/bin/bash +#!/bin/sh -cd src -find . -type f -name '*.class' -delete -javac -cp . mochadoom/Engine.java -java mochadoom/Engine $@ +BUILD_DIR=build +CLASSES_DIR=$BUILD_DIR/classes +SOURCES_DIR=src + +# clean +echo "Clean build directory: $BUILD_DIR..." +rm -r $BUILD_DIR + +# compile +echo "Compile files from: $SOURCES_DIR..." +mkdir -p $CLASSES_DIR +javac -d $CLASSES_DIR -cp $SOURCES_DIR $SOURCES_DIR/mochadoom/Engine.java + +# run +echo "Run..." +java -cp $CLASSES_DIR mochadoom.Engine "$@" diff --git a/build-jar.sh b/build-jar.sh index 26b6f5d9..92e28adf 100755 --- a/build-jar.sh +++ b/build-jar.sh @@ -1,8 +1,22 @@ -#!/bin/bash +#!/bin/sh -cd src -find . -type f -name '*.class' -delete -javac -cp . mochadoom/Engine.java -jar cmf Manifest.txt mochadoom.jar . -zip -d mochadoom.jar *.java README.md Manifest.txt +BUILD_DIR=build +CLASSES_DIR=$BUILD_DIR/classes +LIBS_DIR=$BUILD_DIR/libs +SOURCES_DIR=src +JAR_NAME=mochadoom.jar + +# clean +echo "Clean build directory: $BUILD_DIR..." +rm -r $BUILD_DIR + +# compile +echo "Compile files from: $SOURCES_DIR..." +mkdir -p $CLASSES_DIR +mkdir -p $LIBS_DIR +javac -d $CLASSES_DIR -cp $SOURCES_DIR $SOURCES_DIR/mochadoom/Engine.java + +# jar +echo "Create jar file: $LIBS_DIR/$JAR_NAME..." +jar cmf $SOURCES_DIR/Manifest.txt $LIBS_DIR/$JAR_NAME -C $CLASSES_DIR . diff --git a/src/Manifest.txt b/src/Manifest.txt index cae6f5e7..8ed636c3 100644 --- a/src/Manifest.txt +++ b/src/Manifest.txt @@ -1 +1 @@ -Main-Class: mochadoom/Engine +Main-Class: mochadoom.Engine