@@ -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,31 @@ class RelocationTest : BasePluginTest() {
643
625
""" .trimIndent(),
644
626
)
645
627
646
- run (shadowJarTask) {
647
- it.withDebug(true )
648
- }
649
-
650
- val pathString = outputShadowJar.use { it.toString() }
651
- val result = runProcess(" java" , " -jar" , pathString)
628
+ run (shadowJarTask)
629
+ val result = runProcess(" java" , " -jar" , outputShadowJar.use { it.toString() })
652
630
653
631
assertThat(result).contains(
654
632
if (skipStringLiteral) {
655
- " the value is junit.framework.Test"
633
+ " junit.framework.Test"
656
634
} else {
657
- " the value is foo.junit.framework.Test"
635
+ " foo.junit.framework.Test"
658
636
},
659
637
)
660
638
}
661
639
640
+ private fun writeClassWithStringRef () {
641
+ writeClass {
642
+ """
643
+ package my;
644
+ public class Main {
645
+ public static void main(String[] args) {
646
+ System.out.println("junit.framework.Test");
647
+ }
648
+ }
649
+ """ .trimIndent()
650
+ }
651
+ }
652
+
662
653
private companion object {
663
654
@JvmStatic
664
655
fun prefixProvider () = listOf (
0 commit comments