Skip to content

Migrate shadow plugin from com.github.johnrengelman to com.gradleup (fixes #2862)#2945

Open
thejainamjain wants to merge 15 commits into
newrelic:mainfrom
thejainamjain:migrate-shadow-plugin-to-gradleup
Open

Migrate shadow plugin from com.github.johnrengelman to com.gradleup (fixes #2862)#2945
thejainamjain wants to merge 15 commits into
newrelic:mainfrom
thejainamjain:migrate-shadow-plugin-to-gradleup

Conversation

@thejainamjain

Copy link
Copy Markdown

Closes #2862

What this does

Migrates the shadow Gradle plugin from the deprecated com.github.johnrengelman.shadow
to the GradleUp fork com.gradleup.shadow, pinned at exactly 8.3.0.

Why 8.3.0 specifically

  • com.gradleup.shadow starts at 8.3.0; no earlier version exists under this coordinate
  • Shadow 8.3.4+ broke Java 8 support per upstream reports; 8.3.0 is the last version
    confirmed safe for Java 8 builds
  • Shadow 8.3.0 requires Gradle 8.3+, so a wrapper upgrade was also required (see below)

Changes beyond a plugin ID swap

This turned out to require more than a string substitution:

Gradle wrapper: 7.5.1 → 8.3
com.gradleup.shadow enforces Gradle 8.3+ at runtime and will not apply on 7.5.1.

buildSrc/build.gradle

  • Updated plugin dependency coordinate
  • Added explicit org.apache.ant:ant:1.10.14 — shadow 8.3.0 no longer shades Ant
    internally; it declares Ant as runtime scope in its own POM but Gradle does not
    pull this transitively into buildSrc compilation, causing ZipEntry/ZipOutputStream
    to be missing at compile time. Pinned to 1.10.14 to match shadow 8.3.0's own POM.

DependencyPatcher.java + Log4j2PluginFileMover.java

  • Updated zip imports from shadow.org.apache.tools.zip.* (shaded, now gone) to
    org.apache.tools.zip.* (unshaded, confirmed via javap on shadow 8.3.0 jar)
  • Added getName() override — shadow 8.3.0's Transformer interface now extends
    org.gradle.api.Named, making getName() an abstract requirement

Gradle 8 API fixes (required by the wrapper upgrade)

  • cache_weave_attributes.gradle.kts: JavaExec.mainmainClass
  • infinite-tracing/build.gradle.kts: jacoco.reportsDir removed, xml.isEnabled
    xml.required, html.destinationhtml.outputLocation
  • newrelic-weaver/build.gradle: replaced undefined jdk8 property (which Gradle 8
    no longer resolves leniently on repository containers) with javaToolchains.compilerFor
    to dynamically resolve the JDK 8 installation path

Verified

  • ./gradlew :buildSrc:build :newrelic-opentelemetry-agent-extension:shadowJar passes
    clean with JDK 8 (Zulu 8.94) and Gradle 8.3
  • Java 8 toolchain constraint preserved throughout; no source/target compatibility changes
  • Transformer and TransformerContext class paths unchanged in 8.3.0 — no interface
    rename needed (that only happens in shadow 9.0.0)

…issue newrelic#2862)

- Replace plugin id and dependency coord with com.gradleup.shadow:shadow-gradle-plugin:8.3.0
  in buildSrc/build.gradle, instrumentation-build, and newrelic-opentelemetry-agent-extension
- Add explicit org.apache.ant:ant:1.10.14 dependency to buildSrc; shadow 8.3.0 no longer
  bundles/shades Ant internally so ZipEntry/ZipOutputStream are not available transitively
- Fix zip imports in DependencyPatcher and Log4j2PluginFileMover from shaded
  shadow.org.apache.tools.zip.* to unshaded org.apache.tools.zip.*
- Add getName() override to both Transformer implementations; shadow 8.3.0 Transformer
  interface now extends org.gradle.api.Named requiring this method
- Upgrade Gradle wrapper 7.5.1 -> 8.3; com.gradleup.shadow requires Gradle 8.3 minimum
- Fix Gradle 8 API removals required by the wrapper upgrade:
  - cache_weave_attributes.gradle.kts: JavaExec.main -> mainClass
  - infinite-tracing/build.gradle.kts: jacoco.reportsDir removed, xml.isEnabled -> required,
    html.destination -> html.outputLocation
  - newrelic-weaver/build.gradle: replace undefined jdk8 property reference with
    javaToolchains.compilerFor API to resolve JDK 8 path dynamically

Pinned shadow at exactly 8.3.0 (not later) because 8.3.4+ broke Java 8 support per
upstream reports. Verified Transformer/TransformerContext interfaces unchanged at 8.3.0
so no interface-name migration needed.
@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@thejainamjain

Copy link
Copy Markdown
Author

@jasonjkeller

@jtduffy

jtduffy commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Hi @thejainamjain

I've pulled your branch and ran into a blocker. To build the full agent and the resulting artifact, the gradle command is:
./gradlew clean jar --parallel using a v8 JDK.

When attempting to build with your branch, we get the following error:

A problem was found with the configuration of task ':newrelic-agent:generateVersionProperties' (type 'DefaultTask').
  - Gradle detected a problem with the following location: 'newrelic-java-agent/newrelic-agent/build/resources/main/com/newrelic/agent/Agent.properties'.

    Reason: Task ':newrelic-agent:compileJava11Java' uses this output of task ':newrelic-agent:generateVersionProperties' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':newrelic-agent:generateVersionProperties' as an input of ':newrelic-agent:compileJava11Java'.
      2. Declare an explicit dependency on ':newrelic-agent:generateVersionProperties' from ':newrelic-agent:compileJava11Java' using Task#dependsOn.
      3. Declare an explicit dependency on ':newrelic-agent:generateVersionProperties' from ':newrelic-agent:compileJava11Java' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.

I know getting a build environment setup can be a challenge, especially as it relates to some of the sub-modules that require some closed source compile time jars. If you would like to tackle the above issue and push up to your branch, I'm happy to work through this with you so we can arrive at a successful merge into the agent.

I'm also happy to take what you have so far and complete it on our end (with appropriate credit for your contributions). Let us know how you want to proceed. Thanks again for the contribution!

…teVersionProperties

Gradle 8 strict validation catches implicit task dependencies that Gradle 7
allowed silently. compileJava11Java reads Agent.properties produced by
generateVersionProperties without declaring it as a dependency, causing
failures in parallel builds (./gradlew clean jar --parallel).
@thejainamjain

thejainamjain commented Jun 17, 2026

Copy link
Copy Markdown
Author

Hi @jtduffy
thanks for pulling the branch and testing it yourself, really appreciate the detailed feedback!

Made the fix - compileJava11Java now explicitly declares its dependency on generateVersionProperties, which Gradle 8's stricter task validation requires. Verified ./gradlew clean jar --parallel with JDK 8 completes successfully.

Happy to make any further adjustments if anything else comes up on your end. Looking forward to getting this merged!

@thejainamjain

Copy link
Copy Markdown
Author

One thing worth noting - when running the full build including tests, compileTestAgentExtensionJava in newrelic-opentelemetry-agent-extension fails with cannot find symbol: method getBrowserTimingFooter(). This appears to be a pre-existing issue unrelated to the shadow migration (the file is untouched by this PR). Just flagging in case it's something on your end to track separately.

@jtduffy

jtduffy commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@thejainamjain
If you like, you can remove those references to the getBrowserTimingFooter in that test for the otel-agent-extension project and simply add them to this PR. It's a small enough change so I don't think we need another PR just for that.

We're still reviewing the gradle changes and should have some feedback for you tomorrow.

@thejainamjain

thejainamjain commented Jun 17, 2026

Copy link
Copy Markdown
Author

Done @jtduffy
removed the getBrowserTimingFooter() references from the smoke test and pushed. Compiles clean now. Looking forward to your feedback on the Gradle changes!

getBrowserTimingFooter() was deprecated in agent 8.9.0 and subsequently
removed from the NewRelic API. The smoke test's purpose is to exercise
the full API surface area; the footer calls are no longer part of that
surface. getBrowserTimingHeader() already covers the RUM API section.
@thejainamjain thejainamjain force-pushed the migrate-shadow-plugin-to-gradleup branch from 99f9330 to 08c0e4d Compare June 17, 2026 19:35
@jtduffy

jtduffy commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@thejainamjain If you want, please pull in my changes from my working branch to yours. It contains other fixes for some instrumentation modules and other build items.

I'm still running regression tests on so I may have more changes/feedback in the next couple of days

@jtduffy jtduffy moved this from Triage to In Progress in Java Engineering Board Jun 22, 2026
@jtduffy

jtduffy commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@thejainamjain There is one more minor commit I made that you can pull into your branch. For some reason, the verifier was getting an OOM error when running against the apache-camel-3.9.0 module.

@jtduffy

jtduffy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Successful PR test run in #2950

@jtduffy

jtduffy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@thejainamjain Hey one last thing and then the team will do a full review. Can you remove the file instrumentation/spring-dispatcher-servlet-conversion.md‎ from the PR? I accidentally added to my branch and it shouldn't be there.

@thejainamjain

Copy link
Copy Markdown
Author

Hey @jtduffy, done! Removed instrumentation/spring-dispatcher-servlet-conversion.md from the PR.

@jtduffy

jtduffy commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

I will be doing a squash merge on this on Monday June 29th after I return from FTO so I can be around in case issues pop up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Migrate gradle shadow plugin to the GradleUp version

3 participants