Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2241ccd
Bump
Goooler Jun 19, 2025
3e3bf60
Mark `ShadowJar` as abstract
Goooler Jun 19, 2025
bf1e8c2
Remove Java 11 and add Java 24 into test matrix
Goooler Nov 21, 2024
aeaeedc
Replace `SelfResolvingDependency` with `FileCollectionDependency`
Goooler Jun 19, 2025
5b9a54f
Remove `ShadowCopyAction.ArchiveFileTreeElement.getMode`
Goooler Jun 19, 2025
bcf0cea
Mark `JavaJarExec` as abstract
Goooler Jun 19, 2025
055efaa
org.spockframework:spock-core:2.3-groovy-4.0
Goooler Jun 19, 2025
072d66d
Remove static for `TransformerTestSupport.transformer`
Goooler Jun 19, 2025
adfd31e
Replace `org.gradle.api.UncheckedIOException`
Goooler Jun 19, 2025
635ab61
Merge remote-tracking branch 'origin/8.x' into g/20250619/gradle-9-fo…
Goooler Jun 19, 2025
3faf7d6
Compat `dependencyProject`
Goooler Jun 19, 2025
685fef2
Replace `mainClassName` with `mainClass` for `CreateStartScripts`
Goooler Jun 19, 2025
8c231df
Compat `RelativeArchivePath.getParent` for Groovy 3 and 4
Goooler Jun 19, 2025
748c074
Annotate `RelocatorRemapper` with `CompileStatic`
Goooler Jun 19, 2025
4af1df6
Update changelog
Goooler Jun 19, 2025
6cdb9d0
Revert "Remove `ShadowCopyAction.ArchiveFileTreeElement.getMode`"
Goooler Jun 20, 2025
e3782de
Remove `@Override` for `getMode`
Goooler Jun 20, 2025
91fb2a0
Merge remote-tracking branch 'origin/8.x' into g/20250619/gradle-9-fo…
Goooler Jun 23, 2025
fd20b2f
Add Gradle 8.3 into test matrix
Goooler Jun 23, 2025
37546c3
Compat `RelocationUtil#configureRelocation` for Groovy 3 and 4
Goooler Jun 23, 2025
34f03f7
Log info
Goooler Jun 23, 2025
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
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
# Always test on the latest version and all LTS.
java: [ 11, 17, 21, 23 ]
# Always test on the latest version and some LTS.
java: [ 17, 21, 24 ]
# Test on the minimum Gradle version and the latest.
gradle: [ 8.3, current ]
exclude:
# Gradle 8.3 doesn't support Java 24.
- gradle: 8.3
java: 24
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -22,7 +28,7 @@ jobs:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- uses: gradle/actions/setup-gradle@v4
- run: ./gradlew build
- run: ./gradlew build --info "-PtestGradleVersion=${{ matrix.gradle }}"

publish-snapshot:
needs: build
Expand Down
8 changes: 7 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies {
implementation("org.apache.logging.log4j:log4j-core:2.24.1")
implementation("org.vafer:jdependency:2.13")

testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") {
testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") {
exclude(group = "org.codehaus.groovy")
exclude(group = "org.hamcrest")
}
Expand All @@ -111,6 +111,12 @@ val isCI = providers.environmentVariable("CI").isPresent
tasks.withType<Test>().configureEach {
useJUnitPlatform()

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()

if (isCI) {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-1-bin.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 This may not even be required if you want to keep the change set smaller.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is unnecessary. But it would be easier to track and test Gradle 9 releases.

networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
8 changes: 4 additions & 4 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/docs/changes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## [Unreleased]

**Fixed**

- Fix compatibility for Gradle 9.0.0 RC1. ([#1470](https://github.com/GradleUp/shadow/pull/1470))


## [v8.3.6] (2025-02-02)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ShadowApplicationPlugin implements Plugin<Project> {
startScripts.description = 'Creates OS specific scripts to run the project as a JVM application using the shadow jar'
startScripts.group = ApplicationPlugin.APPLICATION_GROUP
startScripts.classpath = project.files(jar)
startScripts.conventionMapping.mainClassName = { javaApplication.mainClass.get() }
startScripts.mainClass.set(javaApplication.mainClass)
startScripts.conventionMapping.applicationName = { javaApplication.applicationName }
startScripts.conventionMapping.outputDir = { new File(project.layout.buildDirectory.asFile.get(), 'scriptsShadow') }
startScripts.conventionMapping.defaultJvmOpts = { javaApplication.applicationDefaultJvmArgs }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.github.jengelman.gradle.plugins.shadow.relocation.RelocateClassContex
import com.github.jengelman.gradle.plugins.shadow.relocation.RelocatePathContext
import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.RelativeArchivePath
import groovy.transform.CompileStatic
import org.objectweb.asm.commons.Remapper

import java.util.regex.Matcher
Expand All @@ -34,6 +35,7 @@ import java.util.regex.Pattern
*
* @author John Engelman
*/
@CompileStatic
class RelocatorRemapper extends Remapper {

private final Pattern classPattern = Pattern.compile("(\\[*)?L(.+)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package com.github.jengelman.gradle.plugins.shadow.internal

import org.apache.tools.zip.Zip64Mode
import org.apache.tools.zip.ZipOutputStream
import org.gradle.api.UncheckedIOException

class DefaultZipCompressor implements ZipCompressor {
private final int entryCompressionMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskAction

class JavaJarExec extends JavaExec {
abstract class JavaJarExec extends JavaExec {

@InputFile
File jarFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class RelocationUtil {
JarFile jf = new JarFile(jar)
jf.entries().each { entry ->
if (entry.name.endsWith(".class") && entry.name != "module-info.class") {
packages << entry.name[0..entry.name.lastIndexOf('/') - 1].replaceAll('/', '.')
def i = entry.name.lastIndexOf('/')
if (i != -1) {
packages << entry.name.take(i).replaceAll('/', '.')
}
}
}
jf.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package com.github.jengelman.gradle.plugins.shadow.internal
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.FileCollectionDependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.SelfResolvingDependency
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.InputFiles
import org.gradle.util.GradleVersion
import org.vafer.jdependency.Clazz
import org.vafer.jdependency.Clazzpath
import org.vafer.jdependency.ClazzpathUnit
Expand Down Expand Up @@ -70,10 +71,10 @@ class UnusedTracker {
def apiJars = new LinkedList<File>()
apiDependencies.each { dep ->
if (dep instanceof ProjectDependency) {
apiJars.addAll(getApiJarsFromProject(dep.dependencyProject))
apiJars.addAll(getApiJarsFromProject(dependencyProjectCompat(dep, project)))
addJar(runtimeConfiguration, dep, apiJars)
} else if (dep instanceof SelfResolvingDependency) {
apiJars.addAll(dep.resolve())
} else if (dep instanceof FileCollectionDependency) {
apiJars.addAll(dep.files)
} else {
addJar(runtimeConfiguration, dep, apiJars)
apiJars.add(runtimeConfiguration.find { it.name.startsWith("${dep.name}-") } as File)
Expand All @@ -82,4 +83,14 @@ class UnusedTracker {

return project.files(apiJars)
}

/**
* TODO: this could be removed after bumping the min Gradle requirement to 8.11 or above.
*/
private static dependencyProjectCompat(ProjectDependency projectDependency, Project project) {
if (GradleVersion.current() >= GradleVersion.version("8.11")) {
return project.project(projectDependency.path)
}
return projectDependency.dependencyProject
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.apache.tools.zip.ZipFile
import org.apache.tools.zip.ZipOutputStream
import org.gradle.api.Action
import org.gradle.api.GradleException
import org.gradle.api.UncheckedIOException
import org.gradle.api.file.FileCopyDetails
import org.gradle.api.file.FilePermissions
import org.gradle.api.file.FileTreeElement
Expand Down Expand Up @@ -460,7 +459,7 @@ class ShadowCopyAction implements CopyAction {
return null
} else {
//Parent is always a directory so add / to the end of the path
String path = segments[0..-2].join('/') + '/'
String path = segments.take(segments.length - 1).join('/') + '/'
return new RelativeArchivePath(setArchiveTimes(new ZipEntry(path)))
}
}
Expand Down Expand Up @@ -528,7 +527,9 @@ class ShadowCopyAction implements CopyAction {
return archivePath
}

@Override
/**
* This method should be annotated with @Override, but the parent has been removed from Gradle 9.
*/
int getMode() {
return archivePath.entry.unixMode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.concurrent.Callable;

@CacheableTask
public class ShadowJar extends Jar implements ShadowSpec {
public abstract class ShadowJar extends Jar implements ShadowSpec {

private List<Transformer> transformers;
private List<Relocator> relocators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ include 'api', 'main'

buildFile.text = replaceTokens(fullSnippet)

GradleRunner runner = GradleRunner.create().withProjectDir(tempDir).withPluginClasspath().forwardOutput()
GradleRunner runner = GradleRunner.create()
.withGradleVersion(PluginSpecification.TEST_GRADLE_VERSION)
.withProjectDir(tempDir)
.withPluginClasspath()
.forwardOutput()

runner.withArguments(":main:build", "-m").build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ApacheNoticeResourceTransformerParameterTests extends TransformerTestSuppo
processAndFailOnNullPointer("\n")
}

private static void processAndFailOnNullPointer(final String noticeText) {
private void processAndFailOnNullPointer(final String noticeText) {
try {
final ByteArrayInputStream noticeInputStream = new ByteArrayInputStream(noticeText.getBytes())
final List<Relocator> emptyList = Collections.emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.gradle.api.file.RelativePath
import org.gradle.api.internal.file.DefaultFileTreeElement

abstract class TransformerTestSupport<T extends Transformer> {
protected static T transformer
protected T transformer

protected static FileTreeElement getFileElement(String path) {
return new DefaultFileTreeElement(null, RelativePath.parse(true, path), null, null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.jengelman.gradle.plugins.shadow.util;

import org.gradle.api.UncheckedIOException;
import org.gradle.internal.UncheckedException;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ abstract class PluginSpecification extends Specification {

public static final String SHADOW_VERSION = System.getProperty("shadowVersion")

public static final String TEST_GRADLE_VERSION = System.getProperty("TEST_GRADLE_VERSION")

AppendableMavenFileRepository repo

def setup() {
Expand Down Expand Up @@ -55,6 +57,7 @@ abstract class PluginSpecification extends Specification {

GradleRunner getRunner() {
GradleRunner.create()
.withGradleVersion(TEST_GRADLE_VERSION)
.withProjectDir(dir.toFile())
.forwardOutput()
.withPluginClasspath()
Expand Down