Skip to content

Commit 0361e05

Browse files
committed
Make all helper utils internal
1 parent b88a630 commit 0361e05

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

main/src/kotlinx/team/infra/Utils.kt

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package kotlinx.team.infra
22

3-
import groovy.lang.*
43
import org.gradle.api.*
54
import org.gradle.api.logging.*
65
import org.gradle.api.model.ObjectFactory
76
import org.gradle.api.tasks.*
87
import java.io.*
98

10-
fun cleanup(file: File) {
9+
internal fun cleanup(file: File) {
1110
if (file.exists()) {
1211
val listing = file.listFiles()
1312
if (listing != null) {
@@ -19,46 +18,27 @@ fun cleanup(file: File) {
1918
}
2019
}
2120

22-
inline fun <reified T : Task> Project.task(
21+
internal inline fun <reified T : Task> Project.task(
2322
name: String,
24-
depends: String? = null,
2523
noinline configuration: T.() -> Unit
26-
): TaskProvider<T> {
27-
@Suppress("UnstableApiUsage")
28-
val task = tasks.register(name, T::class.java, Action(configuration))
29-
if (depends != null) {
30-
tasks.getByName(depends).dependsOn(task)
31-
}
32-
return task
33-
}
34-
35-
class KotlinClosure1<T : Any?, V : Any>(
36-
val function: T.() -> V?,
37-
owner: Any? = null,
38-
thisObject: Any? = null
39-
) : Closure<T>(owner, thisObject) {
40-
41-
@Suppress("unused") // to be called dynamically by Groovy
42-
fun doCall(it: T): V? = it.function()
43-
}
44-
45-
fun <T> Any.closureOf(action: T.() -> Unit) : Closure<T> =
46-
KotlinClosure1<T, Unit>(action, this, this)
24+
): TaskProvider<T> =
25+
tasks.register(name, T::class.java, Action(configuration))
4726

48-
fun <T> Project.tryGetClass(className: String): Class<T>? {
27+
internal fun <T> Project.tryGetClass(className: String): Class<T>? {
4928
val classLoader = buildscript.classLoader
5029
return try {
30+
@Suppress("UNCHECKED_CAST")
5131
Class.forName(className, false, classLoader) as Class<T>
5232
} catch (e: ClassNotFoundException) {
5333
null
5434
}
5535
}
5636

57-
fun Logger.infra(message: String) {
37+
internal fun Logger.infra(message: String) {
5838
info("INFRA: $message")
5939
}
6040

61-
fun Project.propertyOrEnv(name: String): String? =
41+
internal fun Project.propertyOrEnv(name: String): String? =
6242
findProperty(name) as? String ?: System.getenv(name)
6343

6444
internal inline fun <reified T: Any> ObjectFactory.newInstance(): T = newInstance(T::class.java)

0 commit comments

Comments
 (0)