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
2 changes: 1 addition & 1 deletion api/shadow.api
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar
protected abstract fun getArchiveOperations ()Lorg/gradle/api/file/ArchiveOperations;
public fun getConfigurations ()Lorg/gradle/api/provider/SetProperty;
public fun getDependencyFilter ()Lorg/gradle/api/provider/Property;
public fun getEnableRelocation ()Lorg/gradle/api/provider/Property;
public fun getEnableAutoRelocation ()Lorg/gradle/api/provider/Property;
public fun getExcludes ()Ljava/util/Set;
public fun getIncludedDependencies ()Lorg/gradle/api/file/ConfigurableFileCollection;
public fun getIncludes ()Ljava/util/Set;
Expand Down
12 changes: 12 additions & 0 deletions docs/changes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@

## [Unreleased](https://github.com/GradleUp/shadow/compare/9.0.0-rc2...HEAD) - 2025-xx-xx

**Changed**

- **BREAKING CHANGE:** Rename `ShadowJar`'s `enableRelocation` to `enableAutoRelocation`. ([#1541](https://github.com/GradleUp/shadow/pull/1541))
The Command Line options are also updated:
```
--enable-auto-relocation Enables auto relocation of packages in the dependencies.
--no-enable-auto-relocation Disables option --enable-auto-relocation.
--minimize-jar Minimizes the jar by removing unused classes.
--no-minimize-jar Disables option --minimize-jar.
--relocation-prefix Prefix used for auto relocation of packages in the dependencies.
--rerun Causes the task to be re-run even if up-to-date.
```

## [9.0.0-rc2](https://github.com/GradleUp/shadow/releases/tag/9.0.0-rc2) - 2025-07-23

Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/relocation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ Shadow is shipped with a task that can be used to automatically configure all pa
relocated. This feature was formally shipped into a 2nd plugin (`com.github.johnrengelman.plugin-shadow`) but has been
removed for clarity reasons in version 4.0.0.

To configure automatic dependency relocation, set `enableRelocation = true` and optionally specify a custom
To configure automatic dependency relocation, set `enableAutoRelocation = true` and optionally specify a custom
`relocationPrefix` to override the default value of `"shadow"`.

=== "Kotlin"

```kotlin
tasks.shadowJar {
enableRelocation = true
enableAutoRelocation = true
relocationPrefix = "myapp"
}
```
Expand All @@ -172,7 +172,7 @@ To configure automatic dependency relocation, set `enableRelocation = true` and

```groovy
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
enableRelocation = true
enableAutoRelocation = true
relocationPrefix = "myapp"
}
```
Expand Down
12 changes: 6 additions & 6 deletions docs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ build script. Passing property values on the command line is particularly helpfu
Here are the options that can be passed to the `shadowJar`:

```
--enable-relocation Enable relocation of packages in the jar
--no-enable-relocation Disables option --enable-relocation
--minimize-jar Minimize the jar by removing unused classes
--no-minimize-jar Disables option --minimize-jar
--relocation-prefix Prefix to use for relocated packages
--rerun Causes the task to be re-run even if up-to-date
--enable-auto-relocation Enables auto relocation of packages in the dependencies.
--no-enable-auto-relocation Disables option --enable-auto-relocation.
--minimize-jar Minimizes the jar by removing unused classes.
--no-minimize-jar Disables option --minimize-jar.
--relocation-prefix Prefix used for auto relocation of packages in the dependencies.
--rerun Causes the task to be re-run even if up-to-date.
```

Also, you can view more information about the [`ShadowJar`][ShadowJar] task by running the following command:
Expand Down
4 changes: 2 additions & 2 deletions docs/gradle-plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ task for relocation.
}

tasks.shadowJar {
enableRelocation = true
enableAutoRelocation = true
archiveClassifier = ""
}
```
Expand All @@ -52,7 +52,7 @@ task for relocation.
}

tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
enableRelocation = true
enableAutoRelocation = true
archiveClassifier = ''
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class JavaPluginTest : BasePluginTest() {
// Check self properties.
with(shadowTask) {
assertThat(minimizeJar.get()).isFalse()
assertThat(enableRelocation.get()).isFalse()
assertThat(enableAutoRelocation.get()).isFalse()
assertThat(relocationPrefix.get()).isEqualTo(ShadowBasePlugin.SHADOW)
assertThat(configurations.get()).all {
isNotEmpty()
Expand All @@ -103,11 +103,11 @@ class JavaPluginTest : BasePluginTest() {
val result = run("help", "--task", shadowJarTask)

assertThat(result.output).contains(
"--enable-relocation Enable relocation of packages in the jar",
"--no-enable-relocation Disables option --enable-relocation",
"--minimize-jar Minimize the jar by removing unused classes",
" --no-minimize-jar Disables option --minimize-jar",
"--relocation-prefix Prefix to use for relocated packages",
"--enable-auto-relocation Enables auto relocation of packages in the dependencies.",
"--no-enable-auto-relocation Disables option --enable-auto-relocation.",
"--minimize-jar Minimizes the jar by removing unused classes.",
"--no-minimize-jar Disables option --minimize-jar.",
"--relocation-prefix Prefix used for auto relocation of packages in the dependencies.",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RelocationTest : BasePluginTest() {
implementation 'junit:junit:3.8.2'
}
$shadowJar {
enableRelocation = true
enableAutoRelocation = true
relocationPrefix = '$relocationPrefix'
}
""".trimIndent(),
Expand Down Expand Up @@ -357,7 +357,7 @@ class RelocationTest : BasePluginTest() {

@ParameterizedTest
@MethodSource("preserveLastModifiedProvider")
fun preserveLastModifiedCorrectly(enableRelocation: Boolean, preserveFileTimestamps: Boolean) {
fun preserveLastModifiedCorrectly(enableAutoRelocation: Boolean, preserveFileTimestamps: Boolean) {
// Minus 3 sec to avoid the time difference between the file system and the JVM.
val currentTimeMillis = System.currentTimeMillis() - 3.seconds.inWholeMilliseconds
val junitEntryTimeRange = junitRawEntries.map { it.time }.let { it.min()..it.max() }
Expand All @@ -368,15 +368,15 @@ class RelocationTest : BasePluginTest() {
implementation 'junit:junit:3.8.2'
}
$shadowJar {
enableRelocation = $enableRelocation
enableAutoRelocation = $enableAutoRelocation
preserveFileTimestamps = $preserveFileTimestamps
}
""".trimIndent(),
)

run(shadowJarTask)

if (enableRelocation) {
if (enableAutoRelocation) {
val (relocatedEntries, otherEntries) = outputShadowJar.use {
it.entries().toList().partition { entry -> entry.name.startsWith("shadow/") }
}
Expand Down Expand Up @@ -544,7 +544,7 @@ class RelocationTest : BasePluginTest() {

@ParameterizedTest
@MethodSource("relocationCliOptionProvider")
fun enableRelocationByCliOption(enableRelocation: Boolean, relocationPrefix: String) {
fun enableAutoRelocationByCliOption(enableAutoRelocation: Boolean, relocationPrefix: String) {
val mainClassEntry = writeClass()
projectScriptPath.appendText(
"""
Expand All @@ -557,14 +557,14 @@ class RelocationTest : BasePluginTest() {
.filterNot { it.startsWith("$relocationPrefix/META-INF/") }
.toTypedArray()

if (enableRelocation) {
run(shadowJarTask, "--enable-relocation", "--relocation-prefix=$relocationPrefix")
if (enableAutoRelocation) {
run(shadowJarTask, "--enable-auto-relocation", "--relocation-prefix=$relocationPrefix")
} else {
run(shadowJarTask, "--relocation-prefix=$relocationPrefix")
}

assertThat(outputShadowJar).useAll {
if (enableRelocation) {
if (enableAutoRelocation) {
containsOnly(
"my/",
"$relocationPrefix/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public abstract class ShadowJar :
}

/**
* Minimize the jar by removing unused classes.
* Minimizes the jar by removing unused classes.
*
* Defaults to `false`.
*/
@get:Input
@get:Option(option = "minimize-jar", description = "Minimize the jar by removing unused classes")
@get:Option(option = "minimize-jar", description = "Minimizes the jar by removing unused classes.")
public open val minimizeJar: Property<Boolean> = objectFactory.property(false)

@get:Classpath
Expand Down Expand Up @@ -135,21 +135,25 @@ public abstract class ShadowJar :
}

/**
* Enable relocation of packages in the jar.
* Enables auto relocation of packages in the dependencies.
*
* Defaults to `false`.
*
* @see relocationPrefix
*/
@get:Input
@get:Option(option = "enable-relocation", description = "Enable relocation of packages in the jar")
public open val enableRelocation: Property<Boolean> = objectFactory.property(false)
@get:Option(option = "enable-auto-relocation", description = "Enables auto relocation of packages in the dependencies.")
public open val enableAutoRelocation: Property<Boolean> = objectFactory.property(false)

/**
* Prefix to use for relocated packages.
* Prefix used for auto relocation of packages in the dependencies.
*
* Defaults to `shadow`.
*
* @see enableAutoRelocation
*/
@get:Input
@get:Option(option = "relocation-prefix", description = "Prefix to use for relocated packages")
@get:Option(option = "relocation-prefix", description = "Prefix used for auto relocation of packages in the dependencies.")
public open val relocationPrefix: Property<String> = objectFactory.property(ShadowBasePlugin.SHADOW)

@Internal
Expand Down Expand Up @@ -380,7 +384,7 @@ public abstract class ShadowJar :

private val packageRelocators: List<SimpleRelocator>
get() {
if (!enableRelocation.get()) return emptyList()
if (!enableAutoRelocation.get()) return emptyList()
val prefix = relocationPrefix.get()
return includedDependencies.files.flatMap { file ->
JarFile(file).use { jarFile ->
Expand Down