11package build.extensions.oss.gradle.pluginutils
22
3- import org.gradle.api.plugins.Convention
43import org.gradle.api.plugins.ExtensionAware
54
65
7- @Deprecated(
8- message = " Deprecated - disallow late runtime cast" ,
9- replaceWith = ReplaceWith (" extension(name, T::class.java)" )
10- )
11- fun <T : Any > Any.extension (name : String ): T ? {
12- @Suppress(" UNCHECKED_CAST" )
13- return extension(name, Any ::class .java) as T ?
14- }
15-
166/* *
177 * Gets the extension of the given name if it exists.
188 *
@@ -29,15 +19,6 @@ fun <T : Any> Any.extension(name: String, clazz: Class<T>): T? {
2919}
3020
3121
32- @Deprecated(
33- message = " Deprecated - disallow late runtime cast" ,
34- replaceWith = ReplaceWith (" requiredExtension(name, T::class.java)" )
35- )
36- fun <T : Any > Any.requiredExtension (name : String ): T {
37- @Suppress(" UNCHECKED_CAST" )
38- return requiredExtension(name, Any ::class .java) as T
39- }
40-
4122/* *
4223 * Gets the extension of the given name, throwing an exception if it does not exist.
4324 *
@@ -78,17 +59,3 @@ inline fun <reified T : Any> Any.extension(): T? =
7859 */
7960inline fun <reified T : Any > Any.requiredExtension (): T =
8061 (this as ExtensionAware ).extensions.getByType(typeOf<T >())
81-
82-
83- /* *
84- * Gets the convention plugin object of the given type, throwing an exception if it does not exist.
85- *
86- * @receiver the object containing conventions
87- * @param <T> the convention type
88- * @return the convention plugin object
89- * @throws ClassCastException if the receiver object does not support conventions
90- * @throws IllegalStateException if the convention plugin does not exist
91- */
92- @Deprecated(" prefer extension objects over conventions" )
93- inline fun <reified T : Any > Any.requiredConventionPlugin (): T =
94- ((this as ExtensionAware ).extensions as Convention ).getPlugin(T ::class .java)
0 commit comments