Skip to content

Document how to make a shadowed JAR the default output of a project#1937

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/address-issue-1893
Draft

Document how to make a shadowed JAR the default output of a project#1937
Copilot wants to merge 4 commits intomainfrom
copilot/address-issue-1893

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

In multi-project builds, consumers currently must explicitly select the shadow configuration (project(path = ":foo", configuration = "shadow")), making it easy to accidentally depend on the unshadowed JAR. This PR documents how to reconfigure apiElements/runtimeElements so the shadowed JAR becomes the default artifact.

Changes

  • docs/multi-project/README.md: New section "Making the Shadowed JAR the Default Artifact"

    • Shows reconfiguring apiElements and runtimeElements to replace the default JAR with the shadowed JAR (Kotlin + Groovy DSL)
    • Shows that consumers can then use plain implementation(project(":foo"))
    • Includes optional pattern for adding exclude rules to drop bundled transitive deps
    • Links to Gradle docs on consumable configurations and exclude rules
  • src/functionalTest/kotlin/.../JavaPluginsTest.kt: Two new integration tests

    • shadowJarIsDefaultArtifactInMultiProjectBuild: verifies that reconfiguring apiElements/runtimeElements exposes the shadow JAR (foo-1.0-all.jar) as the default artifact on the consumer's classpath instead of the regular JAR (foo-1.0.jar)
    • excludeRulesPreventBundledDepsOnConsumerClasspath: verifies that adding exclude rules to the configurations prevents bundled transitive dependencies from appearing separately on the consumer's classpath
// foo/build.gradle.kts
configurations {
  named("apiElements") {
    outgoing.artifacts.clear()
    outgoing.artifact(tasks.shadowJar)
  }
  named("runtimeElements") {
    outgoing.artifacts.clear()
    outgoing.artifact(tasks.shadowJar)
  }
}

// consumer/build.gradle.kts — no need to specify configuration = "shadow"
dependencies {
  implementation(project(":foo"))
}

  • CHANGELOG's "Unreleased" section has been updated, if applicable.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…project builds (#1893)

Co-authored-by: Goooler <10363352+Goooler@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue number 1893 docs: document how to make shadowed JAR the default project artifact in multi-project builds Feb 27, 2026
@Goooler
Copy link
Member

Goooler commented Feb 27, 2026

@copilot Add integration tests for verifying these cases.

#1893)

Co-authored-by: Goooler <10363352+Goooler@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot Add integration tests for verifying these cases.

Added two integration tests in commit 37538f0:

  1. shadowJarIsDefaultArtifactInMultiProjectBuild — sets up a foo project (java-library + shadow) that bundles my:a:1.0 and reconfigures apiElements/runtimeElements to expose the shadow JAR. Verifies a consumer using implementation project(':foo') gets foo-1.0-all.jar (shadow JAR) on its classpath, not foo-1.0.jar.

  2. excludeRulesPreventBundledDepsOnConsumerClasspath — same setup with exclude rules added to the configurations. Verifies the bundled transitive dep (a-1.0.jar) does not appear separately on the consumer's classpath.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xmx4g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)
    • Triggering command: /usr/bin/curl curl -s --max-time 10 REDACTED (dns block)
    • Triggering command: /usr/bin/curl curl -v --max-time 10 REDACTED (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xmx4g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Goooler Goooler changed the title docs: document how to make shadowed JAR the default project artifact in multi-project builds Document how to make a shadowed JAR the default output of a project Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants