-
Notifications
You must be signed in to change notification settings - Fork 173
Gradle 9 Support #937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle 9 Support #937
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,11 +88,6 @@ class KtlintPluginAndroidTest : AbstractPluginTest() { | |
minimumJava = 11, | ||
maximumJava = 17 | ||
), | ||
MAX_GRADLE_MIN_AGP( | ||
GradleVersion.version(TestVersions.maxSupportedGradleVersion), | ||
TestVersions.minAgpVersion, | ||
TestVersions.minSupportedKotlinPluginVersion | ||
), | ||
Comment on lines
-91
to
-95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why drop this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the old AGP doesnt work with Gradle 9, so this combination no longer works |
||
MAX( | ||
GradleVersion.version(TestVersions.maxSupportedGradleVersion), | ||
TestVersions.maxAgpVersion, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.jlleitschuh.gradle.ktlint.testdsl | ||
|
||
import net.swiftzer.semver.SemVer | ||
import org.gradle.util.GradleVersion | ||
import org.jlleitschuh.gradle.ktlint.KtlintPlugin | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
|
@@ -8,15 +9,26 @@ import org.junit.jupiter.params.provider.ArgumentsProvider | |
import java.util.stream.Stream | ||
import kotlin.streams.asStream | ||
|
||
fun getCurrentJavaVersion(): String { | ||
return Runtime::class.java.getPackage().specificationVersion // java 8 | ||
?: Runtime::class.java.getMethod("version").invoke(null).toString() // java 9+ | ||
} | ||
|
||
@Suppress("ConstPropertyName") | ||
object TestVersions { | ||
const val minSupportedGradleVersion = "7.6.3" // lowest version for testing | ||
const val maxSupportedGradleVersion = "8.13" | ||
val maxSupportedGradleVersion = | ||
// gradle 9 requires Java 17 | ||
if (SemVer.parse(getCurrentJavaVersion()).major >= 17) { | ||
"9.0.0" | ||
} else { | ||
"8.14.3" | ||
} | ||
val pluginVersion = System.getProperty("project.version") | ||
?: KtlintPlugin::class.java.`package`.implementationVersion | ||
?: error("Unable to determine plugin version.") | ||
const val minSupportedKotlinPluginVersion = "1.6.21" | ||
const val maxSupportedKotlinPluginVersion = "2.1.21" | ||
const val maxSupportedKotlinPluginVersion = "2.2.0" | ||
const val minAgpVersion = "4.1.0" | ||
const val maxAgpVersion = "8.8.0" | ||
} | ||
|
@@ -25,7 +37,6 @@ object TestVersions { | |
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class GradleTestVersions( | ||
val minVersion: String = TestVersions.minSupportedGradleVersion, | ||
val maxVersion: String = TestVersions.maxSupportedGradleVersion, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we were never overriding this anyway, and making it an annotation property was preventing me from making it dynamic based Java version |
||
val additionalVersions: Array<String> = [] | ||
) | ||
|
||
|
@@ -55,7 +66,7 @@ open class GradleArgumentsProvider : ArgumentsProvider { | |
} else { | ||
GradleVersion.version(versionsAnnotation.minVersion) | ||
} | ||
val maxGradleVersion = GradleVersion.version(versionsAnnotation.maxVersion) | ||
val maxGradleVersion = GradleVersion.version(TestVersions.maxSupportedGradleVersion) | ||
val additionalGradleVersions = versionsAnnotation | ||
.additionalVersions | ||
.map(GradleVersion::version) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a binary API breaking change? IE. if projects are depending upon this plugin as a direct dependency rather than as a script, anything compiled against our APIs won't work anymore, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly... I know gradle has some stuff to auto convert between SAMs and Closures, but I'm not sure if it would help here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in any case, this is the way is is supposed to be done in Gradle now, so I think at most, I'll make a note about it in release notes