Skip to content

Commit

Permalink
Convert to Gradle Project
Browse files Browse the repository at this point in the history
  • Loading branch information
Baw-Appie committed Nov 26, 2024
1 parent bab8b1b commit d102a89
Show file tree
Hide file tree
Showing 14 changed files with 475 additions and 162 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:
paths:
- "src/**/*.java"
- "__legacy__/**/*.java"
- "pom.xml"
- "build.gradle.kts"
- ".github/workflows/*"
pull_request:
branches: [ main ]
paths:
- "src/**/*.java"
- "__legacy__/**/*.java"
- "pom.xml"
- "build.gradle.kts"
- ".github/workflows/*"

jobs:
Expand Down Expand Up @@ -50,23 +50,20 @@ jobs:
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
cache: 'gradle'
- name: Setup Spigot Build Environment for ${{ matrix.mc-version }}
run: |
test -d BuildTools || mkdir BuildTools
cd BuildTools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev ${{ matrix.mc-version }}
cd ..
- name: Change target version to ${{ matrix.mc-version }}
run: |
./.github/workflow-files/change-ver.sh ${{ matrix.mc-version }}
- name: Build with Maven
run: mvn package
- name: Build with shadowJar
run: gradle shadowJar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: Agent-${{ matrix.mc-version }}.jar
# A file, directory or wildcard pattern that describes what to upload
path: target/**/*.jar
path: build/libs/*.jar
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ jobs:
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
- name: Setup Spigot Build Environment for ${{ matrix.mc-version }}
run: |
test -d BuildTools || mkdir BuildTools
cd BuildTools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev ${{ matrix.mc-version }}
cd ..
cache: 'gradle'
- name: Change target version to ${{ matrix.mc-version }}
run: |
./.github/workflow-files/change-ver.sh ${{ matrix.mc-version }}
- name: Update version of maven file to ${{ github.event.release.tag_name }}
run: mvn versions:set -DnewVersion=${VER_TAG:1}
env:
VER_TAG: ${{ github.event.release.tag_name }}
- name: Build with Maven
run: mvn package
- name: Setup Spigot Build Environment for ${{ matrix.mc-version }}
run: |
test -d BuildTools || mkdir BuildTools
cd BuildTools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev ${{ matrix.mc-version }}
cd ..
- name: Build with shadowJar
run: gradle shadowJar
- name: Rename package
run: |
mkdir releases
mv target/agent-${VER_TAG:1}.jar releases/agent-${VER_TAG:1}-mc${MC_VERSION}.jar
mv build/libs/agent-${VER_TAG:1}-all.jar releases/agent-${VER_TAG:1}-mc${MC_VERSION}.jar
test $UNSUPPORTED == "true" && mv releases/agent-${VER_TAG:1}-mc${MC_VERSION}.jar releases/agent-${VER_TAG:1}-mc${MC_VERSION}-unsupported.jar || exit 0
env:
VER_TAG: ${{ github.event.release.tag_name }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ fabric.properties

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

# Gradle
.gradle
build
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

11 changes: 4 additions & 7 deletions .idea/misc.xml

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

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

83 changes: 83 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This project uses @Incubating APIs which are subject to change.
*/

plugins {
java
id("com.github.johnrengelman.shadow") version "8.1.1"
}

repositories {
mavenLocal()
maven {
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}

maven {
url = uri("https://oss.sonatype.org/content/groups/public/")
}

maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
}

dependencies {
// Spigot API
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")

// This dependency is required for JSON Parsing
implementation("com.googlecode.json-simple:json-simple:1.1.1")

// This dependency is required for proper Websocket support
implementation("com.neovisionaries:nv-websocket-client:2.14")

// Nullable Support
implementation("org.jetbrains:annotations:16.0.1")

// System Info
implementation("com.github.oshi:oshi-core:6.4.0")

// Jackson JSON postprocessing
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.1")

// Apache IO since I am lazy to write all multiplexing stuff; TeeOutputStream
implementation("commons-io:commons-io:2.11.0")

// For Intercepting Log4J
compileOnly("org.apache.logging.log4j:log4j-core:2.17.2")
}

group = "kr.minehub.servers"
version = "0.0.1-ALPHA"
description = "ServerAgent"
java.sourceCompatibility = JavaVersion.VERSION_1_8

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

tasks {
val pluginYamlFile = file("src/main/resources/plugin.yml")
val outputDir = layout.buildDirectory.dir("resources/main")

val generatePluginYml by registering {
inputs.file(pluginYamlFile)
outputs.dir(outputDir)

doLast {
val pluginYamlText = pluginYamlFile.readText()
val updatedText = pluginYamlText.replace(Regex("\nversion:(.*)"), "\nversion: $version")
println("${outputDir.get()}\\plugin.yml")
outputDir.get().asFile.mkdirs()
file("${outputDir.get()}\\plugin.yml").writeText(updatedText)
}
}

processResources {
exclude("plugin.yml")
dependsOn(generatePluginYml)
}
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.parallel=true
org.gradle.caching=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.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit d102a89

Please sign in to comment.