@@ -10,6 +10,7 @@ import com.github.jengelman.gradle.plugins.shadow.util.JvmLang
1010import com.github.jengelman.gradle.plugins.shadow.util.containsAtLeast
1111import com.github.jengelman.gradle.plugins.shadow.util.containsOnly
1212import com.github.jengelman.gradle.plugins.shadow.util.getMainAttr
13+ import com.github.jengelman.gradle.plugins.shadow.util.runProcess
1314import kotlin.io.path.appendText
1415import kotlin.io.path.writeText
1516import org.junit.jupiter.api.BeforeEach
@@ -268,6 +269,49 @@ class KotlinPluginsTest : BasePluginTest() {
268269 )
269270 }
270271
272+ @Issue(
273+ " https://github.com/GradleUp/shadow/issues/1622" ,
274+ )
275+ @Test
276+ fun relocateKotlinReflectFull () {
277+ projectScript.writeText(
278+ """
279+ ${getDefaultProjectBuildScript(plugin = " org.jetbrains.kotlin.jvm" , withGroup = true , withVersion = true )}
280+ dependencies {
281+ implementation 'org.jetbrains.kotlin:kotlin-reflect'
282+ }
283+ $shadowJarTask {
284+ manifest {
285+ attributes '$mainClassAttributeKey ': 'my.MainKt'
286+ }
287+ enableAutoRelocation = true
288+ mergeServiceFiles() // Merge and relocate service files from kotlin-reflect.
289+ }
290+ """ .trimIndent(),
291+ )
292+ writeClass(jvmLang = JvmLang .Kotlin ) {
293+ """
294+ package my
295+ import kotlin.reflect.full.memberProperties
296+
297+ fun main() {
298+ println(MemberClass()::class.memberProperties)
299+ }
300+ private class MemberClass {
301+ val prop1 = "property 1"
302+ val prop2 by lazy { "property 2" }
303+ }
304+ """ .trimIndent()
305+ }
306+
307+ run (shadowJarPath)
308+ val result = runProcess(" java" , " -jar" , outputShadowedJar.use { it.toString() })
309+
310+ assertThat(result).contains(
311+ " [val my.MemberClass.prop1: kotlin.String, val my.MemberClass.prop2: kotlin.String]" ,
312+ )
313+ }
314+
271315 private fun compileOnlyStdlib (exclude : Boolean ): String {
272316 return if (exclude) {
273317 // Disable the stdlib dependency added via `implementation`.
0 commit comments