Skip to content

Commit

Permalink
Use helper plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Minecraftschurli committed Feb 15, 2024
1 parent c74bdd5 commit 1dcb7c9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 158 deletions.
168 changes: 14 additions & 154 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<JavaCompile>().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<Jar>().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<MavenPublication>(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:[email protected]:${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 = "[email protected]"
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 = "[email protected]"
organization = "Minecraftschurli Mods"
organizationUrl = "https://github.com/Minecraftschurli"
timezone = "Europe/Vienna"
}
}
}

tasks.publish {
dependsOn(tasks.check)
}
12 changes: 8 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=betterhudlib
lib_version=1.0
lib_vendor=Minecraftschurli
github=MinecraftschurliMods/BetterHUDLib
url=https://github.com/MinecraftschurliMods/BetterHUDLib

vendor=Minecraftschurli
java_version=17

github.owner=MinecraftschurliMods
github.name=BetterHUDLib

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

Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ 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") }
}
}

Expand Down

0 comments on commit 1dcb7c9

Please sign in to comment.