Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Class-Path in shadowed Gradle plugin jar #1149

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not work properly. The key set is Set<Object> instead of Set<String>.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing in #1161.

}
}
}

@Issue(
Expand Down
Loading