Skip to content

Commit ec62de4

Browse files
committed
Merge remote-tracking branch 'origin/main' into g/20250311/kotlin-new-app-block
// Conflicts: // src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt
2 parents f7964a0 + bdd1275 commit ec62de4

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

docs/changes/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- `ShadowSpec` no longer extends `CopySpec`.
1717
- Overload `relocate`, `transform` and things for better usability in Kotlin.
1818
- **BREAKING CHANGE:** Remove redundant types from function returning. ([#1308](https://github.com/GradleUp/shadow/pull/1308))
19+
- `runShadow` no longer depends on `installShadowDist`. ([#1353](https://github.com/GradleUp/shadow/pull/1353))
1920

2021
**Fixed**
2122

src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ApplicationPluginTest.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ class ApplicationPluginTest : BasePluginTest() {
4343
toolchain.languageVersion = JavaLanguageVersion.of(17)
4444
}
4545
""".trimIndent(),
46-
applicationBlock = """
47-
applicationDefaultJvmArgs = ['--add-opens=java.base/java.lang=ALL-UNNAMED']
48-
""".trimIndent(),
4946
settingsBlock = """
5047
plugins {
5148
id 'org.gradle.toolchains.foojay-resolver-convention'
@@ -65,6 +62,17 @@ class ApplicationPluginTest : BasePluginTest() {
6562
"Hello, World! (foo) from Main",
6663
"Refs: junit.framework.Test",
6764
)
65+
}
66+
67+
@Test
68+
fun installShadowOutputs() {
69+
prepare(
70+
mainClassWithImports = true,
71+
dependenciesBlock = "implementation 'junit:junit:3.8.2'",
72+
applicationBlock = "applicationDefaultJvmArgs = ['--add-opens=java.base/java.lang=ALL-UNNAMED']",
73+
)
74+
75+
run(installShadowDistTask)
6876

6977
val installPath = path("build/install/")
7078
assertThat(installPath.walkEntries()).containsOnly(
@@ -106,7 +114,7 @@ class ApplicationPluginTest : BasePluginTest() {
106114
fun installShadowDoesNotExecuteDependentShadowTask() {
107115
prepare()
108116

109-
run(SHADOW_INSTALL_TASK_NAME)
117+
run(installShadowDistTask)
110118

111119
commonAssertions(jarPath("build/install/myapp-shadow/lib/myapp-1.0-all.jar"))
112120
}
@@ -134,9 +142,9 @@ class ApplicationPluginTest : BasePluginTest() {
134142
}
135143
}
136144

137-
assertions(run(runShadowTask).output, "foo")
145+
assertions(run(runShadowTask, shadowJarTask).output, "foo")
138146
commonAssertions(
139-
jarPath("build/install/myapp-shadow/lib/myapp-1.0-all.jar"),
147+
jarPath("build/libs/myapp-1.0-all.jar"),
140148
entriesContained = entriesInA + arrayOf(mainClass, main2ClassEntry),
141149
mainClassAttr = "my.Main2",
142150
)

src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import assertk.assertThat
66
import assertk.assertions.doesNotContain
77
import assertk.assertions.isEqualTo
88
import assertk.assertions.isNotNull
9+
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaAppPlugin.Companion.SHADOW_INSTALL_TASK_NAME
910
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaAppPlugin.Companion.SHADOW_RUN_TASK_NAME
1011
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin.Companion.SHADOW_JAR_TASK_NAME
1112
import com.github.jengelman.gradle.plugins.shadow.internal.requireResourceAsPath
@@ -56,6 +57,7 @@ abstract class BasePluginTest {
5657
val shadowJarTask = ":$SHADOW_JAR_TASK_NAME"
5758
val serverShadowJarTask = ":server:$SHADOW_JAR_TASK_NAME"
5859
val runShadowTask = ":$SHADOW_RUN_TASK_NAME"
60+
val installShadowDistTask = ":$SHADOW_INSTALL_TASK_NAME"
5961
val shadowDistZipTask = ":shadowDistZip"
6062

6163
val projectScriptPath: Path get() = path("build.gradle")

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaAppPlugin.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator
2323
* A [Plugin] which packages and runs a project as a Java Application using the shadowed jar.
2424
*
2525
* Modified from [org.gradle.api.plugins.ApplicationPlugin.java](https://github.com/gradle/gradle/blob/45a20d82b623786d19b50185e595adf3d7b196b2/platforms/jvm/plugins-application/src/main/java/org/gradle/api/plugins/ApplicationPlugin.java).
26+
*
27+
* @see [ApplicationPlugin]
2628
*/
2729
public abstract class ShadowJavaAppPlugin : Plugin<Project> {
2830
override fun apply(project: Project) {
@@ -38,10 +40,7 @@ public abstract class ShadowJavaAppPlugin : Plugin<Project> {
3840
task.description = "Runs this project as a JVM application using the shadow jar"
3941
task.group = ApplicationPlugin.APPLICATION_GROUP
4042

41-
val jarFile = tasks.installShadowDist.zip(tasks.shadowJar) { i, s ->
42-
i.destinationDir.resolve("lib/${s.archiveFile.get().asFile.name}")
43-
}
44-
task.classpath(jarFile)
43+
task.classpath = files(tasks.shadowJar)
4544

4645
with(applicationExtension) {
4746
task.mainModule.set(mainModule)

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/Relocator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface Relocator {
2929
* In other words, it has its appropriate inputs annotated so that Gradle can consider them when
3030
* determining the cache key.
3131
*
32-
* @see CacheableTransformer
32+
* @see [CacheableTransformer]
3333
*/
3434
@Retention(AnnotationRetention.RUNTIME)
3535
@Target(AnnotationTarget.CLASS)

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import org.objectweb.asm.commons.ClassRemapper
2828

2929
/**
3030
* Modified from [org.gradle.api.internal.file.archive.ZipCopyAction.java](https://github.com/gradle/gradle/blob/b893c2b085046677cf858fb3d5ce00e68e556c3a/platforms/core-configuration/file-operations/src/main/java/org/gradle/api/internal/file/archive/ZipCopyAction.java).
31+
*
32+
* @see [org.gradle.api.internal.file.archive.ZipCopyAction]
3133
*/
3234
public open class ShadowCopyAction(
3335
private val zipFile: File,

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ResourceTransformer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public interface ResourceTransformer {
6464
* In other words, it has its appropriate inputs annotated so that Gradle can consider them when
6565
* determining the cache key.
6666
*
67-
* @see CacheableRelocator
67+
* @see [CacheableRelocator]
6868
*/
6969
@Retention(AnnotationRetention.RUNTIME)
7070
@Target(AnnotationTarget.CLASS)

0 commit comments

Comments
 (0)