Skip to content

Commit

Permalink
switch project to gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 5, 2024
1 parent 9ef1a58 commit f761116
Show file tree
Hide file tree
Showing 12 changed files with 639 additions and 228 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and upload jar

on:
push:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}-

- name: Build with Gradle
run: ./gradlew clean build

- name: Upload Build Artifact
uses: actions/[email protected]
with:
# Artifact name
name: SnowballFight
# A file, directory or wildcard pattern that describes what to upload
path: build/libs/*.jar
20 changes: 0 additions & 20 deletions .github/workflows/maven-publish.yml

This file was deleted.

120 changes: 116 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,123 @@
# Java
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/

# Compiled class file
*.class
*.jar

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Maven
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

target/

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next

release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

# Gradle
.gradle/
build/

# IntelliJ
.idea
*.iml

# Run Paper/Folia
run/

# Gradle
.gradle/
build/
118 changes: 118 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
plugins {
java
id("com.gradleup.shadow") version ("8.3.2")
id("io.papermc.paperweight.userdev") version ("1.7.4")
id("xyz.wagyourtail.jvmdowngrader") version ("1.2.0")
}

group = "me.xginko"
version = "1.3.2"
description = "Make snowball fights fun and engaging."

repositories {
mavenCentral()

maven("https://ci.pluginwiki.us/plugin/repository/everything/") {
name = "configmaster-repo"
}

maven("https://repo.codemc.io/repository/maven-releases/") {
name = "codemc-repo"
}

maven("https://repo.papermc.io/repository/maven-public/") {
name = "papermc-repo"
}

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

maven("https://mvn-repo.arim.space/lesser-gpl3/") {
name = "arim-mvn-lgpl3"
}
}

dependencies {
paperweight.foliaDevBundle("1.20.6-R0.1-SNAPSHOT");
compileOnly("org.apache.logging.log4j:log4j-core:2.23.1")

implementation("com.github.thatsmusic99:ConfigurationMaster-API:v2.0.0-rc.1")
implementation("com.github.ben-manes.caffeine:caffeine:2.9.3")
implementation("org.reflections:reflections:0.10.2")

implementation("space.arim.morepaperlib:morepaperlib:0.4.3")
implementation("com.github.cryptomorin:XSeries:11.3.0")
implementation("org.bstats:bstats-bukkit:3.0.2")

implementation("net.kyori:adventure-api:4.17.0")
implementation("net.kyori:adventure-text-serializer-ansi:4.17.0")
implementation("net.kyori:adventure-text-logger-slf4j:4.17.0")
implementation("net.kyori:adventure-text-minimessage:4.17.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
}

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

tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
}

javadoc {
options.encoding = Charsets.UTF_8.name()
}

build.configure {
dependsOn("shadowJar")
}

shadowJar {
archiveFileName.set("SnowballFight-${version}.jar")
relocate("io.github.thatsmusic99.configurationmaster", "me.xginko.snowballfight.libs.configmaster")
relocate("com.github.cryptomorin.xseries", "me.xginko.snowballfight.libs.xseries")
exclude(
"com/cryptomorin/xseries/XBiome*",
"com/cryptomorin/xseries/NMSExtras*",
"com/cryptomorin/xseries/NoteBlockMusic*",
"com/cryptomorin/xseries/SkullCacheListener*"
)
relocate("com.github.benmanes.caffeine", "me.xginko.snowballfight.libs.caffeine")
relocate("space.arim.morepaperlib", "me.xginko.snowballfight.libs.morepaperlib")
relocate("org.reflections", "me.xginko.snowballfight.libs.reflections")
relocate("org.bstats", "me.xginko.snowballfight.libs.bstats")
relocate("net.kyori", "me.xginko.snowballfight.libs.kyori")
}

processResources {
filesMatching("plugin.yml") {
expand(
mapOf(
"name" to project.name,
"version" to project.version,
"description" to project.description!!.replace('"'.toString(), "\\\""),
"url" to "https://github.com/xGinko/SnowballFight"
)
)
}
}

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(shadowJar.get())
from(zipTree(shadowJar.get().archiveFile))
finalizedBy("shadeDowngradedApi")
}

shadeDowngradedApi {
archiveFileName = shadowJar.get().archiveFileName
destinationDirectory = projectDir.resolve("build/libs")

downgradeTo = JavaVersion.VERSION_1_8
shadePath = { _ -> "me/xginko/shadow/jvmdowngrader" }
}
}
11 changes: 11 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Gradle properties
org.gradle.jvmargs=-Xmx2G -Xms256m -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.daemon=true

org.gradle.configureondemand=true
org.gradle.cache=true
org.gradle.caching=true
org.gradle.parallel=true

org.gradle.vfs.watch=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 f761116

Please sign in to comment.