Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Build

on:
push:
branches:
- master
- feat/**
pull_request:
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Build executable jar (${{ matrix.os }})
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build and test
run: ./gradlew --no-daemon build
shell: bash

- name: Upload executable jar
uses: actions/upload-artifact@v4
with:
name: oopang-executable-jar-${{ matrix.os }}
path: build/libs/*-all.jar
if-no-files-found: error


release:
name: Create release if version changed
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Read Gradle version
id: version
run: |
VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Check latest release
id: release_check
env:
GH_TOKEN: ${{ github.token }}
run: |
CURRENT="v${{ steps.version.outputs.version }}"

LATEST=$(gh release view --json tagName -q .tagName 2>/dev/null || echo "")

echo "Current: $CURRENT"
echo "Latest: $LATEST"

if [ "$CURRENT" != "$LATEST" ]; then
echo "needs_release=true" >> "$GITHUB_OUTPUT"
else
echo "needs_release=false" >> "$GITHUB_OUTPUT"
fi

- name: Create git tag
if: steps.release_check.outputs.needs_release == 'true'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com

git tag "v${VERSION}"
git push origin "v${VERSION}"

- name: Download artifacts
if: steps.release_check.outputs.needs_release == 'true'
uses: actions/download-artifact@v4
with:
path: release-assets

- name: Create GitHub Release
if: steps.release_check.outputs.needs_release == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
files: |
release-assets/**/*
env:
GITHUB_TOKEN: ${{ github.token }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/bin/
/doc/
/doc/
/build/
/.gradle/
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ There are two game modes:
Keep playing to gain xp Points and reach rank 10. Every rank is rewarded with coins to upgrade your powers.

### How do I get set up? ###
1. Install the Java Runtime environment [here](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
2. Download OOPang.jar in the *Downloads* section
3. Doubleclick to launch application
4. Enjoy!
1. Install a Java 17 or newer JDK.
2. Build the executable jar with Gradle:
```sh
./gradlew build
```
3. Run the generated jar:
```sh
java -jar build/libs/oop-ang-1.0.0-all.jar
```

The project uses OpenJFX through Gradle because JavaFX is no longer bundled with the JDK after Java 8.

### Makers ###
* Samuele Burattini
Expand All @@ -29,4 +36,4 @@ Keep playing to gain xp Points and reach rank 10. Every rank is rewarded with co
* Lorenzo Menghini
* Francesca Tonetti

This project was realized for the Object Oriented Programming course in Computer Science and Engineering department of UniBo, Cesena.
This project was realized for the Object Oriented Programming course in Computer Science and Engineering department of UniBo, Cesena.
84 changes: 84 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
plugins {
id 'application'
id 'java'
id 'org.openjfx.javafxplugin' version '0.1.0'
}

group = 'oopang'
version = '1.1.0'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

javafx {
version = '21.0.6'
modules = ['javafx.controls', 'javafx.fxml']
}

application {
mainClass = 'oopang.Launcher'
}

sourceSets {
main {
java {
srcDirs = ['src']
exclude 'test/**'
}
resources {
srcDirs = ['res']
}
}
test {
java {
srcDirs = ['src/test']
}
}
}

dependencies {
implementation files('lib/dyn4j-3.2.4.jar')
implementation 'com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11'

testImplementation 'junit:junit:4.13.2'
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

tasks.named('test') {
useJUnit()
}

tasks.named('jar') {
manifest {
attributes 'Main-Class': application.mainClass.get()
}
}

tasks.register('fatJar', Jar) {
group = 'build'
description = 'Builds an executable jar with runtime dependencies.'

archiveClassifier = 'all'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

from sourceSets.main.output
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}

exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'

manifest {
attributes 'Main-Class': application.mainClass.get()
}
}

tasks.named('build') {
dependsOn tasks.named('fatJar')
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading