Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ val integrationTest by tasks.registering(Test::class) {
testClassesDirs = intiTest.output.classesDirs
classpath = intiTest.runtimeClasspath

// TODO: this should be moved into functionalTest after we migrated all functional tests to Kotlin.
// Required to enable `IssueExtension` for all tests.
systemProperty("junit.jupiter.extensions.autodetection.enabled", true)

val docsDir = file("src/docs")
// Add src/docs as an input directory to trigger ManualCodeSnippetTests re-run on changes.
inputs.dir(docsDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import assertk.assertThat
import assertk.assertions.exists
import assertk.assertions.isEqualTo
import assertk.assertions.isInstanceOf
import com.github.jengelman.gradle.plugins.shadow.util.Issue
import java.net.URLClassLoader
import java.util.jar.JarFile
import kotlin.io.path.appendText
Expand Down Expand Up @@ -50,9 +51,9 @@ class RelocationTest : BasePluginTest() {
)
}

/**
* https://github.com/GradleUp/shadow/issues/58
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/58",
)
@Test
fun relocateDependencyFiles() {
projectScriptPath.appendText(
Expand Down Expand Up @@ -179,10 +180,10 @@ class RelocationTest : BasePluginTest() {
)
}

/**
* https://github.com/GradleUp/shadow/issues/53
* https://github.com/GradleUp/shadow/issues/55
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/53",
"https://github.com/GradleUp/shadow/issues/55",
)
@Test
fun remapClassNamesForRelocatedFilesInProjectSource() {
projectScriptPath.appendText(
Expand Down Expand Up @@ -314,10 +315,10 @@ class RelocationTest : BasePluginTest() {
)
}

/**
* https://github.com/GradleUp/shadow/issues/93
* https://github.com/GradleUp/shadow/issues/114
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/93",
"https://github.com/GradleUp/shadow/issues/114",
)
@Test
fun relocateResourceFiles() {
repo.module("shadow", "dep", "1.0")
Expand Down Expand Up @@ -363,9 +364,9 @@ class RelocationTest : BasePluginTest() {
)
}

/**
* https://github.com/GradleUp/shadow/issues/294
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/294",
)
@Test
fun doesNotErrorOnRelocatingJava9Classes() {
projectScriptPath.appendText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import assertk.assertions.isNull
import assertk.assertions.isTrue
import com.github.jengelman.gradle.plugins.shadow.legacy.LegacyShadowPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.util.Issue
import java.util.jar.JarFile
import kotlin.io.path.appendText
import kotlin.io.path.readText
Expand Down Expand Up @@ -556,9 +557,9 @@ class ShadowPluginTest : BasePluginTest() {
assertThat(attributes.getValue("Class-Path")).isNull()
}

/**
* https://github.com/GradleUp/shadow/issues/65
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/65",
)
@Test
fun addShadowConfigurationToClassPathInManifest() {
projectScriptPath.appendText(
Expand All @@ -581,9 +582,9 @@ class ShadowPluginTest : BasePluginTest() {
assertThat(attributes.getValue("Class-Path")).isEqualTo("/libs/a.jar junit-3.8.2.jar")
}

/**
* https://github.com/GradleUp/shadow/issues/92
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/92",
)
@Test
fun doNotIncludeNullValueInClassPathWhenJarFileDoesNotContainClassPath() {
projectScriptPath.appendText(
Expand All @@ -601,9 +602,9 @@ class ShadowPluginTest : BasePluginTest() {
assertThat(attributes.getValue("Class-Path")).isEqualTo("junit-3.8.2.jar")
}

/**
* https://github.com/GradleUp/shadow/issues/203
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/203",
)
@Test
fun supportZipCompressionStored() {
projectScriptPath.appendText(
Expand All @@ -625,9 +626,10 @@ class ShadowPluginTest : BasePluginTest() {

/**
* This spec requires > 15 minutes and > 8GB of disk space to run
*
* https://github.com/GradleUp/shadow/issues/143
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/143",
)
@Disabled
@Test
fun checkLargeZipFilesWithZip64Enabled() {
Expand Down Expand Up @@ -690,9 +692,9 @@ class ShadowPluginTest : BasePluginTest() {
assertThat(result.output).contains("TestApp: Hello World! (foo)")
}

/**
* https://github.com/GradleUp/shadow/issues/609
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/609",
)
@Test
fun doesNotErrorWhenUsingApplicationMainClassProperty() {
projectScriptPath.appendText(
Expand Down Expand Up @@ -724,9 +726,9 @@ class ShadowPluginTest : BasePluginTest() {
assertThat(result.output).contains("TestApp: Hello World! (foo)")
}

/**
* https://github.com/GradleUp/shadow/pull/459
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/459",
)
@Test
fun excludeGradleApiByDefault() {
projectScriptPath.writeText(
Expand Down Expand Up @@ -759,9 +761,9 @@ class ShadowPluginTest : BasePluginTest() {
assertThat(entries.count { it.name.endsWith(".class") }).isEqualTo(1)
}

/**
* https://github.com/GradleUp/shadow/issues/1070
*/
@Issue(
"https://github.com/GradleUp/shadow/issues/1070",
)
@Test
fun canRegisterCustomShadowJarTask() {
val testShadowJarTask = "testShadowJar"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.jengelman.gradle.plugins.shadow.util

import org.junit.jupiter.api.Tags
import org.junit.jupiter.api.extension.BeforeEachCallback
import org.junit.jupiter.api.extension.ExtensionContext
import org.junit.jupiter.api.extension.ExtensionContext.Namespace

/**
* This is related to [spock.lang.Issue](https://github.com/spockframework/spock/blob/master/spock-core/src/main/java/spock/lang/Issue.java) but is used for JUnit 5 tests.
*
* @see [Tags]
*/
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class Issue(vararg val values: String)

class IssueExtension : BeforeEachCallback {
override fun beforeEach(context: ExtensionContext) {
val issueAnnotation = context.requiredTestMethod.getAnnotation(Issue::class.java) ?: return
val store = context.getStore(Namespace.create(IssueExtension::class.java, context.requiredTestClass))
store.put("tags", issueAnnotation.values.map(::issueLinkToTag))
}
}

private fun issueLinkToTag(link: String): String {
return issueLinkRegex.replace(link) { matchResult ->
"ISSUE-${matchResult.groupValues[1]}"
}
}

private val issueLinkRegex = "https://github\\.com/[^/]+/[^/]+/issues/(\\d+)".toRegex()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.github.jengelman.gradle.plugins.shadow.util.IssueExtension
Loading