Skip to content

Commit 87a5b3d

Browse files
committed
Rename skipStringLiteral to skipStringConstants
1 parent 5530f3e commit 87a5b3d

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

api/shadow.api

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public abstract interface class com/github/jengelman/gradle/plugins/shadow/reloc
112112
public abstract fun applyToSourceContent (Ljava/lang/String;)Ljava/lang/String;
113113
public abstract fun canRelocateClass (Ljava/lang/String;)Z
114114
public abstract fun canRelocatePath (Ljava/lang/String;)Z
115-
public fun getSkipStringLiteral ()Z
115+
public fun getSkipStringConstants ()Z
116116
public abstract fun relocateClass (Lcom/github/jengelman/gradle/plugins/shadow/relocation/RelocateClassContext;)Ljava/lang/String;
117117
public abstract fun relocatePath (Lcom/github/jengelman/gradle/plugins/shadow/relocation/RelocatePathContext;)Ljava/lang/String;
118118
}
@@ -137,12 +137,12 @@ public class com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocat
137137
public fun exclude (Ljava/lang/String;)V
138138
public final fun getExcludes ()Ljava/util/Set;
139139
public final fun getIncludes ()Ljava/util/Set;
140-
public fun getSkipStringLiteral ()Z
140+
public fun getSkipStringConstants ()Z
141141
public fun hashCode ()I
142142
public fun include (Ljava/lang/String;)V
143143
public fun relocateClass (Lcom/github/jengelman/gradle/plugins/shadow/relocation/RelocateClassContext;)Ljava/lang/String;
144144
public fun relocatePath (Lcom/github/jengelman/gradle/plugins/shadow/relocation/RelocatePathContext;)Ljava/lang/String;
145-
public fun setSkipStringLiteral (Z)V
145+
public fun setSkipStringConstants (Z)V
146146
}
147147

148148
public abstract interface class com/github/jengelman/gradle/plugins/shadow/tasks/DependencyFilter : java/io/Serializable {

src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ class RelocationTest : BasePluginTest() {
610610
)
611611
@ParameterizedTest
612612
@ValueSource(booleans = [false, true])
613-
fun canDisableRelocateStringConstants(skipStringLiteral: Boolean) {
613+
fun canDisableRelocateStringConstants(skipStringConstants: Boolean) {
614614
writeClassWithStringRef()
615615
projectScriptPath.appendText(
616616
"""
@@ -619,7 +619,7 @@ class RelocationTest : BasePluginTest() {
619619
attributes '$mainClassAttributeKey': 'my.Main'
620620
}
621621
relocate('junit', 'foo.junit') {
622-
skipStringLiteral = $skipStringLiteral
622+
skipStringConstants = $skipStringConstants
623623
}
624624
}
625625
""".trimIndent(),
@@ -628,13 +628,8 @@ class RelocationTest : BasePluginTest() {
628628
run(shadowJarTask)
629629
val result = runProcess("java", "-jar", outputShadowJar.use { it.toString() })
630630

631-
assertThat(result).contains(
632-
if (skipStringLiteral) {
633-
"junit.framework.Test"
634-
} else {
635-
"foo.junit.framework.Test"
636-
},
637-
)
631+
val expected = if (skipStringConstants) "junit.framework.Test" else "foo.junit.framework.Test"
632+
assertThat(result).contains(expected)
638633
}
639634

640635
private fun writeClassWithStringRef() {

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/RelocatorRemapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal class RelocatorRemapper(
4545
}
4646

4747
for (relocator in relocators) {
48-
if (mapLiterals && relocator.skipStringLiteral) {
48+
if (mapLiterals && relocator.skipStringConstants) {
4949
return name
5050
} else if (relocator.canRelocateClass(newName)) {
5151
return prefix + relocator.relocateClass(newName) + suffix

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/Relocator.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ public interface Relocator {
2020

2121
public fun applyToSourceContent(sourceContent: String): String
2222

23+
/**
24+
* Indicates whether this relocator should skip relocating string constants.
25+
*
26+
* Defaults to `false`.
27+
*/
2328
@get:Input
24-
public val skipStringLiteral: Boolean get() = false
29+
public val skipStringConstants: Boolean get() = false
2530

2631
public companion object {
2732
public val ROLE: String = Relocator::class.java.name

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public open class SimpleRelocator @JvmOverloads constructor(
1919
includes: List<String>? = null,
2020
excludes: List<String>? = null,
2121
private val rawString: Boolean = false,
22-
@get:Input override var skipStringLiteral: Boolean = false,
22+
@get:Input override var skipStringConstants: Boolean = false,
2323
) : Relocator {
2424
private val pattern: String
2525
private val pathPattern: String
@@ -138,7 +138,7 @@ public open class SimpleRelocator @JvmOverloads constructor(
138138
if (this === other) return true
139139
if (other !is SimpleRelocator) return false
140140
return rawString == other.rawString &&
141-
skipStringLiteral == other.skipStringLiteral &&
141+
skipStringConstants == other.skipStringConstants &&
142142
pattern == other.pattern &&
143143
pathPattern == other.pathPattern &&
144144
shadedPattern == other.shadedPattern &&
@@ -151,7 +151,7 @@ public open class SimpleRelocator @JvmOverloads constructor(
151151

152152
override fun hashCode(): Int {
153153
var result = rawString.hashCode()
154-
result = 31 * result + skipStringLiteral.hashCode()
154+
result = 31 * result + skipStringConstants.hashCode()
155155
result = 31 * result + pattern.hashCode()
156156
result = 31 * result + pathPattern.hashCode()
157157
result = 31 * result + shadedPattern.hashCode()

0 commit comments

Comments
 (0)