Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0ea96b4
Add includedSourcesJars
Goooler Sep 1, 2026
a312982
Generate shadowed sources jar when includedSourcesJars is present
Goooler Sep 1, 2026
24fba42
Extract generateShadowedSourcesJar logic to internal package
Goooler Sep 1, 2026
5d4f2c3
Use module g for shadowed sources jar functional test
Goooler Sep 1, 2026
1d383df
Configure sourceSetsSourceDirs in ShadowJavaPlugin and ShadowKmpPlugin
Goooler Sep 1, 2026
59bcafa
Update changelog
Goooler Sep 1, 2026
04118a4
Allow generating shadowed sources jar when project sources are presen…
Goooler Sep 1, 2026
8d99b41
Support publishing shadow sources jar
Goooler Sep 1, 2026
85f1aa5
Remove outdated comment for applyToSourceContent
Goooler Sep 1, 2026
93c8d73
Add documentation and test for generating Javadoc/Dokka from shadowed…
Goooler Sep 1, 2026
ecad8e4
Clean up ShadowJavaPlugin
Goooler Sep 2, 2026
68c2e1b
Set Dokka properties via gradle.properties as workaround for IP
Goooler Sep 2, 2026
0f814e5
Clean docs/publishing/README.md
Goooler Sep 2, 2026
f4eab8f
Clean up tests
Goooler Sep 2, 2026
935c73b
Filter unused classes when generating shadowed sources jar
Goooler Sep 2, 2026
476b36d
Extract declared package from source files to determine canonical pat…
Goooler Sep 2, 2026
e07d3be
Extract createDefaultLocalMavenRepository to LocalMavenRepository.kt
Goooler Sep 2, 2026
23adce5
Pass zos for generateShadowedSourcesJar
Goooler Sep 2, 2026
30b2c88
Revert "Pass zos for generateShadowedSourcesJar"
Goooler Sep 2, 2026
d231e62
Filter included sources jars based on DependencyFilter include and ex…
Goooler Sep 2, 2026
4d0ca8a
Document Shadowed Sources JAR features, publication and configuration
Goooler Sep 2, 2026
51d5feb
Support bundling sources JAR from local subproject dependencies
Goooler Sep 2, 2026
0100ab2
Use Worker API
Goooler Sep 2, 2026
09c2cea
Revert "Use Worker API"
Goooler Sep 2, 2026
0ca34cc
Include META-INF/MANIFEST.MF in shadowed sources JAR
Goooler Sep 2, 2026
03c024f
Fix KMP publications configuration in publishing docs
Goooler Sep 2, 2026
95650a7
Explicitly configure sources classifier for publications
Goooler Sep 3, 2026
cd245cb
Cache unusedClasses and packageRelocators by lazy
Goooler Sep 3, 2026
0350f8f
Revert "Cache unusedClasses and packageRelocators by lazy"
Goooler Sep 3, 2026
1b26f8b
Remove currentTimeMillis for lastModified
Goooler Sep 3, 2026
5232d50
Update regexes
Goooler Sep 3, 2026
6079bbc
Safe cast for DefaultDependencyFilter
Goooler Sep 3, 2026
ac67d84
Only publish shadowSourcesElements when java sources variant is present
Goooler Sep 3, 2026
e13c3b3
Merge remote-tracking branch 'origin/main' into g/20260901/sources-jar
Goooler Sep 3, 2026
41142b1
Ensure deterministic sources JAR entry ordering and fix jvmNameRegex
Goooler Sep 3, 2026
7edd7d6
Clarify shadowed sources JAR generation vs publishing in docs
Goooler Sep 3, 2026
485aa65
Expose sourceSetsSourceDirs and includedSourcesJars as public with do…
Goooler Sep 3, 2026
984fee4
Annotate includedSourcesJars with @InputFiles and @PathSensitive(NONE)
Goooler Sep 3, 2026
ea3d529
Introduce generateSourcesJar property gated by withSourcesJar by default
Goooler Sep 3, 2026
e449d2e
Merge remote-tracking branch 'origin/main' into g/20260901/sources-jar
Goooler Sep 3, 2026
97105cd
Polish error message in generateShadowedSourcesJar
Goooler Sep 3, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Support manifest header relocation via configurable `attributesToRelocate` property.
- Allow disabling default ProGuard rules in R8 minimization with `R8Spec.useDefaultRules`. ([#2252](https://github.com/GradleUp/shadow/pull/2252))
- Allow passing classpath files to R8 minimization with `R8Spec.classpath`. ([#2255](https://github.com/GradleUp/shadow/pull/2255))
- Support shadowed sources JAR. ([#2265](https://github.com/GradleUp/shadow/pull/2265))

### Changed

Expand Down
6 changes: 6 additions & 0 deletions api/shadow.api
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugi
public static final field COMPONENT_NAME Ljava/lang/String;
public static final field Companion Lcom/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin$Companion;
public static final field SHADOW_RUNTIME_ELEMENTS_CONFIGURATION_NAME Ljava/lang/String;
public static final field SHADOW_SOURCES_ELEMENTS_CONFIGURATION_NAME Ljava/lang/String;
public fun <init> (Lorg/gradle/api/component/SoftwareComponentFactory;)V
public synthetic fun apply (Ljava/lang/Object;)V
public fun apply (Lorg/gradle/api/Project;)V
Expand All @@ -69,6 +70,7 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugi

public final class com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin$Companion {
public final synthetic fun getShadowRuntimeElements (Lorg/gradle/api/artifacts/ConfigurationContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
public final synthetic fun getShadowSourcesElements (Lorg/gradle/api/artifacts/ConfigurationContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
}

public abstract class com/github/jengelman/gradle/plugins/shadow/ShadowKmpPlugin : org/gradle/api/Plugin {
Expand Down Expand Up @@ -259,6 +261,7 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar
public fun getAddMultiReleaseAttribute ()Lorg/gradle/api/provider/Property;
public fun getApiJars ()Lorg/gradle/api/file/ConfigurableFileCollection;
protected abstract fun getArchiveOperations ()Lorg/gradle/api/file/ArchiveOperations;
public fun getArchiveSourcesFile ()Lorg/gradle/api/file/RegularFileProperty;
public fun getConfigurations ()Lorg/gradle/api/provider/SetProperty;
public fun getDependencyFilter ()Lorg/gradle/api/provider/Property;
public fun getDuplicatesStrategy ()Lorg/gradle/api/file/DuplicatesStrategy;
Expand All @@ -267,7 +270,9 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar
public fun getExcludes ()Ljava/util/Set;
protected abstract fun getExecOperations ()Lorg/gradle/process/ExecOperations;
public fun getFailOnDuplicateEntries ()Lorg/gradle/api/provider/Property;
public fun getGenerateSourcesJar ()Lorg/gradle/api/provider/Property;
public fun getIncludedDependencies ()Lorg/gradle/api/file/ConfigurableFileCollection;
public fun getIncludedSourcesJars ()Lorg/gradle/api/file/ConfigurableFileCollection;
public fun getIncludes ()Ljava/util/Set;
public fun getJavaLauncher ()Lorg/gradle/api/provider/Property;
public fun getMainClass ()Lorg/gradle/api/provider/Property;
Expand All @@ -279,6 +284,7 @@ public abstract class com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar
public fun getRelocationPrefix ()Lorg/gradle/api/provider/Property;
public fun getRelocators ()Lorg/gradle/api/provider/SetProperty;
public fun getSourceSetsClassesDirs ()Lorg/gradle/api/file/ConfigurableFileCollection;
public fun getSourceSetsSourceDirs ()Lorg/gradle/api/file/ConfigurableFileCollection;
public fun getToMinimize ()Lorg/gradle/api/file/ConfigurableFileCollection;
public fun getTransformers ()Lorg/gradle/api/provider/SetProperty;
public fun mergeGroovyExtensionModules ()V
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ dependencies {

testPluginRuntimeOnly(libs.foojayResolver)
testPluginRuntimeOnly(libs.pluginPublish)
testPluginRuntimeOnly(libs.dokka)

lintChecks(libs.androidx.gradlePluginLints)
}
Expand Down
10 changes: 10 additions & 0 deletions docs/configuration/minimizing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ rules published in dependency JARs, for example under `META-INF/proguard`.
> Alternatively, if you use [R8 Repackaging][r8-repackaging] (e.g. `-repackageclasses`), R8 applies embedded rules
> natively without needing rule rewriting.

> [!NOTE]
> **Shadowed Sources JAR and R8**
>
> R8 operates directly on compiled JVM bytecode rather than source code. When minimizing with R8 (`minimize { r8 { ... } }`),
> Shadow cannot determine which source files correspond to classes removed by R8. Therefore, the shadowed sources JAR will
> contain all relocated source files without responding to R8 shrinking results.
>
> If you need unused source files to be filtered out of the shadowed sources JAR, use the default dependency analyzer
> minimization (`minimize()`) instead.

=== ":material-language-kotlin: build.gradle.kts"

```kotlin
Expand Down
8 changes: 7 additions & 1 deletion docs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ in their build logic), Shadow will automatically configure the following behavio
- `META-INF/*.RSA`
- `META-INF/versions/**/module-info.class`
- `module-info.class`
- Configures the [`ShadowJar`][ShadowJar] task to generate a companion **Shadowed Sources JAR** containing both
project sources and shadowed dependency sources with relocated packages when `java.withSourcesJar()` is enabled
(or when [`generateSourcesJar`][ShadowJar.generateSourcesJar] is set to `true`).
- Creates and registers the `shadow` component in the project (used for integrating with
[`maven-publish`][maven-publish]).
[`maven-publish`][maven-publish]), including the `shadowSourcesElements` variant when `java.withSourcesJar()` is enabled.

## ShadowJar Command Line options

Expand All @@ -155,6 +158,8 @@ Here are the options that can be passed to the `shadowJar`:
--no-enable-kotlin-module-remapping Disables option --enable-kotlin-module-remapping.
--fail-on-duplicate-entries Fails build if the ZIP entries in the shadowed JAR are duplicate.
--no-fail-on-duplicate-entries Disables option --fail-on-duplicate-entries.
--generate-sources-jar Generates a companion shadowed sources JAR containing project and dependency sources.
--no-generate-sources-jar Disables option --generate-sources-jar.
--main-class Main class attribute to add to manifest.
--minimize-jar Minimizes the jar by removing unused classes.
--no-minimize-jar Disables option --minimize-jar.
Expand All @@ -175,5 +180,6 @@ Refer to [listing command line options][listing-command-line-options].
[JavaPlugin]: https://docs.gradle.org/current/userguide/java_plugin.html
[maven-publish]: https://docs.gradle.org/current/userguide/publishing_maven.html
[ShadowJar]: ../api/shadow/com.github.jengelman.gradle.plugins.shadow.tasks/-shadow-jar/index.html
[ShadowJar.generateSourcesJar]: ../api/shadow/com.github.jengelman.gradle.plugins.shadow.tasks/-shadow-jar/generate-sources-jar.html
[gradle-plugin-portal]: https://plugins.gradle.org/plugin/com.gradleup.shadow
[listing-command-line-options]: https://docs.gradle.org/current/userguide/custom_tasks.html#sec:listing_task_options
4 changes: 4 additions & 0 deletions docs/kotlin-plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ automatically configure additional tasks for bundling the shadowed JAR for its `
}
```

For details on publishing shadowed artifacts and sources JAR in KMP projects, see
[Publishing with Kotlin Multiplatform (KMP)][publishing-with-kmp].

## Kotlin Module Metadata Remapping

Kotlin module metadata (`.kotlin_module`) files contain information about package parts and facades. When relocating
Expand Down Expand Up @@ -169,4 +172,5 @@ To explicitly apply this remapping (recommended for future compatibility), add
[KotlinModuleMetadataTransformer]: ../api/shadow/com.github.jengelman.gradle.plugins.shadow.transformers/-kotlin-module-metadata-transformer/index.html
[dependency-on-the-standard-library]: https://kotlinlang.org/docs/gradle-configure-project.html#dependency-on-the-standard-library
[publishing-libraries]: ../publishing/README.md
[publishing-with-kmp]: ../publishing/README.md#publishing-with-kotlin-multiplatform-kmp
[running-applications]: ../application-plugin/README.md
Loading