From 421d2c439f4c4d41858ad45775111a1687abc2b1 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 12 Jan 2025 15:01:42 +0800 Subject: [PATCH] Check Class-Path in shadowed Gradle plugin jar --- .../gradle/plugins/shadow/ShadowPluginTest.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPluginTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPluginTest.kt index 91f9d778d..d73eee5b4 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPluginTest.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPluginTest.kt @@ -3,10 +3,13 @@ package com.github.jengelman.gradle.plugins.shadow import assertk.all import assertk.assertThat import assertk.assertions.contains +import assertk.assertions.doesNotContain import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty import assertk.assertions.isNotNull import assertk.assertions.isNull import assertk.assertions.isTrue +import assertk.assertions.single import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin.Companion.SHADOW_JAR_TASK_NAME import com.github.jengelman.gradle.plugins.shadow.legacy.LegacyShadowPlugin import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar @@ -738,6 +741,7 @@ class ShadowPluginTest : BasePluginTest() { @Issue( "https://github.com/GradleUp/shadow/issues/459", + "https://github.com/GradleUp/shadow/issues/852", ) @Test fun excludeGradleApiByDefault() { @@ -765,8 +769,15 @@ class ShadowPluginTest : BasePluginTest() { run(shadowJarTask) - val entries = outputShadowJar.use { it.entries().toList() } - assertThat(entries.count { it.name.endsWith(".class") }).isEqualTo(1) + assertThat(outputShadowJar).useAll { + transform { actual -> actual.entries().toList().map { it.name }.filter { it.endsWith(".class") } } + .single().isEqualTo("my/plugin/MyPlugin.class") + transform { it.manifest.mainAttributes.keys }.all { + isNotEmpty() + // Doesn't contain Gradle classes. + doesNotContain("Class-Path") + } + } } @Issue(