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
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ on:

jobs:
build:
name: OS=${{ matrix.os }}, Java=${{ matrix.java }}, Gradle=${{ matrix.gradle }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
# Always test on the latest version and some LTS.
java: [ 17, 21, 24 ]
# Test on the minimum Gradle version and the latest.
gradle: [ 8.11, current ]
exclude:
# Gradle 8.11 doesn't support Java 24.
- gradle: 8.11
java: 24
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -22,7 +29,7 @@ jobs:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- uses: gradle/actions/setup-gradle@v4
- run: ./gradlew build
- run: ./gradlew build "-PtestGradleVersion=${{ matrix.gradle }}"

# There's no need to run the update task frequently; the start scripts are typically updated with Gradle releases.
update-start-scripts:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Gradle plugin for creating fat/uber JARs with support for package relocation.
| 7.0.0+ | 7.x | 8 | [`com.github.johnrengelman.shadow`][johnrengelman's] |
| 8.0.0+ | 8.0 | 8 | [`com.github.johnrengelman.shadow`][johnrengelman's] |
| 8.3.0+ | 8.3 | 8 | [`com.gradleup.shadow`][gradleup's] |
| 9.0.0+ | 8.3 | 11 | [`com.gradleup.shadow`][gradleup's] |
| 9.0.0+ | 8.11 | 11 | [`com.gradleup.shadow`][gradleup's] |



Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ testing.suites {
}
targets.configureEach {
testTask {
val testGradleVersion = providers.gradleProperty("testGradleVersion").orNull.let {
if (it == null || it == "current") GradleVersion.current().version else it
}
logger.info("Using test Gradle version: $testGradleVersion")
systemProperty("TEST_GRADLE_VERSION", testGradleVersion)

maxParallelForks = Runtime.getRuntime().availableProcessors()
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependent libraries into the output jar without incurring the I/O overhead of ex
| 7.0.0+ | 7.x | 8 | [`com.github.johnrengelman.shadow`][johnrengelman's] |
| 8.0.0+ | 8.0 | 8 | [`com.github.johnrengelman.shadow`][johnrengelman's] |
| 8.3.0+ | 8.3 | 8 | [`com.gradleup.shadow`][gradleup's] |
| 9.0.0+ | 8.3 | 11 | [`com.gradleup.shadow`][gradleup's] |
| 9.0.0+ | 8.11 | 11 | [`com.gradleup.shadow`][gradleup's] |

## Benefits of Shadow

Expand Down
1 change: 1 addition & 0 deletions docs/changes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

**Changed**

- Bump the min Gradle requirement to 8.11. ([#1479](https://github.com/GradleUp/shadow/pull/1479))
- Expose Ant as `compile` scope. ([#1488](https://github.com/GradleUp/shadow/pull/1488))

## [9.0.0-beta17](https://github.com/GradleUp/shadow/releases/tag/9.0.0-beta17) - 2025-06-18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ sealed class SnippetExecutable : Executable {

try {
GradleRunner.create()
.withGradleVersion(testGradleVersion)
.withProjectDir(projectRoot.toFile())
.withPluginClasspath()
.forwardOutput()
Expand Down Expand Up @@ -97,6 +98,9 @@ sealed class SnippetExecutable : Executable {
}

companion object {
private val testGradleVersion = System.getProperty("TEST_GRADLE_VERSION")
?: error("TEST_GRADLE_VERSION system property is not set.")

fun create(
lang: DslLang,
snippet: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ abstract class BasePluginTest {
arguments: Iterable<String> = emptyList(),
projectDir: Path? = projectRoot,
): GradleRunner = GradleRunner.create()
.withGradleVersion(testGradleVersion)
.forwardOutput()
.withPluginClasspath()
.withTestKitDir(testKitDir.toFile())
Expand All @@ -391,6 +392,9 @@ abstract class BasePluginTest {

@Suppress("ConstPropertyName")
companion object {
private val testGradleVersion = System.getProperty("TEST_GRADLE_VERSION")
?: error("TEST_GRADLE_VERSION system property is not set.")

val testKitDir: Path = run {
var gradleUserHome = System.getenv("GRADLE_USER_HOME")
if (gradleUserHome == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.bundling.Jar
import org.gradle.testfixtures.ProjectBuilder
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.condition.DisabledForJreRange
import org.junit.jupiter.api.condition.JRE
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource

Expand Down Expand Up @@ -92,35 +90,6 @@ class JavaPluginTest : BasePluginTest() {
assertThat(shadowConfig.artifacts.files).contains(shadowTask.archiveFile.get().asFile)
}

@Test
@DisabledForJreRange(
min = JRE.JAVA_21,
disabledReason = "Gradle 8.3 doesn't support Java 21.",
)
fun compatibleWithMinGradleVersion() {
val mainClassEntry = writeClass(withImports = true)
projectScriptPath.appendText(
"""
dependencies {
implementation 'junit:junit:3.8.2'
}
""".trimIndent(),
)

run(shadowJarTask) {
it.withGradleVersion("8.3")
}

assertThat(outputShadowJar).useAll {
containsOnly(
"my/",
mainClassEntry,
*junitEntries,
*manifestEntries,
)
}
}

@Test
fun incompatibleWithLowerMinGradleVersion() {
runWithFailure(shadowJarTask) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.gradle.util.GradleVersion
public abstract class ShadowBasePlugin : Plugin<Project> {

override fun apply(project: Project): Unit = with(project) {
if (GradleVersion.current() < GradleVersion.version("8.3")) {
throw GradleException("This version of Shadow supports Gradle 8.3+ only. Please upgrade.")
if (GradleVersion.current() < GradleVersion.version("8.11")) {
throw GradleException("This version of Shadow supports Gradle 8.11+ only. Please upgrade.")
}
@Suppress("DEPRECATION")
extensions.create(EXTENSION_NAME, ShadowExtension::class.java, project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.jengelman.gradle.plugins.shadow.internal

import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.distribution.DistributionContainer
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.model.ObjectFactory
Expand All @@ -18,7 +17,6 @@ import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.jvm.tasks.Jar
import org.gradle.jvm.toolchain.JavaToolchainService
import org.gradle.util.GradleVersion

/**
* Return `runtimeClasspath` or `runtime` configuration.
Expand Down Expand Up @@ -83,27 +81,9 @@ internal inline fun <reified V : Any> ObjectFactory.mapProperty(
}
}

/**
* TODO: this could be removed after bumping the min Gradle requirement to 8.8 or above.
*/
internal inline fun ObjectFactory.fileCollection(
path: () -> Any,
): ConfigurableFileCollection = fileCollection().apply {
@Suppress("UnstableApiUsage")
if (GradleVersion.current() >= GradleVersion.version("8.8")) {
convention(path())
} else {
setFrom(path())
}
}

/**
* TODO: this could be removed after bumping the min Gradle requirement to 8.11 or above.
*/
internal fun ProjectDependency.dependencyProjectCompat(project: Project): Project {
return if (GradleVersion.current() >= GradleVersion.version("8.11")) {
project.project(path)
} else {
return this::class.java.getDeclaredMethod("getDependencyProject").invoke(this) as Project
}
convention(path())
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal class UnusedTracker(
apiDependencies.forEach { dep ->
when (dep) {
is ProjectDependency -> {
apiJars.addAll(getApiJarsFromProject(dep.dependencyProjectCompat(project)))
apiJars.addAll(getApiJarsFromProject(project.project(dep.path)))
addJar(runtimeConfiguration, dep, apiJars)
}
is FileCollectionDependency -> {
Expand Down