From 80ee7ea55fe446524dd5a695ad53b043122d08db Mon Sep 17 00:00:00 2001 From: Gabor Bata Date: Wed, 27 Sep 2023 11:26:38 +0200 Subject: [PATCH] Gradle build tool support --- .github/workflows/gradle.yml | 36 ++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ README.md | 10 ++++++++++ build.gradle | 29 +++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 .github/workflows/gradle.yml create mode 100644 build.gradle diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 00000000..b3c048a2 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,36 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + gradle-version: 8.3 + arguments: build + diff --git a/.gitignore b/.gitignore index 347bb6f4..56596baf 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ dist/ *.dsg build.xml nbproject/ +.gradle +mochadoom.cfg # Intellij *.iml diff --git a/README.md b/README.md index 2af0a815..a824d3c1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,16 @@ On Linux, two different scripts can be used. 1. `build-and-run.sh` which will build Mocha Doom and run it. You can use it as such: `./build-and-run.sh -iwad ~/DOOM2.WAD`. This is the preferred way to quickly test changes for developers. 2. `build-jar.sh` which will build a JAR file. You can then run the JAR file as such: `java -jar mochadoom.jar -iwad ~/DOOM2.WAD`. This is the preferred way for distributing a Mocha Doom executable. +### Build with Gradle + +[Gradle](https://gradle.org/) is a cross-platform build tool, which can be also used to run and build Mocha Doom. +First of all, you have to install Gradle following its [installation notes](https://gradle.org/install/). After that you can use the following commands: + +* Run Mocha Doom: `gradle clean run` +* Build a JAR file: `gradle clean build` + This creates a JAR file in the `build/libs/` folder. + You can then run the JAR file as such: `java -jar build/libs/mochadoom.jar -iwad ~/DOOM.WAD`. + # License Mocha Doom contains work from many contributors. Here are the main contributors, but it's no limited to this list. Others are listed in the copyright headers of the files where they own copyright. diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..d9ebe4e1 --- /dev/null +++ b/build.gradle @@ -0,0 +1,29 @@ +plugins { + id 'application' +} + +apply plugin: 'java' + +sourceSets { + main { + java { + srcDirs = ['src'] + } + } +} + +ext { + javaMainClass = 'mochadoom.Engine' +} + +jar { + archiveBaseName = 'mochadoom' + manifest { + attributes('Main-Class': javaMainClass) + } +} + +application { + mainClass.set(javaMainClass) +} +