Skip to content

Commit

Permalink
build... conventions?
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyces committed May 22, 2024
1 parent 99c57f8 commit c60c86c
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build-conventions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}
File renamed without changes.
9 changes: 9 additions & 0 deletions build-conventions/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-conventions"
104 changes: 104 additions & 0 deletions build-conventions/src/main/kotlin/trimmed.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
plugins {
`java-library`
`maven-publish`
`version-catalog`
}

configure<JavaPluginExtension> {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

ext {
val parchmentVersion: String;
if (!libs.versions.parchment.mc.get().equals(libs.versions.minecraft.release.get())) {
parchmentVersion = "${libs.versions.parchment.mc.get()}-${libs.versions.parchment.release.get()}-${libs.versions.minecraft.release.get()}"
} else {
parchmentVersion = "${libs.versions.parchment.release.get()}-${libs.versions.minecraft.release.get()}"
}
}

version = extra["mod_version"]

tasks.jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${extra["mod_name"]}" }
}
manifest {
attributes(
"Specification-Title" to extra["mod_name"],
"Specification-Vendor" to extra["mod_author"],
"Specification-Version" to archiveVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to archiveVersion,
"Implementation-Vendor" to extra["mod_author"],
// "Implementation-Timestamp" to new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Timestamp" to System.currentTimeMillis(),
"Built-On-Java" to "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})",
"Built-On-Minecraft" to libs.versions.minecraft.release.get()
)
}
}

repositories {
mavenCentral()
mavenLocal()

maven {
name = "Sponge / Mixin"
url = uri("https://repo.spongepowered.org/repository/maven-public/")
}

maven {
name = "BlameJared Maven (CrT / Bookshelf)"
url = uri("https://maven.blamejared.com")
}

maven {
url = uri("https://jm.gserv.me/repository/maven-public/")
}

maven { url = uri("https://jitpack.io/") }
}

dependencies {
"compileOnly"(libs.jetbrains.annotations)
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release = 21
}

// Disables Gradle"s custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
//tasks.withType<GenerateModuleMetadata>().configureEach {
// enabled = false
//}

// publishing {
// repositories {
// maven {
// name = "Local"
// url = uri("file://" + findProperty("local_maven"))
// }
// maven {
// name = "Maven"
// url = uri(findProperty("mavenUrl"))
//// credentials(PasswordCredentials) {
//// username = findProperty("mavenUsername")
//// password = findProperty("mavenPassword")
//// }
// }
// maven {
// name = "GitHubPackages"
// url = uri("https://maven.pkg.github.com/dhyces/trimmed")
//// credentials {
//// username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
//// password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
//// }
// }
// }
// }

0 comments on commit c60c86c

Please sign in to comment.