-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add the sources from apm-agent in to the final sources jar #3063
Conversation
elastic-apm-agent/pom.xml
Outdated
|
||
<target name="merge-sources" description="Merge source jars"> | ||
<zip destfile="${project.basedir}/target/${project.artifactId}-${project.version}-sources.jar"> | ||
<zipgroupfileset dir="${project.basedir}/../apm-agent/target/" includes="apm-agent-*-sources.jar"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I do however have an idea on how to get rid of the direct apm-agent
file based reference:
- use the
maven-dependency-plugin
execution in this pom above to explicitly copy the apm-agent sources JAR into the target folder (using the copy goal ) - use the copied sources-jar from the target folder instead of the file path
${project.basedir}/../apm-agent/target/
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that a slightly different config, it requires the dependency to be declared as such which then would be included in the class files. Then I tried to exclude the dependencies after including them, then they don't show in the sources. So if I then do that and then copy the source jar, then do the merge it might work - but sounds like a very complex addition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think I even tried it and couldn't get the sources if the classes were excluded, and couldn't prevent the classes from being the final class jar if they weren't even when I tried to exclude them also using the shade target. It was a really painful week
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice change, thank you! Much better
What does this PR do?
In 1.27.0 we restructured the subprojects so that all the main agent dependency management was moved from
elastic-apm-agent
toapm-agent
, with no direct dependency onapm-agent
fromelastic-apm-agent
. Instead it was made into a shaded dependency. This was to make the agent more isolated to reduce conflicts in classloading related to agent classes. An unnoticed side-effect of this was that the sources jar inelastic-apm-agent
no longer contained the full agent sources.To fix this, I tried a number of different configurations. Any configuration that directly added the
apm-agent
as a dependency caused the class jar file to contain the classes as well as the shaded classes, so those configurations failed. The shading plugin should have been able to create all the sources of the shaded dependencies, but although I tried really hard I couldn't find the magic combo that produced that. So I've gone with the brute force approach of just merging the sources from theapm-agent
sources jar into theelastic-apm-agent
sources jar. This has the advantage of being very simple, but the disadvantage of directly depending on a source jar file existing in another project.Additionally this PR fixes the missing
co.elastic.apm.agent.configuration
->co.elastic.apm.agent.premain.configuration
that @JonasKunz noticedChecklist