diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/Utils.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/Utils.kt index 9e082961c..2250b1062 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/Utils.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/Utils.kt @@ -15,7 +15,7 @@ internal inline val Project.runtimeConfiguration: Configuration get() { ?: configurations.getByName("runtime") } -internal inline fun ObjectFactory.property(defaultValue: T? = null): Property { +internal inline fun ObjectFactory.property(defaultValue: T? = null): Property { return property(T::class.java).apply { if (defaultValue != null) convention(defaultValue) } diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocator.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocator.kt index 216b81dce..be819e17b 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocator.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocator.kt @@ -23,25 +23,25 @@ public open class SimpleRelocator @JvmOverloads constructor( shadedPattern: String?, includes: List? = null, excludes: List? = null, - isRawString: Boolean = false, + rawString: Boolean = false, ) : Relocator { @get:Input @get:Optional - public open val pattern: Property = objectFactory.property() + public open val pattern: Property = objectFactory.property() @get:Input public open val pathPattern: Property = objectFactory.property() @get:Input @get:Optional - public open val shadedPattern: Property = objectFactory.property() + public open val shadedPattern: Property = objectFactory.property() @get:Input public open val shadedPathPattern: Property = objectFactory.property() @get:Input - public open val rawString: Property = objectFactory.property(isRawString) + public open val rawString: Property = objectFactory.property(rawString) @get:Input public open val includes: SetProperty = objectFactory.setProperty(String::class.java) @@ -50,11 +50,11 @@ public open class SimpleRelocator @JvmOverloads constructor( public open val excludes: SetProperty = objectFactory.setProperty(String::class.java) init { - if (isRawString) { + if (rawString) { pathPattern.set(pattern.orEmpty()) shadedPathPattern.set(shadedPattern.orEmpty()) this.pattern.set(null as String?) // not used for raw string relocator - this.shadedPathPattern.set(null as String?) // not used for raw string relocator + this.shadedPattern.set(null as String?) // not used for raw string relocator } else { if (pattern == null) { this.pattern.set("") @@ -64,8 +64,8 @@ public open class SimpleRelocator @JvmOverloads constructor( this.pathPattern.set(pattern.replace('.', '/')) } if (shadedPattern == null) { - this.shadedPattern.set("hidden.$pattern") - this.shadedPathPattern.set("hidden/$pathPattern") + this.shadedPattern.set(this.pattern.map { "hidden.$it" }) + this.shadedPathPattern.set(this.pathPattern.map { "hidden/$it" }) } else { this.shadedPattern.set(shadedPattern.replace('/', '.')) this.shadedPathPattern.set(shadedPattern.replace('.', '/')) @@ -116,14 +116,14 @@ public open class SimpleRelocator @JvmOverloads constructor( override fun relocateClass(context: RelocateClassContext): String { context.stats.relocate(pathPattern.get(), shadedPathPattern.get()) - return context.className.replaceFirst(pattern.get().orEmpty(), shadedPattern.get().orEmpty()) + return context.className.replaceFirst(pattern.orNull.orEmpty(), shadedPattern.orNull.orEmpty()) } override fun applyToSourceContent(sourceContent: String): String { return if (rawString.get()) { sourceContent } else { - sourceContent.replace("\\b$pattern.get()".toRegex(), shadedPattern.get().orEmpty()) + sourceContent.replace("\\b${pattern.orNull}".toRegex(), shadedPattern.orNull.orEmpty()) } }