Fix various gradle buildscript issues (#4)

This commit is contained in:
zml 2023-01-08 23:46:27 -08:00 committed by GitHub
parent 34685d6789
commit 6565ba08e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 44 deletions

View file

@ -12,9 +12,6 @@ plugins {
}
val archives_base_name: String by project
group = "com.example"
version = project.version.toString()
base.archivesName.set(archives_base_name)
val javaVersion = 17
@ -62,19 +59,19 @@ tasks {
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = javaVersion.toString()
languageVersion = libs.plugins.kotlin.get().version.strictVersion
incremental = true
// languageVersion: A.B of the kotlin plugin version A.B.C
languageVersion = libs.plugins.kotlin.get().version.requiredVersion.substringBeforeLast('.')
}
}
withType<JavaCompile> {
withType<JavaCompile>.configureEach {
options.encoding = "UTF-8"
options.isDeprecation = true
options.isIncremental = true
options.release.set(javaVersion)
}
processResources {
filteringCharset = "UTF-8"
inputs.property("version", project.version)
filesMatching("quilt.mod.json") {
@ -86,24 +83,30 @@ tasks {
}
}
// Change the gradle version here and run `./gradlew wrapper` or `gradle wrapper` to update gradle scripts
javadoc {
options.encoding = "UTF-8"
}
// Run `./gradlew wrapper --gradle-version <newVersion>` or `gradle wrapper --gradle-version <newVersion>` to update gradle scripts
// BIN distribution should be sufficient for the majority of mods
wrapper {
gradleVersion = "7.6"
distributionType = Wrapper.DistributionType.BIN
}
remapJar {
dependsOn(remapSourcesJar)
}
jar {
from("LICENSE")
from("LICENSE") {
rename { "LICENSE_${archives_base_name}" }
}
}
}
kotlin {
jvmToolchain(javaVersion)
val targetJavaVersion = JavaVersion.toVersion(javaVersion)
if (JavaVersion.current() < targetJavaVersion) {
kotlin.jvmToolchain(javaVersion)
java.toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}
java {
@ -116,31 +119,16 @@ java {
// withJavadocJar()
// Still required by IDEs such as Eclipse and VSC
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
sourceCompatibility = targetJavaVersion
targetCompatibility = targetJavaVersion
}
val sourceJar = task("sourceJar", Jar::class) {
dependsOn(tasks["classes"])
archiveClassifier.set("source")
from(sourceSets.main.get().allSource)
}
val javadoc = task("javadocJar", Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
from(tasks.javadoc)
}
// Configure the maven publication
publishing {
publications {
create<MavenPublication>("Maven") {
register<MavenPublication>("Maven") {
from(components.getByName("java"))
artifact(javadoc)
artifact(sourceJar)
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
@ -150,5 +138,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}

View file

@ -3,5 +3,6 @@ org.gradle.parallel=true
kotlin.incremental=true
kotlin.code.style=official
group=com.example
version=1.0.0
archives_base_name=quilt-kotlin-template-mod