javaagent-gradle-plugin icon indicating copy to clipboard operation
javaagent-gradle-plugin copied to clipboard

The plugin doesn't work with the gradle shadow plugin

Open swamyrajamohan opened this issue 1 year ago • 3 comments

When used with the gradle-shadow plugin and creating the shadowDistTar or shadowDistZip instead of the regular distZip and distTar provided by the application plugin the resultant distributions don't contain the agent-libs directory in the distribution (zip/tar).

tar produced by the distTar after applying the javaagent-gradle-plugin agent-libs # containing the javaagent lib bin # containing the startup scripts lib # containing the dependent libraries and application jar

tar produced by the distTar after applying the javaagent-gradle-plugin #Misses the agent-libs folder containing javaagent lib bin # containing the startup scripts lib # containing the dependent libraries and application jar

plugins {
    id 'java'
    id 'groovy'
    id 'application'
    id 'com.ryandens.javaagent-application' version '0.4.2'  
    id 'maven-publish'
    id 'com.github.jk1.dependency-license-report' version '2.5'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
    id 'org.sonarqube' version '4.4.1.3373'
    id 'org.owasp.dependencycheck' version '9.0.9'
}

swamyrajamohan avatar Mar 11 '24 20:03 swamyrajamohan

Tried it with the newer version 0.5.1 as well and still the same issue

swamyrajamohan avatar Mar 11 '24 20:03 swamyrajamohan

👋 i wouldn't expect it to work with the artifacts built by the shadow task - feel free to make a PR! If you want to make a specific proposal around any api changes, let me know. I'm unfamiliar with the purpose of the shadowDistTar and shadowDistZip tasks? My understanding was the purpose of the shadow plugin was to create an uber-jar that could be run in a standalone fashion. What is the purpose of putting an uber-jar inside of a tar/zip that uses a start script and abstracts away adding dependencies to the classpath? Adding support for a new plugin integration creates a maintenance burden, so I would need to see a compelling reason for folks to actually use a javaagent with these distributions.

Note that javaagents themselves can't be shaded into the shadow jar, as they need to be specified with the -javaagent flag or registered programatically. Perhaps you're looking for something like https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/static-instrumenter

ryandens avatar Mar 12 '24 00:03 ryandens

I think this is the same as #94, where I've included a potential workaround @swamyrajamohan

tajobe avatar Apr 10 '24 15:04 tajobe

closed as duplicate of #94

ryandens avatar Apr 26 '24 15:04 ryandens