Skip to content

Commit

Permalink
update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Oct 23, 2024
1 parent 07cf6ff commit 5197b99
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 136 deletions.
74 changes: 29 additions & 45 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,68 +1,52 @@
plugins {
alias(libs.plugins.minotaur)
alias(libs.plugins.hangar)

`java-plugin`
`maven-publish`
`java-library`
}

val buildNumber: String? = System.getenv("BUILD_NUMBER")

rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "2.5.1"

val isSnapshot = false

val content: String = rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)

subprojects.filter { it.name != "api" }.forEach {
it.project.version = rootProject.version
}

modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))

projectId.set(rootProject.name.lowercase())

versionType.set(if (isSnapshot) "beta" else "release")

versionName.set("${rootProject.name} ${rootProject.version}")
versionNumber.set(rootProject.version as String)

changelog.set(content)

uploadFile.set(rootProject.projectDir.resolve("jars/${rootProject.name}-${rootProject.version}.jar"))
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "java-library")

gameVersions.set(listOf(libs.versions.minecraft.get()))
group = "com.badbones69.crazyenchantments"
description = "Adds over 80 unique enchantments to your server and more!"

loaders.addAll(listOf("purpur", "paper", "folia"))
repositories {
maven("https://repo.codemc.io/repository/maven-public")

autoAddDependsOn.set(false)
detectLoaders.set(false)
}

hangarPublish {
publications.register("plugin") {
apiKey.set(System.getenv("HANGAR_KEY"))
maven("https://repo.crazycrew.us/libraries")
maven("https://repo.crazycrew.us/releases")

id.set(rootProject.name.lowercase())
maven("https://jitpack.io")

version.set(rootProject.version as String)

channel.set(if (isSnapshot) "Beta" else "Release")
mavenCentral()
}

changelog.set(content)
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

platforms {
paper {
jar.set(rootProject.projectDir.resolve("jars/${rootProject.name}-${rootProject.version}.jar"))
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(21)
}

platformVersions.set(listOf(libs.versions.minecraft.get()))
javadoc {
options.encoding = Charsets.UTF_8.name()
}

dependencies {
hangar("PlaceholderAPI") {
required = false
}
}
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
}
}
3 changes: 0 additions & 3 deletions buildSrc/build.gradle.kts

This file was deleted.

7 changes: 0 additions & 7 deletions buildSrc/settings.gradle.kts

This file was deleted.

41 changes: 0 additions & 41 deletions buildSrc/src/main/kotlin/java-plugin.gradle.kts

This file was deleted.

17 changes: 0 additions & 17 deletions buildSrc/src/main/kotlin/paper-plugin.gradle.kts

This file was deleted.

10 changes: 0 additions & 10 deletions gradle.properties

This file was deleted.

30 changes: 19 additions & 11 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
plugins {
alias(libs.plugins.paperweight)
alias(libs.plugins.runPaper)
alias(libs.plugins.shadow)

`paper-plugin`
alias(libs.plugins.paperweight)
}

base {
archivesName.set(rootProject.name)
}

repositories {
maven("https://repo.papermc.io/repository/maven-public")

maven("https://repo.md-5.net/content/repositories/snapshots")

maven("https://ci.ender.zone/plugin/repository/everything")

maven("https://repo.glaremasters.me/repository/towny")

maven("https://repo.bg-software.com/repository/api")

maven("https://maven.enginehub.org/repo")

maven("https://repo.oraxen.com/releases")
}

dependencies {
paperweight.paperDevBundle(libs.versions.paper)

Expand Down Expand Up @@ -99,22 +114,15 @@ tasks {
shadowJar {
archiveBaseName.set(rootProject.name)
archiveClassifier.set("")

listOf(
"de.tr7zw.changeme.nbtapi"
).forEach {
relocate(it, "libs.$it")
}
}

processResources {
inputs.properties("name" to rootProject.name)
inputs.properties("version" to project.version)
inputs.properties("group" to "${project.group}.paper")
inputs.properties("description" to project.properties["description"])
inputs.properties("description" to project.description)
inputs.properties("apiVersion" to libs.versions.minecraft.get())
inputs.properties("authors" to project.properties["authors"])
inputs.properties("website" to project.properties["website"])
inputs.properties("website" to "https://modrinth.com/plugin/crazyenchantments")

filesMatching("plugin.yml") {
expand(inputs.properties)
Expand Down
5 changes: 4 additions & 1 deletion paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: '${name}'
main: '${group}.${name}'

authors: ${authors}
authors:
- ryderbelserion
- BadBones69
- TDL

version: '${version}'
api-version: '${apiVersion}'
Expand Down
64 changes: 64 additions & 0 deletions publish/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
plugins {
alias(libs.plugins.minotaur)
alias(libs.plugins.hangar)
}

val content: String = rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)

val isBeta = false
val pluginName = rootProject.name
val mcVersion = libs.versions.minecraft.get()

tasks {
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))

projectId.set(rootProject.name)

versionType.set(if (isBeta) "beta" else "release")

versionName.set("$pluginName ${rootProject.version}")
versionNumber.set(rootProject.version as String)

changelog.set(content)

uploadFile.set(rootProject.projectDir.resolve("jars/$pluginName-${rootProject.version}.jar"))

gameVersions.set(listOf(mcVersion))

loaders.addAll(listOf("purpur", "paper", "folia"))

syncBodyFrom.set(rootProject.file("README.md").readText(Charsets.UTF_8))

autoAddDependsOn.set(false)
detectLoaders.set(false)
}

hangarPublish {
publications.register("plugin") {
apiKey.set(System.getenv("HANGAR_KEY"))

id.set(pluginName)

version.set(rootProject.version as String)

channel.set(if (isBeta) "Beta" else "Release")

changelog.set(content)

platforms {
paper {
jar.set(rootProject.projectDir.resolve("jars/$pluginName-${rootProject.version}.jar"))

platformVersions.set(listOf(mcVersion))

dependencies {
hangar("PlaceholderAPI") {
required = false
}
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = "CrazyEnchantments"

include("paper")
include("publish" ,"paper")

0 comments on commit 5197b99

Please sign in to comment.