Skip to content

Commit

Permalink
RFG Kotlin fixes, update kotlin to 1.8, drop jdk7
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenraven committed Jan 29, 2023
1 parent 95b68a1 commit 2fc47b1
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 18 deletions.
6 changes: 0 additions & 6 deletions addon.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
apply plugin: 'org.jetbrains.kotlin.jvm'

compileKotlin {
kotlinOptions {
jvmTarget = 1.8
}
}
65 changes: 60 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1675013090
//version: 1675030924
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -55,9 +55,9 @@ plugins {
id 'eclipse'
id 'scala'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false
id 'org.jetbrains.kotlin.kapt' version '1.8.0' apply false
id 'com.google.devtools.ksp' version '1.8.0-1.0.9' apply false
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version ,unused, available for addon.gradle
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'com.palantir.git-version' version '0.13.0' apply false // 0.13.0 is the last jvm8 supporting version
Expand Down Expand Up @@ -113,6 +113,7 @@ propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
propertyDefaultIfUnset("relocateShadowedDependencies", true)
// Deprecated properties (kept for backwards compat)
propertyDefaultIfUnset("gradleTokenModId", "")
propertyDefaultIfUnset("gradleTokenModName", "")
Expand Down Expand Up @@ -149,6 +150,30 @@ java {
}
}

pluginManager.withPlugin('org.jetbrains.kotlin.jvm') {
// If Kotlin is enabled in the project
kotlin {
jvmToolchain(8)
}
// Kotlin hacks our source sets, so we hack Kotlin's tasks
def disabledKotlinTaskList = [
"kaptGenerateStubsMcLauncherKotlin",
"kaptGenerateStubsPatchedMcKotlin",
"kaptGenerateStubsInjectedTagsKotlin",
"compileMcLauncherKotlin",
"compilePatchedMcKotlin",
"compileInjectedTagsKotlin",
"kaptMcLauncherKotlin",
"kaptPatchedMcKotlin",
"kaptInjectedTagsKotlin",
]
tasks.configureEach { task ->
if (task.name in disabledKotlinTaskList) {
task.enabled = false
}
}
}

configurations {
create("runtimeOnlyNonPublishable") {
description = "Runtime only dependencies that are not published alongside the jar"
Expand Down Expand Up @@ -502,6 +527,14 @@ dependencies {
}
}

pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
if (usesMixins.toBoolean()) {
dependencies {
kapt('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
}
}
}

apply from: 'dependencies.gradle'

def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
Expand Down Expand Up @@ -558,6 +591,25 @@ if (usesMixins.toBoolean()) {
"-XDignore.symbol.file"
]
}

pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
kapt {
correctErrorTypes = true
javacOptions {
option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}")
option("-AoutSrgFile=$mixinSrg")
option("-AoutRefMapFile=$refMap")
}
}
tasks.configureEach { task ->
if (task.name == "kaptKotlin") {
task.doFirst {
new File(mixinTmpDir).mkdirs()
}
}
}
}

}

tasks.named("processResources", ProcessResources).configure {
Expand Down Expand Up @@ -613,6 +665,7 @@ if (usesShadowedDependencies.toBoolean()) {
tasks.register('relocateShadowJar', ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
enabled = minimizeShadowedDependencies.toBoolean()
}
tasks.named("shadowJar", ShadowJar).configure {
manifest {
Expand All @@ -628,7 +681,9 @@ if (usesShadowedDependencies.toBoolean()) {
project.configurations.shadeCompile
]
archiveClassifier.set('dev')
dependsOn(relocateShadowJar)
if (minimizeShadowedDependencies.toBoolean()) {
dependsOn(relocateShadowJar)
}
}
configurations.runtimeElements.outgoing.artifacts.clear()
configurations.apiElements.outgoing.artifacts.clear()
Expand Down
13 changes: 6 additions & 7 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Add your dependencies here

dependencies {
shadeCompile("org.jetbrains.kotlin:kotlin-stdlib:1.5.30")
shadeCompile("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.30")
shadeCompile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30")
shadeCompile("org.jetbrains.kotlin:kotlin-reflect:1.5.30")
shadeCompile("org.jetbrains:annotations")
shadeCompile("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
shadeCompile("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.2")
shadowImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.0")
shadowImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0")
shadowImplementation("org.jetbrains.kotlin:kotlin-reflect:1.8.0")
shadowImplementation("org.jetbrains:annotations")
shadowImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
shadowImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = true
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = false
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = false

# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter.
Expand Down

0 comments on commit 2fc47b1

Please sign in to comment.