mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-25 12:25:20 +01:00
[ci-skip] Move mover values to gradle.properties
This commit is contained in:
parent
48d055d982
commit
89d4f02982
18
.github/workflows/auto-assign.yml
vendored
18
.github/workflows/auto-assign.yml
vendored
@ -1,18 +0,0 @@
|
||||
name: Auto Assign
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited, labeled, unlabeled]
|
||||
pull_request:
|
||||
types: [opened, edited, labeled, unlabeled]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: wow-actions/auto-assign@v2
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
reviewers: |
|
||||
RyderBelserion
|
||||
assignees: RyderBelserion
|
@ -8,4 +8,11 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21")
|
||||
|
||||
// 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")
|
||||
}
|
@ -17,11 +17,11 @@ repositories {
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(extra["java_version"].toString().toInt()))
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.release.set(17)
|
||||
options.release.set(extra["java_version"].toString().toInt())
|
||||
}
|
||||
}
|
@ -1,11 +1,7 @@
|
||||
plugins {
|
||||
id("crazyauctions-common")
|
||||
id("crazyauctions.common-plugin")
|
||||
}
|
||||
|
||||
project.version = "${extra["plugin_version"]}"
|
||||
project.group = "${extra["plugin_group"]}.CrazyAuctions"
|
||||
project.description = "Auction your items off in style!"
|
||||
|
||||
repositories {
|
||||
/**
|
||||
* PAPI Team
|
@ -0,0 +1,24 @@
|
||||
import task.ReleaseWebhook
|
||||
import task.WebhookExtension
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(extra["java_version"].toString().toInt()))
|
||||
}
|
||||
|
||||
tasks {
|
||||
// Creating the extension to be available on the root gradle
|
||||
val webhookExtension = extensions.create("webhook", WebhookExtension::class)
|
||||
|
||||
// Register the task
|
||||
register<ReleaseWebhook>("releaseWebhook") {
|
||||
extension = webhookExtension
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.release.set(extra["java_version"].toString().toInt())
|
||||
}
|
||||
}
|
52
build-logic/src/main/kotlin/task/ReleaseWebhook.kt
Normal file
52
build-logic/src/main/kotlin/task/ReleaseWebhook.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package task
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.client.request.headers
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.client.request.setBody
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpHeaders
|
||||
import io.ktor.http.append
|
||||
import io.ktor.serialization.gson.gson
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
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() {
|
||||
|
||||
/** Configured extension. */
|
||||
@get:Input
|
||||
lateinit var extension: WebhookExtension
|
||||
|
||||
/** Ktor client for easy requests. */
|
||||
private val client = HttpClient(CIO) {
|
||||
install(ContentNegotiation) {
|
||||
gson()
|
||||
}
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun webhook() {
|
||||
// The webhook url configured in the gradle.properties
|
||||
val url = System.getenv("DISCORD_WEBHOOK")
|
||||
|
||||
runBlocking(Dispatchers.IO) {
|
||||
val response = client.post(url) {
|
||||
headers {
|
||||
append(HttpHeaders.ContentType, ContentType.Application.Json)
|
||||
}
|
||||
|
||||
setBody(extension.build())
|
||||
}
|
||||
|
||||
// Should be using logger, but eh
|
||||
println("Webhook result: ${response.status}")
|
||||
}
|
||||
}
|
||||
}
|
190
build-logic/src/main/kotlin/task/WebhookExtension.kt
Normal file
190
build-logic/src/main/kotlin/task/WebhookExtension.kt
Normal file
@ -0,0 +1,190 @@
|
||||
package task
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.awt.Color
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
/** Extension to simplify customizing the webhook. */
|
||||
abstract class WebhookExtension {
|
||||
|
||||
private var content: String = ""
|
||||
private var username: String = ""
|
||||
private var avatar: String = ""
|
||||
private val embeds: MutableList<Embed> = mutableListOf()
|
||||
|
||||
fun content(content: String) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
fun username(username: String) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
fun avatar(avatar: String) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
fun embeds(builder: EmbedsBuilder.() -> Unit) {
|
||||
embeds.addAll(EmbedsBuilder().apply(builder).build())
|
||||
}
|
||||
|
||||
internal fun build(): Webhook {
|
||||
return Webhook(
|
||||
content,
|
||||
username,
|
||||
avatar,
|
||||
false,
|
||||
embeds.toList()
|
||||
)
|
||||
}
|
||||
|
||||
class EmbedsBuilder {
|
||||
private val embeds: MutableList<Embed> = mutableListOf()
|
||||
|
||||
fun embed(builder: EmbedBuilder.() -> Unit) {
|
||||
embeds.add(EmbedBuilder().apply(builder).build())
|
||||
}
|
||||
|
||||
internal fun build() = embeds.toList()
|
||||
}
|
||||
|
||||
class EmbedBuilder {
|
||||
private var title: String? = null
|
||||
private var description: String? = null
|
||||
private var url: String? = null
|
||||
private var timestamp: String = ""
|
||||
private var color: Int? = null
|
||||
private var footer: Footer? = null
|
||||
private var image: Image? = null
|
||||
private var thumbnail: Image? = null
|
||||
private var provider: Provider? = null
|
||||
private var author: Author? = null
|
||||
private var fields: List<Field>? = null
|
||||
|
||||
fun title(title: String) {
|
||||
this.title = title
|
||||
}
|
||||
|
||||
fun description(description: String) {
|
||||
this.description = description
|
||||
}
|
||||
|
||||
fun url(url: String) {
|
||||
this.url = url
|
||||
}
|
||||
|
||||
fun timestamp(date: LocalDateTime) {
|
||||
this.timestamp = date.format(DateTimeFormatter.ISO_DATE_TIME)
|
||||
}
|
||||
|
||||
fun color(color: Color) {
|
||||
this.color = color.toInt()
|
||||
}
|
||||
|
||||
fun footer(text: String, icon: String? = null) {
|
||||
this.footer = Footer(text, icon)
|
||||
}
|
||||
|
||||
fun image(url: String) {
|
||||
this.image = Image(url)
|
||||
}
|
||||
|
||||
fun thumbnail(url: String) {
|
||||
this.thumbnail = Image(url)
|
||||
}
|
||||
|
||||
fun provider(name: String? = null, url: String? = null) {
|
||||
this.provider = Provider(name, url)
|
||||
}
|
||||
|
||||
fun author(name: String, url: String? = null, icon: String? = null) {
|
||||
this.author = Author(name, url, icon)
|
||||
}
|
||||
|
||||
fun fields(builder: FieldsBuilder.() -> Unit) {
|
||||
this.fields = FieldsBuilder().apply(builder).build()
|
||||
}
|
||||
|
||||
internal fun build() = Embed(
|
||||
title,
|
||||
description,
|
||||
url,
|
||||
timestamp,
|
||||
color,
|
||||
footer,
|
||||
image,
|
||||
thumbnail,
|
||||
provider,
|
||||
author,
|
||||
fields,
|
||||
)
|
||||
}
|
||||
|
||||
class FieldsBuilder {
|
||||
private val fields: MutableList<Field> = mutableListOf()
|
||||
|
||||
fun field(name: String, value: String, inline: Boolean = false) {
|
||||
fields.add(Field(name, value, inline))
|
||||
}
|
||||
|
||||
internal fun build() = fields.toList()
|
||||
}
|
||||
|
||||
data class Webhook(
|
||||
val content: String,
|
||||
val username: String,
|
||||
@SerializedName("avatar_url") val avatarUrl: String,
|
||||
val tts: Boolean,
|
||||
val embeds: List<Embed>,
|
||||
)
|
||||
|
||||
data class Embed(
|
||||
val title: String?,
|
||||
val description: String?,
|
||||
val url: String?,
|
||||
val timestamp: String,
|
||||
val color: Int?,
|
||||
val footer: Footer?,
|
||||
val image: Image?,
|
||||
val thumbnail: Image?,
|
||||
val provider: Provider?,
|
||||
val author: Author?,
|
||||
val fields: List<Field>?,
|
||||
)
|
||||
|
||||
data class Image(
|
||||
val url: String,
|
||||
)
|
||||
|
||||
data class Author(
|
||||
val name: String,
|
||||
val url: String?,
|
||||
@SerializedName("icon_url") val iconUrl: String?,
|
||||
)
|
||||
|
||||
data class Provider(
|
||||
val name: String?,
|
||||
val url: String?,
|
||||
)
|
||||
|
||||
data class Footer(
|
||||
val text: String,
|
||||
@SerializedName("icon_url") val iconUrl: String?,
|
||||
)
|
||||
|
||||
data class Field(
|
||||
val name: String,
|
||||
val value: String,
|
||||
val inline: Boolean?,
|
||||
)
|
||||
}
|
||||
|
||||
/** Turns color into integer for webhook, using this because [Color]'s rgb method returns negatives. */
|
||||
private fun Color.toInt(): Int {
|
||||
val red = red shl 16 and 0xFF0000
|
||||
val green = green shl 8 and 0x00FF00
|
||||
val blue = blue and 0x0000FF
|
||||
|
||||
return red or green or blue
|
||||
}
|
@ -1 +1,54 @@
|
||||
rootProject.group = "${extra["plugin_group"]}"
|
||||
import java.awt.Color
|
||||
|
||||
plugins {
|
||||
id("crazyauctions.root-plugin")
|
||||
}
|
||||
|
||||
val legacyUpdate = Color(255, 73, 110)
|
||||
val releaseUpdate = Color(27, 217, 106)
|
||||
val snapshotUpdate = Color(255, 163, 71)
|
||||
|
||||
val commitMessage: String? = System.getenv("COMMIT_MESSAGE")
|
||||
val isBeta: Boolean = extra["isBeta"].toString().toBoolean()
|
||||
|
||||
webhook {
|
||||
this.avatar("https://cdn.discordapp.com/avatars/209853986646261762/eefe3c03882cbb885d98107857d0b022.png")
|
||||
|
||||
this.username("Ryder Belserion")
|
||||
|
||||
//this.content("New version of ${project.name} is ready! <@929463441159254066>")
|
||||
|
||||
this.content("New version of ${project.name} is ready!")
|
||||
|
||||
this.embeds {
|
||||
this.embed {
|
||||
if (isBeta) this.color(snapshotUpdate) else this.color(releaseUpdate)
|
||||
|
||||
this.fields {
|
||||
this.field(
|
||||
"Version ${project.version}",
|
||||
"Download Link: https://modrinth.com/plugin/${project.name.toLowerCase()}/version/${project.version}"
|
||||
)
|
||||
|
||||
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.author(
|
||||
project.name,
|
||||
"https://modrinth.com/plugin/${project.name.toLowerCase()}/versions",
|
||||
"https://cdn-raw.modrinth.com/data/r3BBZyf3/4522ef0f83143c4803473d356160a3e877c2499c.png"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("crazyauctions-common")
|
||||
id("crazyauctions.common-plugin")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -1,8 +1,22 @@
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=false
|
||||
##########################################################################
|
||||
# Standard Properties
|
||||
org.gradle.jvmargs = -Xmx2G
|
||||
org.gradle.warning.mode = all
|
||||
|
||||
minecraft_version=1.19.3
|
||||
##########################################################################
|
||||
# Standard Minecraft Dependencies
|
||||
minecraft_version = 1.19.3
|
||||
|
||||
plugin_version=1.2.18
|
||||
##########################################################################
|
||||
# Project Properties
|
||||
version = 1.2.18
|
||||
group = com.badbones69.crazyauctions
|
||||
name = CrazyAuctions
|
||||
description = Auction off your items in style!
|
||||
|
||||
plugin_group=com.badbones69.crazyauctions
|
||||
##########################################################################
|
||||
# Misc Properties
|
||||
isBeta = true
|
||||
java_version = 17
|
||||
|
||||
##########################################################################
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("crazyauctions-paper")
|
||||
id("crazyauctions.paper-plugin")
|
||||
|
||||
id("com.modrinth.minotaur") version "2.6.0"
|
||||
|
||||
@ -8,40 +8,36 @@ plugins {
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
val buildVersion = "${project.version}-SNAPSHOT"
|
||||
val isSnapshot = true
|
||||
val isBeta: Boolean = extra["isBeta"].toString().toBoolean()
|
||||
|
||||
fun getPluginVersion(): String {
|
||||
return if (isBeta) "${project.version}-BETA" else project.version.toString()
|
||||
}
|
||||
|
||||
fun getPluginVersionType(): String {
|
||||
return if (isBeta) "beta" else "release"
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
if (isSnapshot) {
|
||||
archiveFileName.set("${rootProject.name}-${buildVersion}.jar")
|
||||
} else {
|
||||
archiveFileName.set("${rootProject.name}-${project.version}.jar")
|
||||
}
|
||||
archiveFileName.set("${project.name}-${getPluginVersion()}.jar")
|
||||
|
||||
listOf(
|
||||
"org.bstats",
|
||||
"dev.triumphteam.cmd"
|
||||
).forEach {
|
||||
relocate(it, "${rootProject.group}.plugin.lib.$it")
|
||||
relocate(it, "${project.group}.plugin.lib.$it")
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
token.set(System.getenv("MODRINTH_TOKEN"))
|
||||
projectId.set("crazyauctions")
|
||||
projectId.set(project.name.toLowerCase())
|
||||
|
||||
if (isSnapshot) {
|
||||
versionName.set("${rootProject.name} $buildVersion")
|
||||
versionNumber.set(buildVersion)
|
||||
versionName.set("${project.name} ${getPluginVersion()}")
|
||||
versionNumber.set(getPluginVersion())
|
||||
|
||||
versionType.set("beta")
|
||||
} else {
|
||||
versionName.set("${rootProject.name} ${project.version}")
|
||||
versionNumber.set("${project.version}")
|
||||
|
||||
versionType.set("release")
|
||||
}
|
||||
versionType.set(getPluginVersionType())
|
||||
|
||||
uploadFile.set(shadowJar.get())
|
||||
|
||||
@ -62,17 +58,18 @@ tasks {
|
||||
processResources {
|
||||
filesMatching("plugin.yml") {
|
||||
expand(
|
||||
"name" to rootProject.name,
|
||||
"name" to project.name,
|
||||
"group" to project.group,
|
||||
"version" to if (isSnapshot) buildVersion else project.version,
|
||||
"description" to project.description
|
||||
"version" to getPluginVersion(),
|
||||
"description" to project.description,
|
||||
"website" to "https://modrinth.com/plugin/${project.name.toLowerCase()}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
val mavenExt: String = if (isSnapshot) "snapshots" else "releases"
|
||||
val mavenExt: String = if (isBeta) "beta" else "releases"
|
||||
|
||||
repositories {
|
||||
maven("https://repo.crazycrew.us/$mavenExt") {
|
||||
@ -87,9 +84,9 @@ publishing {
|
||||
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = "${extra["plugin_group"]}"
|
||||
artifactId = rootProject.name.toLowerCase()
|
||||
version = if (isSnapshot) buildVersion else "${project.version}"
|
||||
groupId = "${project.group}"
|
||||
artifactId = project.name.toLowerCase()
|
||||
version = getPluginVersion()
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
rootProject.name = "CrazyAuctions"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
includeBuild("build-logic")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user