-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pablo Herrera <[email protected]>
- Loading branch information
1 parent
7397d46
commit a86687f
Showing
31 changed files
with
576 additions
and
1,679 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins { | ||
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build. | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
// Use the plugin portal to apply community plugins in convention plugins. | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.0") | ||
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.0.BETA4") | ||
implementation("de.skuzzle.restrictimports:restrict-imports-gradle-plugin:2.6.0") | ||
} |
80 changes: 80 additions & 0 deletions
80
buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
plugins { | ||
`java-library` | ||
id("com.diffplug.spotless") | ||
id("de.skuzzle.restrictimports") | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven("https://oss.sonatype.org/content/repositories/snapshots/") // Snapshots | ||
maven("https://repo.viaversion.com/") // Viaversion | ||
maven("https://repo.pgm.fyi/snapshots") // Sportpaper & other pgm-specific stuff | ||
maven("https://repo.dmulloy2.net/repository/public/") // ProtocolLib repo | ||
maven("https://repo.papermc.io/repository/maven-public/") // Paper builds & paperweight plugin | ||
} | ||
|
||
dependencies { | ||
api("org.jdom:jdom2:2.0.6.1") | ||
api("net.kyori:adventure-api:4.17.0") | ||
api("net.kyori:adventure-text-serializer-plain:4.17.0") | ||
api("net.kyori:adventure-platform-bukkit:4.3.4") | ||
api("org.incendo:cloud-core:2.0.0") | ||
api("org.incendo:cloud-annotations:2.0.0") | ||
api("org.incendo:cloud-paper:2.0.0-beta.10") | ||
api("org.incendo:cloud-minecraft-extras:2.0.0-beta.10") | ||
api("me.lucko:commodore:2.2") | ||
api("fr.mrmicky:fastboard:2.1.3") | ||
api("fr.minuskube.inv:smart-invs:1.2.7") { exclude("*") } | ||
api("org.eclipse.jgit:org.eclipse.jgit:6.7.0.202309050840-r") { exclude("*") } | ||
api("net.objecthunter:exp4j:0.4.9-pgm") | ||
api("org.reflections:reflections:0.10.2") | ||
|
||
// Optional plugin deps | ||
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0") | ||
compileOnly("com.viaversion:viaversion-api:5.0.0") | ||
|
||
// Minecraft includes these (or equivalents) | ||
compileOnly("it.unimi.dsi:fastutil:8.1.0") | ||
compileOnly("com.google.guava:guava:17.0") | ||
compileOnly("com.google.code.gson:gson:2.10.1") | ||
compileOnly("commons-lang:commons-lang:2.6") | ||
} | ||
|
||
group = "tc.oc.pgm" | ||
version = "0.16-SNAPSHOT" | ||
description = "The original PvP Game Manager for Minecraft" | ||
|
||
tasks { | ||
withType<JavaCompile>() { | ||
options.encoding = "UTF-8" | ||
} | ||
withType<Javadoc>() { | ||
options.encoding = "UTF-8" | ||
} | ||
} | ||
|
||
spotless { | ||
ratchetFrom = "origin/dev" | ||
java { | ||
removeUnusedImports() | ||
palantirJavaFormat("2.47.0").style("GOOGLE").formatJavadoc(true) | ||
} | ||
} | ||
|
||
restrictImports { | ||
group { | ||
reason = "Use org.jetbrains.annotations to add annotations" | ||
bannedImports = listOf("javax.annotation.**") | ||
} | ||
group { | ||
reason = "Use tc.oc.pgm.util.Assert to add assertions" | ||
bannedImports = listOf("com.google.common.base.Preconditions.**", "java.util.Objects.requireNonNull") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import org.gradle.api.Project | ||
import java.io.ByteArrayOutputStream | ||
|
||
|
||
fun Project.latestCommitHash(): String { | ||
return runGitCommand(listOf("rev-parse", "--short", "HEAD")) | ||
} | ||
|
||
fun Project.runGitCommand(args: List<String>): String { | ||
val byteOut = ByteArrayOutputStream() | ||
exec { | ||
commandLine = listOf("git") + args | ||
standardOutput = byteOut | ||
} | ||
return byteOut.toString(Charsets.UTF_8.name()).trim() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
|
||
plugins { | ||
id("buildlogic.java-conventions") | ||
`maven-publish` | ||
id("com.gradleup.shadow") | ||
} | ||
|
||
dependencies { | ||
compileOnly("dev.pgm.paper:paper-api:1.8_1.21.1-SNAPSHOT") | ||
|
||
implementation(project(":util")) | ||
runtimeOnly(project(":platform-sportpaper")) { exclude("*") } | ||
runtimeOnly(project(":platform-modern")) { exclude("*") } | ||
} | ||
|
||
|
||
tasks.named<ShadowJar>("shadowJar") { | ||
manifest { | ||
attributes["paperweight-mappings-namespace"] = "mojang" | ||
} | ||
archiveFileName = "PGM.jar" | ||
destinationDirectory = rootProject.projectDir.resolve("build/libs") | ||
|
||
minimize { | ||
// Exclude from minimization as they're required at runtime | ||
exclude(project(":platform-sportpaper")) | ||
exclude(project(":platform-modern")) | ||
} | ||
|
||
dependencies { | ||
exclude(dependency("com.mojang:brigadier")) // Added by commodore | ||
// Several compile-only annotation dependencies | ||
exclude(dependency("org.jetbrains:annotations")) | ||
exclude(dependency("org.checkerframework:checker-qual")) | ||
exclude(dependency("org.apiguardian:apiguardian-api")) | ||
} | ||
|
||
fun pgmRelocate(basePckg: String) = relocate(basePckg, "tc.oc.pgm.lib.$basePckg") | ||
|
||
pgmRelocate("org.incendo.cloud") | ||
pgmRelocate("io.leangen.geantyref") | ||
pgmRelocate("me.lucko.commodore") | ||
pgmRelocate("fr.mrmicky") | ||
pgmRelocate("org.jdom2") | ||
pgmRelocate("org.eclipse.jgit") | ||
pgmRelocate("org.slf4j") | ||
|
||
exclude("META-INF/**") | ||
exclude("**/*.html") | ||
exclude("javax/**") // Unsure why this is even added | ||
|
||
// Trim unused parts of javassist | ||
exclude("javassist/bytecode/analysis/**") | ||
exclude("javassist/bytecode/stackmap/**") | ||
exclude("javassist/compiler/**") | ||
} | ||
|
||
publishing { | ||
publications.create<MavenPublication>("pgm") { | ||
groupId = rootProject.group as String | ||
artifactId = project.name | ||
version = rootProject.version as String | ||
|
||
artifact(tasks["shadowJar"]) | ||
} | ||
repositories { | ||
maven { | ||
name = "ghPackages" | ||
url = uri("https://github.com/PGMDev/PGM") | ||
credentials { | ||
username = System.getenv("GITHUB_ACTOR") | ||
password = System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks { | ||
processResources { | ||
filesMatching(listOf("plugin.yml")) { | ||
expand( | ||
"name" to project.name, | ||
"description" to project.description, | ||
"mainClass" to "tc.oc.pgm.PGMPlugin", | ||
"version" to project.version, | ||
"commitHash" to project.latestCommitHash(), | ||
"url" to "https://pgm.dev/") | ||
} | ||
} | ||
|
||
named("build") { | ||
dependsOn(shadowJar) | ||
} | ||
} |
Oops, something went wrong.