Update build script with the juicy toys

This commit is contained in:
Ryder Belserion 2023-02-06 01:58:02 -05:00
parent 6aca5269ef
commit 64cb1aae55
No known key found for this signature in database
GPG Key ID: CA602465429CF065
17 changed files with 480 additions and 93 deletions

View File

@ -7,12 +7,14 @@ repositories {
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21")
implementation(tools.jetbrains)
implementation(tools.license)
implementation(tools.shadowJar)
// For the webhook tasks, this applies to the build-logic only
implementation("io.ktor:ktor-client-core:2.2.2")
implementation("io.ktor:ktor-client-cio:2.2.2")
implementation("io.ktor:ktor-client-content-negotiation:2.2.2")
implementation("io.ktor:ktor-serialization-gson:2.2.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation(tools.ktor.gson)
implementation(tools.ktor.core)
implementation(tools.ktor.cio)
implementation(tools.ktor.cn)
implementation(tools.kotlinx)
}

View File

@ -1,5 +1,11 @@
@file:Suppress("UnstableApiUsage")
dependencyResolutionManagement {
versionCatalogs {
create("tools") {
from(files("../gradle/tools.versions.toml"))
}
}
repositories.gradlePluginPortal()
}

View File

@ -0,0 +1,28 @@
plugins {
`java-library`
`maven-publish`
id("com.github.hierynomus.license")
id("com.github.johnrengelman.shadow")
}
license {
header = rootProject.file("LICENSE")
encoding = "UTF-8"
mapping("java", "JAVADOC_STYLE")
include("**/*.java")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(project.properties["java_version"].toString()))
}
tasks {
compileJava {
options.release.set(project.properties["java_version"].toString().toInt())
}
}

View File

@ -1,41 +1,17 @@
plugins {
id("crazyauctions.common-plugin")
id("crazyauctions.root-plugin")
}
repositories {
/**
* PAPI Team
*/
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
exclusiveContent {
forRepository {
maven("https://repo.papermc.io/repository/maven-public/")
}
/**
* NBT Team
*/
maven("https://repo.codemc.org/repository/maven-public/")
/**
* Paper Team
*/
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
implementation(project(":common"))
implementation("dev.triumphteam", "triumph-cmd-bukkit", "2.0.0-SNAPSHOT")
implementation("com.ryderbelserion.ithildin", "ithildin-core", "0.0.1")
implementation("org.bstats", "bstats-bukkit", "3.0.0")
compileOnly("io.papermc.paper", "paper-api", "${project.extra["minecraft_version"]}-R0.1-SNAPSHOT")
compileOnly("com.github.decentsoftware-eu", "decentholograms", "2.7.8")
compileOnly("com.github.MilkBowl", "VaultAPI", "1.7")
compileOnly("me.clip", "placeholderapi", "2.11.2") {
exclude(group = "org.spigotmc", module = "spigot")
exclude(group = "org.bukkit", module = "bukkit")
filter {
includeGroup("io.papermc.paper")
includeGroup("com.mojang")
includeGroup("net.md-5")
}
}
}

View File

@ -2,11 +2,19 @@ import task.ReleaseWebhook
import task.WebhookExtension
plugins {
`java-library`
id("crazyauctions.base-plugin")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(project.extra["java_version"].toString().toInt()))
repositories {
maven("https://repo.triumphteam.dev/snapshots/")
maven("https://repo.crazycrew.us/plugins/")
maven("https://libraries.minecraft.net/")
maven("https://jitpack.io/")
mavenCentral()
}
tasks {
@ -14,11 +22,7 @@ tasks {
val webhookExtension = extensions.create("webhook", WebhookExtension::class)
// Register the task
register<ReleaseWebhook>("releaseWebhook") {
register<ReleaseWebhook>("webhook") {
extension = webhookExtension
}
compileJava {
options.release.set(project.extra["java_version"].toString().toInt())
}
}

View File

@ -15,7 +15,6 @@ import kotlinx.coroutines.runBlocking
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.extra
/** Task to send webhooks to discord. */
abstract class ReleaseWebhook : DefaultTask() {

View File

@ -2,6 +2,9 @@ package task
import com.google.gson.annotations.SerializedName
import java.awt.Color
import java.io.UnsupportedEncodingException
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@ -39,6 +42,26 @@ abstract class WebhookExtension {
)
}
class Gravatar {
private fun hexCode(array: ByteArray): String {
val sb = StringBuffer()
for (i in array.indices) {
sb.append(Integer.toHexString((array[i].toInt() and 0xFF) or 0x100).substring(1, 3))
}
return sb.toString()
}
fun md5Hex(message: String): String? {
try {
val md = MessageDigest.getInstance("MD5")
return hexCode(md.digest(message.toByteArray(charset("CP1252"))))
} catch (_: NoSuchAlgorithmException) {} catch (_: UnsupportedEncodingException) { }
return null
}
}
class EmbedsBuilder {
private val embeds: MutableList<Embed> = mutableListOf()

View File

@ -1,3 +1,4 @@
import task.WebhookExtension
import java.awt.Color
plugins {
@ -6,47 +7,46 @@ plugins {
val legacyUpdate = Color(255, 73, 110)
val releaseUpdate = Color(27, 217, 106)
val snapshotUpdate = Color(255, 163, 71)
val betaUpdate = Color(255, 163, 71)
val commitMessage: String? = System.getenv("COMMIT_MESSAGE")
val isBeta: Boolean = extra["isBeta"].toString().toBoolean()
val isBeta = settings.versions.projectBeta.get().toBoolean()
val projectVersion = settings.versions.projectVersion.get()
val projectName = settings.versions.projectName.get()
val projectExt = settings.versions.projectExtension.get()
val finalVersion = if (isBeta) "$projectVersion+Beta" else projectVersion
val projectNameLowerCase = projectName.toLowerCase()
val color = if (isBeta) betaUpdate else releaseUpdate
val repo = if (isBeta) "beta" else "releases"
webhook {
this.avatar("https://cdn.discordapp.com/avatars/209853986646261762/eefe3c03882cbb885d98107857d0b022.png")
this.avatar("https://en.gravatar.com/avatar/${WebhookExtension.Gravatar().md5Hex("no-reply@ryderbelserion.com")}.jpeg")
this.username("Ryder Belserion")
//this.content("New version of ${rootProject.name} is ready! <@929463441159254066>")
this.content("New version of ${rootProject.name} is ready!")
this.content("New version of $projectName is ready! <@&929463441159254066>")
this.embeds {
this.embed {
if (isBeta) this.color(snapshotUpdate) else this.color(releaseUpdate)
this.color(color)
this.fields {
this.field(
"Version ${project.version}",
"Download Link: https://modrinth.com/plugin/${rootProject.name.toLowerCase()}/version/${project.version}"
"Version $finalVersion",
"Download Link: https://modrinth.com/$projectExt/$projectNameLowerCase/version/$finalVersion"
)
if (isBeta) {
if (commitMessage != null) this.field("Commit Message", commitMessage)
this.field("Snapshots", "They will be hosted on the same page labeled as `Beta`")
this.field(
"API Update",
"Version ${project.version} has been pushed to https://repo.crazycrew.us/#/snapshots/"
)
}
if (!isBeta) this.field("API Update","Version ${project.version} has been pushed to https://repo.crazycrew.us/#/releases/")
this.field(
"API Update",
"Version $finalVersion has been pushed to https://repo.crazycrew.us/#/$repo"
)
}
this.author(
rootProject.name,
"https://modrinth.com/plugin/${rootProject.name.toLowerCase()}/versions",
projectName,
"https://modrinth.com/$projectExt/$projectNameLowerCase/versions",
"https://cdn-raw.modrinth.com/data/r3BBZyf3/4522ef0f83143c4803473d356160a3e877c2499c.png"
)
}

22
core/build.gradle.kts Normal file
View File

@ -0,0 +1,22 @@
plugins {
id("crazyauctions.root-plugin")
}
val projectBeta = settings.versions.projectBeta.get().toBoolean()
val projectVersion = settings.versions.projectVersion.get()
val projectName = settings.versions.projectName.get()
val finalVersion = if (projectBeta) "$projectVersion+beta" else projectVersion
project.version = finalVersion
dependencies {
//compileOnly(libs.adventure.api)
//compileOnly(libs.adventure.text)
}
tasks {
shadowJar {
archiveFileName.set("$projectName+core+$finalVersion.jar")
}
}

45
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,45 @@
[versions]
# Minecraft
paper = "1.19.3-R0.1-SNAPSHOT"
# Adventure
adventure = "4.12.0"
# RubyCore
ruby = "0.0.1"
[libraries]
# Minecraft
papermc = { module = "io.papermc.paper:paper-api", version.ref = "paper" }
# Adventure
adventure_api = { module = "net.kyori:adventure-api", version.ref = "adventure" }
adventure_text = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" }
# RubyCore
ruby_api = { module = "net.dehya.ruby:ruby-core", version.ref = "ruby" }
ruby_paper = { module = "net.dehya.ruby:ruby-paper", version.ref = "ruby" }
# Configurations
yaml = { module = "me.carleslc.Simple-YAML:Simple-Yaml", version = "1.8.3" }
# Triumph Team
triumph_cmds = { module = "dev.triumphteam:triumph-cmd-bukkit", version = "2.0.0-SNAPSHOT" }
triumph_gui = { module = "dev.triumphteam:triumph-gui", version = "3.1.2" }
# Misc
bstats_bukkit = { module = "org.bstats:bstats-bukkit", version = "3.0.0" }
vault_api = { module = "com.github.MilkBowl:VaultAPI", version = "1.7" }
# Holograms
holographic_displays = { module = "me.filoghost.holographicdisplays:holographicdisplays-api", version = "3.0.0" }
decent_holograms = { module = "com.github.decentsoftware-eu:decentholograms", version = "2.7.8" }
cmi_api = { module = "com.Zrips.CMI:CMI-API", version = "9.2.6.1" }
cmi_lib = { module = "net.Zrips.CMILib:CMI-Lib", version = "1.2.4.1" }
# Placeholders
placeholder_api = { module = "me.clip:placeholderapi", version = "2.11.2" }

View File

@ -0,0 +1,16 @@
[versions]
# Project Settings
projectVersion = "1.11.14.1"
projectGroup = "com.badbones69.crazyauctions"
projectName = "CrazyAuctions"
projectDescription = "Auction off your items in style!"
projectGithub = "https://github.com/Crazy-Crew/CrazyAuctions"
projectBeta = "true"
projectExtension = "plugin"
[plugins]
minotaur = { id = "com.modrinth.minotaur", version = "2.6.0" }
run-paper = { id = "xyz.jpenilla.run-paper", version = "2.0.0" }

View File

@ -0,0 +1,20 @@
[versions]
# Gradle
shadow = "7.1.2"
ktor = "2.2.2"
kotlin = "1.7.21"
license = "0.16.1"
coroutines = "1.6.4"
[libraries]
jetbrains = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
license = { module = "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin", version.ref = "license" }
shadowJar = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "shadow" }
ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-cn = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-gson = { module = "io.ktor:ktor-serialization-gson", version.ref = "ktor"}
kotlinx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines"}

View File

@ -1,16 +0,0 @@
name: "CrazyAuctions"
main: "${group}"
authors: [BadBones69, RyderBelserion]
version: ${version}
api-version: "1.18"
description: ${description}
softdepend: [Vault, PlaceholderAPI]
website: https://modrinth.com/plugin/crazyauctions
commands:
crazyauctions:
description: The base command for Crazy Auctions

View File

@ -0,0 +1,173 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("crazyauctions.paper-plugin")
alias(settings.plugins.minotaur)
alias(settings.plugins.run.paper)
}
repositories {
/**
* PAPI Team
*/
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
exclusiveContent {
forRepository {
maven("https://repo.crazycrew.us/libraries")
}
filter {
includeGroup("net.dehya")
}
}
}
dependencies {
//api(project(":crazyauctions-core"))
compileOnly(libs.papermc)
}
val projectDescription = settings.versions.projectDescription.get()
val projectGithub = settings.versions.projectGithub.get()
val projectGroup = settings.versions.projectGroup.get()
val projectName = settings.versions.projectName.get()
val projectExt = settings.versions.projectExtension.get()
val isBeta = settings.versions.projectBeta.get().toBoolean()
val projectVersion = settings.versions.projectVersion.get()
val finalVersion = if (isBeta) "$projectVersion+Beta" else projectVersion
val projectNameLowerCase = projectName.toLowerCase()
val repo = if (isBeta) "beta" else "releases"
val type = if (isBeta) "beta" else "release"
tasks {
shadowJar {
archiveFileName.set("${projectName}+$finalVersion.jar")
listOf(
"org.bstats"
).forEach { relocate(it, "$projectGroup.plugin.library.$it") }
}
runServer {
minecraftVersion("1.19.3")
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(projectNameLowerCase)
versionName.set("$projectName $finalVersion")
versionNumber.set(finalVersion)
versionType.set(type)
uploadFile.set(shadowJar.get())
autoAddDependsOn.set(true)
gameVersions.addAll(
listOf(
"1.17",
"1.17.1",
"1.18",
"1.18.1",
"1.18.2",
"1.19",
"1.19.1",
"1.19.2",
"1.19.3"
)
)
loaders.addAll(listOf("paper", "purpur"))
//<h3>The first release for CrazyAuctions on Modrinth! 🎉🎉🎉🎉🎉<h3><br> If we want a header.
changelog.set(
"""
<h4>Changes:</h4>
<p>N/A</p>
<h4>Under the hood changes</h4>
<p>N/A</p>
<h4>Bug Fixes:</h4>
<p>N/A</p>
""".trimIndent()
)
}
processResources {
filesMatching("plugin.yml") {
expand(
"name" to projectName,
"group" to projectGroup,
"version" to finalVersion,
"description" to projectDescription,
"website" to "https://modrinth.com/$projectExt/$projectNameLowerCase"
)
}
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = projectGroup
artifactId = "$projectNameLowerCase-paper"
version = finalVersion
from(components["java"])
pom {
name.set(projectName)
description.set(projectDescription)
url.set(projectGithub)
licenses {
license {
name.set("MIT License")
url.set("https://www.opensource.org/licenses/mit-license.php")
}
}
developers {
developer {
id.set("ryderbelserion")
name.set("Ryder Belserion")
}
developer {
id.set("badbones69")
name.set("BadBones69")
}
}
scm {
connection.set("scm:git:git://github.com/Crazy-Crew/$projectName.git")
developerConnection.set("scm:git:ssh://github.com/Crazy-Crew/$projectName.git")
url.set(projectGithub)
}
}
}
}
repositories {
maven("https://repo.crazycrew.us/$repo") {
name = "crazycrew"
// Used for locally publishing.
// credentials(PasswordCredentials::class)
credentials {
username = System.getenv("REPOSITORY_USERNAME")
password = System.getenv("REPOSITORY_PASSWORD")
}
}
}
}

View File

@ -0,0 +1,28 @@
package com.badbones69.crazyauctions;
import org.bukkit.plugin.java.JavaPlugin;
public class CrazyAuctions extends JavaPlugin {
private static CrazyAuctions plugin;
public CrazyAuctions() {
super();
plugin = this;
}
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
public static CrazyAuctions getPlugin() {
return plugin;
}
}

View File

@ -0,0 +1,16 @@
name: "CrazyCrates"
main: "${group}.CrazyAuctions"
authors: [BadBones69, RyderBelserion]
version: ${version}
api-version: "1.17"
description: ${description}
website: ${website}
softdepend: [CMI, HolographicDisplays, DecentHolograms, PlaceholderAPI]
commands:
crazyauctions:
description: The base command for Crazy Auctions
aliases: [ca, ah, crazyauction]

View File

@ -1,14 +1,59 @@
rootProject.name = extra["name"] as String
dependencyResolutionManagement {
includeBuild("build-logic")
versionCatalogs {
create("settings") {
from(files("gradle/settings.versions.toml"))
}
}
repositories.gradlePluginPortal()
}
pluginManagement {
repositories {
gradlePluginPortal()
maven("https://papermc.io/repo/repository/maven-public/")
gradlePluginPortal()
mavenCentral()
}
}
include("paper", "common")
val lowerCase = rootProject.name.toLowerCase()
include("core")
project(":core").name = "$lowerCase-core"
listOf("paper").forEach(::includePlatform)
fun includeProject(name: String) {
include(name) {
this.name = "$lowerCase-$name"
}
}
fun includePlatform(name: String) {
include(name) {
this.name = "$lowerCase-platform-$name"
this.projectDir = file("platforms/$name")
}
}
fun includeModule(name: String) {
include(name) {
this.name = "$lowerCase-module-$name"
this.projectDir = file("modules/$name")
}
}
fun includePlatformModule(name: String, platform: String) {
include(name) {
this.name = "$lowerCase-module-$platform-$name"
this.projectDir = file("modules/$platform/$name")
}
}
fun include(name: String, block: ProjectDescriptor.() -> Unit) {
include(name)
project(":$name").apply(block)
}