com.github.jengelman.gradle.plugins.shadow.internal.Utils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadow-gradle-plugin Show documentation
Show all versions of shadow-gradle-plugin Show documentation
Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
package com.github.jengelman.gradle.plugins.shadow.internal
import java.io.InputStream
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.provider.Property
/**
* Return `runtimeClasspath` or `runtime` configuration.
*/
internal inline val Project.runtimeConfiguration: Configuration get() {
return configurations.findByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
?: configurations.getByName("runtime")
}
internal inline fun ObjectFactory.property(defaultValue: T? = null): Property {
return property(T::class.java).apply {
if (defaultValue != null) convention(defaultValue)
}
}
@Suppress("NOTHING_TO_INLINE")
internal inline fun unsafeLazy(noinline initializer: () -> T): Lazy =
lazy(LazyThreadSafetyMode.NONE, initializer)
internal fun Class<*>.requireResourceAsText(name: String): String {
return requireResourceAsStream(name).bufferedReader().readText()
}
private fun Class<*>.requireResourceAsStream(name: String): InputStream {
return getResourceAsStream(name) ?: error("Resource $name not found.")
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy