Skip to content

Commit

Permalink
Gradle (#35)
Browse files Browse the repository at this point in the history
* Update .gitignore

* Switch over builds

* Changing permission of gradlew
  • Loading branch information
TylerS1066 authored Jul 4, 2024
1 parent 6c22594 commit af88c2b
Show file tree
Hide file tree
Showing 11 changed files with 517 additions and 211 deletions.
117 changes: 49 additions & 68 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,64 @@

name: Java CI
name: Gradle CI

on:
on:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: '22 20 * * 6'
release:
types: [created, prereleased]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout Movecraft-Warfare
uses: actions/checkout@v2
with:
path: Movecraft-Warfare
- name: Checkout Movecraft-Repair
uses: actions/checkout@v2
with:
repository: 'APDevTeam/Movecraft-Repair'
path: Movecraft-Repair
ref: main
- name: Checkout Movecraft-Combat
uses: actions/checkout@v2
with:
repository: 'TylerS1066/Movecraft-Combat'
path: Movecraft-Combat
ref: main
- name: Checkout Movecraft-WorldGuard
uses: actions/checkout@v2
with:
repository: 'APDevTeam/Movecraft-WorldGuard'
path: Movecraft-WorldGuard
ref: main
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Cache Maven packages
id: cacheMain
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2
- name: Checkout Movecraft-Warfare
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"

# Build Movecraft-Repair
- name: Build Movecraft-Repair
run: mvn -B package -T 1C --file Movecraft-Repair/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Gradle
run: ./gradlew clean build --parallel

# Build Movecraft-Combat
- name: Build Movecraft-Combat
run: mvn -B package -T 1C --file Movecraft-Combat/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub Packages
if: ${{ github.event_name == 'release' }}
run: ./gradlew publish --parallel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Build Movecraft-WorldGuard
- name: Build Movecraft-WorldGuard
run: mvn -B package -T 1C --file Movecraft-WorldGuard/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PaperMC Hangar
if: ${{ github.event_name == 'release' }}
run: ./gradlew publishPluginPublicationToHangar --parallel
env:
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}

# Build Movecraft-Warfare
- name: Build Movecraft-Warfare
run: mvn -B package -T 1C --file Movecraft-Warfare/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stage jar for Actions
if: ${{ github.event_name != 'release' }}
run: mkdir staging && cp build/libs/Movecraft-Warfare.jar staging && mv staging/Movecraft-Warfare.jar staging/Movecraft-Warfare_$GITHUB_SHA.jar
- name: Upload jar to Actions
if: ${{ github.event_name != 'release' }}
uses: actions/upload-artifact@v4
with:
name: Movecraft-Warfare_Dev-Build
path: staging/Movecraft-Warfare_*.jar

- name: Stage jar
run: mkdir staging && cp Movecraft-Warfare/target/Movecraft-Warfare.jar staging
- name: Rename jar
run: mv staging/Movecraft-Warfare*.jar staging/Movecraft-Warfare_$GITHUB_SHA.jar
- name: Upload jar
uses: actions/upload-artifact@v2
with:
name: Movecraft-Warfare_Dev-Build
path: staging/Movecraft-Warfare_*.jar
- name: Stage jar for Release
if: ${{ github.event_name == 'release' }}
run: mkdir staging && cp build/libs/Movecraft-Warfare.jar staging && mv staging/Movecraft-Warfare.jar staging/Movecraft-Warfare_${{ github.event.release.tag_name }}.jar
- name: Upload jar to Release
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v2
with:
files: staging/Movecraft-Warfare_${{ github.event.release.tag_name }}.jar
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,26 @@ hs_err_pid*
target/*
libs/*
.vscode/

### GitHub example for gradle
.gradle
**/build/
!src/**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties

# Cache of project
.gradletasknamecache

# Eclipse Gradle plugin generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Movecraft-Warfare Addon
![Warfare](https://github.com/APDevTeam/Movecraft-Warfare/actions/workflows/maven.yml/badge.svg)
![Warfare](https://github.com/APDevTeam/Movecraft-Warfare/actions/workflows/gradle.yml/badge.svg)

Home of the code for the following features:
- Siege
Expand All @@ -11,19 +11,18 @@ The `legacy` branch is coded for 1.10.2 to 1.16.5 and Movecraft 7.x.
The `main` branch is coded for 1.14.4+ and Movecraft 8.x.

## Download
Devevlopment builds can be found on the [GitHub Actions tab](https://github.com/APDevTeam/Movecraft-Warfare/actions) of this repository.
Releases can be found on the [releases tab](https://github.com/APDevTeam/Movecraft-Warfare/releases).

Stable builds can be found on [our SpigotMC page](https://www.spigotmc.org/resources/movecraft-warfare.87359/).
Development builds can be found on the [GitHub Actions tab](https://github.com/APDevTeam/Movecraft-Warfare/actions) of this repository.

## Building
This plugin requires that the user setup and build their [Movecraft-Repair](https://github.com/APDevTeam/Movecraft-Repair), [Movecraft-Combat](https://github.com/TylerS1066/Movecraft-Combat), and [Movecraft-WorldGuard](https://github.com/APDevTeam/Movecraft-WorldGuard) development environments, and then clone this into the same folder as your Movecraft development environment such that both Movecraft-Warfare and Movecraft are contained in the same folder.
Previous builds can be found on[our SpigotMC page](https://www.spigotmc.org/resources/movecraft-warfare.87359/).

Then, run the following to build Movecraft-Warfare through `maven`.
## Building
Run the following to build Movecraft-Warfare:
```
mvn clean install
./gradlew clean build --parallel
```
Jars are located in `/target`.

Jars are located in `/build/libs` directory.

## Support
[Github Issues](https://github.com/APDevTeam/Movecraft-Warfare/issues)
Expand Down
86 changes: 86 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
plugins {
`java-library`
`maven-publish`
id("io.github.0ffz.github-packages") version "1.2.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}

repositories {
gradlePluginPortal()
mavenLocal()
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven { githubPackage("apdevteam/movecraft")(this) }
maven { githubPackage("apdevteam/movecraft-repair")(this) }
maven { githubPackage("apdevteam/movecraft-worldguard")(this) }
maven("https://jitpack.io")
}

dependencies {
api("org.jetbrains:annotations-java5:24.1.0")
compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("net.countercraft:movecraft:+")
compileOnly("net.countercraft.movecraft.repair:movecraft-repair:+")
compileOnly("net.countercraft.movecraft.worldguard:movecraft-worldguard:+")
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
}

group = "net.countercraft.movecraft.warfare"
version = "1.0.0_beta-3"
description = "Movecraft-Warfare"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.jar {
archiveBaseName.set("Movecraft-Warfare")
archiveClassifier.set("")
archiveVersion.set("")
}

tasks.processResources {
from(rootProject.file("LICENSE.md"))
filesMatching("*.yml") {
expand(mapOf("projectVersion" to project.version))
}
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "net.countercraft.movecraft.warfare"
artifactId = "movecraft-warfare"
version = "${project.version}"

artifact(tasks.jar)
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/apdevteam/movecraft-warfare")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

hangarPublish {
publications.register("plugin") {
version.set(project.version as String)
channel.set("Release")
id.set("Airship-Pirates/Movecraft-Warfare")
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
platforms {
register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) {
jar.set(tasks.jar.flatMap { it.archiveFile })
platformVersions.set(listOf("1.18.2-1.21"))
dependencies {
hangar("Movecraft") {
required.set(true)
}
}
}
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit af88c2b

Please sign in to comment.