Skip to content

Commit

Permalink
Update build scripts to use build folder
Browse files Browse the repository at this point in the history
* Use the same folder hierarchy as Gradle
* Fix manifest file
  • Loading branch information
gaborbata committed Oct 12, 2023
1 parent ba457a6 commit 26e7eaf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
22 changes: 17 additions & 5 deletions build-and-run.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

26 changes: 20 additions & 6 deletions build-jar.sh
Original file line number Diff line number Diff line change
@@ -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 .

2 changes: 1 addition & 1 deletion src/Manifest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main-Class: mochadoom/Engine
Main-Class: mochadoom.Engine

0 comments on commit 26e7eaf

Please sign in to comment.