Fix various gradle buildscript issues (#4)
This commit is contained in:
parent
34685d6789
commit
6565ba08e5
2 changed files with 32 additions and 44 deletions
|
@ -12,9 +12,6 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
val archives_base_name: String by project
|
val archives_base_name: String by project
|
||||||
|
|
||||||
group = "com.example"
|
|
||||||
version = project.version.toString()
|
|
||||||
base.archivesName.set(archives_base_name)
|
base.archivesName.set(archives_base_name)
|
||||||
|
|
||||||
val javaVersion = 17
|
val javaVersion = 17
|
||||||
|
@ -62,19 +59,19 @@ tasks {
|
||||||
withType<KotlinCompile> {
|
withType<KotlinCompile> {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = javaVersion.toString()
|
jvmTarget = javaVersion.toString()
|
||||||
languageVersion = libs.plugins.kotlin.get().version.strictVersion
|
// languageVersion: A.B of the kotlin plugin version A.B.C
|
||||||
incremental = true
|
languageVersion = libs.plugins.kotlin.get().version.requiredVersion.substringBeforeLast('.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withType<JavaCompile> {
|
withType<JavaCompile>.configureEach {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.isDeprecation = true
|
options.isDeprecation = true
|
||||||
options.isIncremental = true
|
|
||||||
options.release.set(javaVersion)
|
options.release.set(javaVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
filteringCharset = "UTF-8"
|
||||||
inputs.property("version", project.version)
|
inputs.property("version", project.version)
|
||||||
|
|
||||||
filesMatching("quilt.mod.json") {
|
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
|
// BIN distribution should be sufficient for the majority of mods
|
||||||
wrapper {
|
wrapper {
|
||||||
gradleVersion = "7.6"
|
|
||||||
distributionType = Wrapper.DistributionType.BIN
|
distributionType = Wrapper.DistributionType.BIN
|
||||||
}
|
}
|
||||||
|
|
||||||
remapJar {
|
|
||||||
dependsOn(remapSourcesJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from("LICENSE")
|
from("LICENSE") {
|
||||||
|
rename { "LICENSE_${archives_base_name}" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
val targetJavaVersion = JavaVersion.toVersion(javaVersion)
|
||||||
jvmToolchain(javaVersion)
|
if (JavaVersion.current() < targetJavaVersion) {
|
||||||
|
kotlin.jvmToolchain(javaVersion)
|
||||||
|
|
||||||
|
java.toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(javaVersion))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -116,39 +119,23 @@ java {
|
||||||
// withJavadocJar()
|
// withJavadocJar()
|
||||||
|
|
||||||
// Still required by IDEs such as Eclipse and VSC
|
// Still required by IDEs such as Eclipse and VSC
|
||||||
sourceCompatibility = JavaVersion.toVersion(javaVersion)
|
sourceCompatibility = targetJavaVersion
|
||||||
targetCompatibility = JavaVersion.toVersion(javaVersion)
|
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
|
// Configure the maven publication
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("Maven") {
|
register<MavenPublication>("Maven") {
|
||||||
from(components.getByName("java"))
|
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.
|
|
||||||
repositories {
|
|
||||||
// Add repositories to publish to here.
|
|
||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
|
||||||
// retrieving dependencies.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||||
|
repositories {
|
||||||
|
// Add repositories to publish to here.
|
||||||
|
// Notice: This block does NOT have the same function as the block in the top level.
|
||||||
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
|
// retrieving dependencies.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@ org.gradle.parallel=true
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
|
||||||
|
group=com.example
|
||||||
version=1.0.0
|
version=1.0.0
|
||||||
archives_base_name=quilt-kotlin-template-mod
|
archives_base_name=quilt-kotlin-template-mod
|
Loading…
Reference in a new issue