Skip to content

Commit a9ff2eb

Browse files
committed
add tests and documentation
2 parents c71cd18 + fc1f149 commit a9ff2eb

File tree

3 files changed

+1
-36
lines changed

3 files changed

+1
-36
lines changed

gradle-plugin-utils/api/gradle-plugin-utils.api

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ public final class build/extensions/oss/gradle/pluginutils/DurationUtilsKt {
88
}
99

1010
public final class build/extensions/oss/gradle/pluginutils/ExtensionUtilsKt {
11-
public static final fun extension (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
1211
public static final fun extension (Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
13-
public static final fun requiredExtension (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
1412
public static final fun requiredExtension (Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
1513
}
1614

gradle-plugin-utils/src/main/kotlin/build/extensions/oss/gradle/pluginutils/ExtensionUtils.kt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
package build.extensions.oss.gradle.pluginutils
22

3-
import org.gradle.api.plugins.Convention
43
import 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
*/
7960
inline 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)

gradle-plugin-utils/src/test/kotlin/build/extensions/oss/gradle/pluginutils/SystemUtilsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ class SystemUtilsTest {
4646
fun testPosixArchiveFormat() {
4747
SystemUtils.getOperatingSystemArchiveFormat() shouldBe "tar.gz"
4848
}
49-
}
49+
}

0 commit comments

Comments
 (0)