From 4f52838c0556a25b87f15fbd4848c9bf2fb9d13b Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Wed, 31 Jul 2024 20:45:45 -0500 Subject: [PATCH] add multi-release settings to gradle plugin --- .../jvmdg/gradle/JVMDowngraderExtension.kt | 2 ++ .../jvmdg/gradle/flags/DowngradeFlags.kt | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/JVMDowngraderExtension.kt b/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/JVMDowngraderExtension.kt index b04173c9..9d914d2d 100644 --- a/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/JVMDowngraderExtension.kt +++ b/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/JVMDowngraderExtension.kt @@ -71,6 +71,8 @@ abstract class JVMDowngraderExtension @Inject constructor(@get:Internal val proj debugSkipStubs.convention(emptySet()).finalizeValueOnRead() debugDumpClasses.convention(false).finalizeValueOnRead() shadePath.convention { it.substringBefore(".").substringBeforeLast("-").replace(Regex("[.;\\[/]"), "-") + "/" } + multiReleaseOriginal.convention(false).finalizeValueOnRead() + multiReleaseVersions.convention(emptySet()).finalizeValueOnRead() } fun convention(flags: ShadeFlags) { diff --git a/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/flags/DowngradeFlags.kt b/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/flags/DowngradeFlags.kt index 36309c23..dd21e429 100644 --- a/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/flags/DowngradeFlags.kt +++ b/gradle-plugin/src/main/kotlin/xyz/wagyourtail/jvmdg/gradle/flags/DowngradeFlags.kt @@ -93,6 +93,21 @@ interface DowngradeFlags : TransformParameters { @get:Optional val debugDumpClasses: Property + /** + * sets if the original versions of classes should be retained in the output jar as a Multi-Release + * @since 1.0.0 + */ + @get:Input + @get:Optional + val multiReleaseOriginal: Property + + /** + * sets if semi-downgraded versions of classes should be retained in the output jar as a Multi-Release + * @since 1.0.0 + */ + @get:Input + @get:Optional + val multiReleaseVersions: SetProperty } fun DowngradeFlags.toFlags(): Flags { @@ -106,5 +121,7 @@ fun DowngradeFlags.toFlags(): Flags { flags.debugSkipStubs = debugSkipStubs.getOrElse(emptySet()).map { it.toOpcode() }.toSet() ignoreWarningsIn.getOrElse(emptyList()).forEach { flags.addIgnore(it) } flags.debugDumpClasses = debugDumpClasses.getOrElse(false) + flags.multiReleaseOriginal = multiReleaseOriginal.getOrElse(false) + flags.multiReleaseVersions = multiReleaseVersions.getOrElse(emptySet()).map { it.toOpcode() }.toSet() return flags }