Add conventions only if they are still available
So Gradle could drop conventions in Gradle 8.0 release. ^KT-47047 Fixed
This commit is contained in:
+12
-1
@@ -23,7 +23,18 @@ import org.gradle.api.plugins.ExtensionAware
|
||||
|
||||
@Deprecated("Conventions are deprecated in Gradle")
|
||||
internal inline fun <reified T : Any> Any.addConvention(name: String, plugin: T) {
|
||||
(this as HasConvention).convention.plugins[name] = plugin
|
||||
// Verifying conventions are still available via reflection,
|
||||
// so Gradle could remove them in Gradle 8.0 release
|
||||
val conventionsIsAvailable = try {
|
||||
Class.forName("org.gradle.api.internal.HasConvention")
|
||||
true
|
||||
} catch (_: ClassNotFoundException) {
|
||||
false
|
||||
}
|
||||
|
||||
if (conventionsIsAvailable) {
|
||||
(this as HasConvention).convention.plugins[name] = plugin
|
||||
}
|
||||
}
|
||||
|
||||
internal inline fun <reified T : Any> Any.addExtension(name: String, extension: T) =
|
||||
|
||||
Reference in New Issue
Block a user