@@ -585,16 +585,7 @@ class RelocationTest : BasePluginTest() {
585
585
586
586
@Test
587
587
fun relocateStringConstantsByDefault () {
588
- writeClass {
589
- """
590
- package my;
591
- public class Main {
592
- public static void main(String[] args) {
593
- System.out.println("junit.framework.Test");
594
- }
595
- }
596
- """ .trimIndent()
597
- }
588
+ writeClassWithStringRef()
598
589
projectScriptPath.appendText(
599
590
"""
600
591
$shadowJar {
@@ -614,22 +605,13 @@ class RelocationTest : BasePluginTest() {
614
605
)
615
606
}
616
607
608
+ @Issue(
609
+ " https://github.com/GradleUp/shadow/issues/232" ,
610
+ )
617
611
@ParameterizedTest
618
612
@ValueSource(booleans = [false , true ])
619
613
fun canDisableRelocateStringConstants (skipStringLiteral : Boolean ) {
620
- writeClass {
621
- """
622
- package my;
623
- public class Main {
624
- public static final String junit = "junit.framework.Test";
625
- public static void main(String[] args) {
626
- System.out.println(getValue() + junit);
627
- }
628
- // Use this method to force the compiler to not inline the string literal.
629
- private static String getValue() { return "the value is "; }
630
- }
631
- """ .trimIndent()
632
- }
614
+ writeClassWithStringRef()
633
615
projectScriptPath.appendText(
634
616
"""
635
617
$shadowJar {
@@ -643,22 +625,33 @@ class RelocationTest : BasePluginTest() {
643
625
""" .trimIndent(),
644
626
)
645
627
646
- run (shadowJarTask) {
647
- it.withDebug(true )
648
- }
628
+ run (shadowJarTask)
649
629
650
630
val pathString = outputShadowJar.use { it.toString() }
651
631
val result = runProcess(" java" , " -jar" , pathString)
652
632
653
633
assertThat(result).contains(
654
634
if (skipStringLiteral) {
655
- " the value is junit.framework.Test"
635
+ " junit.framework.Test"
656
636
} else {
657
- " the value is foo.junit.framework.Test"
637
+ " foo.junit.framework.Test"
658
638
},
659
639
)
660
640
}
661
641
642
+ private fun writeClassWithStringRef () {
643
+ writeClass {
644
+ """
645
+ package my;
646
+ public class Main {
647
+ public static void main(String[] args) {
648
+ System.out.println("junit.framework.Test");
649
+ }
650
+ }
651
+ """ .trimIndent()
652
+ }
653
+ }
654
+
662
655
private companion object {
663
656
@JvmStatic
664
657
fun prefixProvider () = listOf (
0 commit comments