From 3003371ddad2c30751a986d33c561405283dfc3c Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Thu, 15 Feb 2024 20:22:10 +0100 Subject: [PATCH] Use helper plugin --- build.gradle.kts | 168 ++++---------------------------------------- gradle.properties | 12 ++-- settings.gradle.kts | 4 +- 3 files changed, 25 insertions(+), 159 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c9dd269..f1a2723 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,165 +1,25 @@ -import java.time.Instant -import java.time.format.DateTimeFormatter - plugins { - `java-library` - eclipse - idea - `maven-publish` - id("org.ec4j.editorconfig") - id("net.neoforged.gradle.userdev") -} -//============================================= - -editorconfig { - excludes = listOf("**/run/**", "**/out/**", "**/.idea/**", "**/gradlew*") - isExcludeNonSourceFiles = true -} - -group = "${project.properties["lib_group"]}" -version = "${project.properties["mc_version"]}-${project.properties["lib_version"]}" -base.archivesName = "${project.properties["lib_name"]}" - -if (System.getenv("RELEASE_TYPE") != null) { - status = System.getenv("RELEASE_TYPE").lowercase() - if (status == "snapshot") status = (status as String).uppercase() -} else { - status = "SNAPSHOT" -} - -if (status != "release") { - version = "${version}-${status}" -} - -java { - withSourcesJar() - withJavadocJar() - - toolchain { - languageVersion = JavaLanguageVersion.of((project.properties["java_version"] as String).toInt()) - vendor = if (System.getenv("CI").toBoolean()) { JvmVendorSpec.ADOPTIUM } else { JvmVendorSpec.JETBRAINS } - } -} - -repositories { - mavenLocal() - mavenCentral() - maven { - name = "Minecraftschurli Maven" - url = uri("https://minecraftschurli.ddns.net/repository/maven-public") - } + id ("com.github.minecraftschurlimods.helperplugin") } dependencies { - implementation("net.neoforged:neoforge:${project.properties["neo_version"]}") + implementation(helper.neoforge()) compileOnly("org.jetbrains:annotations:23.0.0") } -tasks.withType().configureEach { - options.encoding = "UTF-8" -} - -tasks.javadoc { - options.encoding = "UTF-8" - (options as StandardJavadocDocletOptions).tags = listOf( - "side:a:Side:", - "apiNote:a:API Note:", - "implSpec:a:Implementation Requirements:", - "implNote:a:Implementation Note:" - ) - if (JavaVersion.current().isJava9Compatible) { - (options as CoreJavadocOptions).addBooleanOption("html5", true) - } -} - -tasks.withType().configureEach { - from("LICENSE") - manifest { - attributes(mapOf( - "Maven-Artifact" to "${project.group}:${project.base.archivesName.get()}:${project.version}", - "Specification-Title" to base.archivesName.get(), - "Specification-Vendor" to project.properties["lib_vendor"], - "Specification-Version" to "1", - "Implementation-Title" to base.archivesName.get(), - "Implementation-Version" to project.properties["lib_version"], - "Implementation-Vendor" to project.properties["lib_vendor"], - "Built-On-Java" to "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})", - "Built-On-Minecraft" to project.properties["mc_version"], - "Built-On" to project.properties["neo_version"], - "Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now()), - "FMLModType" to "GAMELIBRARY", - "LICENSE" to "MIT" - )) - } -} - -artifacts { - archives(tasks.jar) - archives(tasks.named("sourcesJar")) - archives(tasks.named("javadocJar")) -} - -publishing { - publications.create(base.archivesName.get()+"ToMaven") { - groupId = project.group as String - artifactId = base.archivesName.get() - version = project.version as String - from(components.getByName("java")) - pom { - name = project.name - url = (project.properties["url"] as String) - packaging = "jar" - scm { - connection = "scm:git:git://github.com/${project.properties["github"]}.git" - developerConnection = "scm:git:git@github.com:${project.properties["github"]}.git" - url = "https://github.com/${project.properties["github"]}" - } - issueManagement { - system = "github" - url = "https://github.com/${project.properties["github"]}.git/issues" - } - organization { - name = "Minecraftschurli Mods" - url = "https://github.com/Minecraftschurli" - } - developers { - developer { - id = "minecraftschurli" - name = "Minecraftschurli" - email = "minecraftschurli@gmail.com" - organization = "Minecraftschurli Mods" - organizationUrl = "https://github.com/Minecraftschurli" - timezone = "Europe/Vienna" - } - } - licenses { - license { - name = "MIT" - url = "https://github.com/${project.properties["github"]}/blob/main/LICENSE" - distribution = "repo" - } - } - } +helper.publication.pom { + organization { + name = "Minecraftschurli Mods" + url = "https://github.com/MinecraftschurliMods" } - repositories { - maven { - if ((System.getenv("MAVEN_USER") != null) && - (System.getenv("MAVEN_PASSWORD") != null) && - (System.getenv("MAVEN_URL") != null) - ) { - url = uri(System.getenv("MAVEN_URL")) - credentials { - username = System.getenv("MAVEN_USER") - password = System.getenv("MAVEN_PASSWORD") - } - } else { - println("Using repo folder") - url = uri(project.layout.buildDirectory.dir("repo")) - } + developers { + developer { + id = "minecraftschurli" + name = "Minecraftschurli" + email = "minecraftschurli@gmail.com" + organization = "Minecraftschurli Mods" + organizationUrl = "https://github.com/Minecraftschurli" + timezone = "Europe/Vienna" } } } - -tasks.publish { - dependsOn(tasks.check) -} diff --git a/gradle.properties b/gradle.properties index 8447e7e..7bb011d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,16 +2,20 @@ org.gradle.jvmargs=-Xmx4G org.gradle.daemon=false org.gradle.caching=true +project_type=LIBRARY lib_group=com.github.minecraftschurlimods lib_name=betterkeybindlib lib_version=1.1 -lib_vendor=Minecraftschurli -github=MinecraftschurliMods/betterkeybindlib -url=https://github.com/MinecraftschurliMods/betterkeybindlib - vendor=Minecraftschurli java_version=17 +github.owner=MinecraftschurliMods +github.repo=betterkeybindlib + +license.name=MIT +license.url=https://opensource.org/licenses/MIT +license.file=LICENSE + neogradle.subsystems.parchment.minecraftVersion=1.20.3 neogradle.subsystems.parchment.mappingsVersion=2023.12.31 diff --git a/settings.gradle.kts b/settings.gradle.kts index 614787f..7170977 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,15 +2,17 @@ pluginManagement { plugins { id("org.ec4j.editorconfig") version "0.0.3" id("net.neoforged.gradle.userdev") version "7.0.80" + id("com.github.minecraftschurlimods.helperplugin") version "1.1" } repositories { mavenLocal() gradlePluginPortal() maven { url = uri("https://maven.neoforged.net/releases") } + maven { url = uri("https://minecraftschurli.ddns.net/repository/maven-public") } } } -plugins { +plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" }