-
Notifications
You must be signed in to change notification settings - Fork 179
[JENKINS-65757] only use pluginFirst classloader when you have no other option (and never for guice!) #151
Conversation
FileFilter just joined the passed in excludes as a comma separated list and added defaults if the list was empty or null, But the code already handles this so just call the Plex util directly
@@ -530,7 +361,6 @@ THE SOFTWARE. | |||
</execution> | |||
</executions> | |||
<configuration> | |||
<pluginFirstClassLoader>true</pluginFirstClassLoader> |
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.
we do not need this, we are safe with maskClasses
now after removing other conflicting libraries
@@ -19,7 +19,6 @@ | |||
import org.jacoco.core.data.ExecutionDataReader; | |||
import org.jacoco.core.data.ExecutionDataStore; | |||
import org.jacoco.core.data.SessionInfoStore; | |||
import org.jacoco.maven.FileFilter; |
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.
this caused a whole slew of the maven dependencies and for no real reason.
@@ -122,9 +121,8 @@ private IBundleCoverage analyzeStructure() throws IOException { | |||
excludes = ITEM_ZERO; |
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.
so this is the default exclude - but I have no idea why. the default in maven in the empty String, but here we use "{0}"
🤷
public class E2ETest { | ||
|
||
@Rule | ||
public RealJenkinsRule rjr = new RealJenkinsRule(); |
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.
} | ||
|
||
private static List<Builder> createJacocoProjectBuilders() { | ||
String[] commands = { "git clone --branch jacoco-3.2.0 https://github.com/jenkinsci/jacoco-plugin.git .", |
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.
whilst running maven inside a test is not the best, we are using this project as the test (and a tag) so we at least have most of the dependencies already local.
It will diverge over time, so we may want to try and keep this somewhat in sync
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.
So binaries "git" and "mvn" need to be available on the CI node for this to work, right?
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.
yes, but maven already is as it is what runs the build that runs this test :)
as for git
the CI could have cloned using jgit
rather than the git
CLI so it may not be available, but ci.jenkins.io is not setup like that.
A developer could work exclusively with IntelliJ or Eclipse (again jgit
) but I am not convinced that is likely.
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.
For a more reproducible environment:
- store a small test project in
src/test/resources/sampleproj/
- use
dependency:copy
to unpack a specific release of Maven intotarget/test-classes/
but still use the Java in path I guess.
JDK11 and JDK8 compilers generate different bytecode and so asserting the bytecode instruction coverage would need to be different on potentially different compilers (e.g eclipse vs jdk 8 vs jdk11 vs ...)
the shade plugin was bound to a phase that did not exist in the hpi packaging type. even if it did it would be completely unclear what it did as the shade plugin does not play nicely with hpis.
I loaded the PR build https://ci.jenkins.io/job/Plugins/job/jacoco-plugin/job/PR-151/4/ into my Jenkins instance and confirmed that it reports JaCoCo coverage as expected for the platformlabeler plugin test job that uses it. Thanks so much for your work on this @jtnord ! |
Thanks for the suggested simplification, would be nice to be able to merge this. Some of these dependencies were necessary to make "validate" succeed and not complain about mismatched versions, did you try running that maven target as well? e.g. the following needs to succeed to be able to release: Also some tests seem to be failing in CI, is this caused by some of the changes? |
|
@centic9 any link? - all the statuses are green after 40f5613 and the failures I saw on ci.jenkins.io (which caused me to retrigger the build) where due to agent infrastructure issues and not test failures. |
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.
Ok, thanks for confirming, I was looking at CI-results of 91837c8 which showed some failing tests, it seems some newer build now succeeds fully again.
} | ||
|
||
private static List<Builder> createJacocoProjectBuilders() { | ||
String[] commands = { "git clone --branch jacoco-3.2.0 https://github.com/jenkinsci/jacoco-plugin.git .", |
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.
So binaries "git" and "mvn" need to be available on the CI node for this to work, right?
@centic9 yes, the ci.jenkins.io agents used for |
<maven.version>3.8.1</maven.version> | ||
<powermock.version>2.0.7</powermock.version> | ||
<!-- until the plugin-pom picks up a newer version --> | ||
<jenkins-test-harness.version>1589.vc23fca066d5c</jenkins-test-harness.version> |
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.
} | ||
|
||
private static List<Builder> createJacocoProjectBuilders() { | ||
String[] commands = { "git clone --branch jacoco-3.2.0 https://github.com/jenkinsci/jacoco-plugin.git .", |
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.
For a more reproducible environment:
- store a small test project in
src/test/resources/sampleproj/
- use
dependency:copy
to unpack a specific release of Maven intotarget/test-classes/
but still use the Java in path I guess.
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.
Much nicer!
maven-hpi-plugin
output before
[INFO] --- maven-hpi-plugin:3.17:hpi (default) @ jacoco --- [INFO] Generating src/jenkinsci/jacoco-plugin/target/jacoco/META-INF/MANIFEST.MF [INFO] Checking for attached .jar artifact ... [INFO] Generating jar src/jenkinsci/jacoco-plugin/target/jacoco.jar [INFO] Building jar: src/jenkinsci/jacoco-plugin/target/jacoco.jar [INFO] Exploding webapp... [INFO] Copy webapp webResources to src/jenkinsci/jacoco-plugin/target/jacoco [INFO] Assembling webapp jacoco in src/jenkinsci/jacoco-plugin/target/jacoco [WARNING] Bundling transitive dependency guice-4.2.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency javax.inject-1.jar (via jacoco-maven-plugin) [INFO] Bundling direct dependency httpcore-4.4.13.jar [WARNING] Bundling transitive dependency maven-reporting-api-3.0.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-resolver-api-1.6.2.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-resolver-impl-1.6.2.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-resolver-spi-1.6.2.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-resolver-util-1.6.2.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency file-management-1.2.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-shared-io-1.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-shared-utils-3.2.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency wagon-provider-api-1.0-alpha-6.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-artifact-manager-2.0.2.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-builder-support-3.8.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-core-3.8.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-model-builder-3.8.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-repository-metadata-3.8.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-resolver-provider-3.8.1.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency maven-settings-builder-3.8.1.jar (via jacoco-maven-plugin) [INFO] Bundling direct dependency plexus-utils-3.2.1.jar [WARNING] Bundling transitive dependency org.eclipse.sisu.inject-0.3.4.jar (via jacoco-maven-plugin) [INFO] Bundling direct dependency jacoco-maven-plugin-0.8.7.jar [WARNING] Bundling transitive dependency org.jacoco.agent-0.8.7.jar (via jacoco-maven-plugin) [WARNING] Bundling transitive dependency org.jacoco.core-0.8.7.jar (via org.jacoco.report) [INFO] Bundling direct dependency org.jacoco.report-0.8.7.jar [WARNING] Bundling transitive dependency asm-analysis-9.1.jar (via org.jacoco.report) [WARNING] Bundling transitive dependency asm-commons-9.1.jar (via org.jacoco.report) [WARNING] Bundling transitive dependency asm-tree-9.1.jar (via org.jacoco.report) [WARNING] Bundling transitive dependency asm-9.1.jar (via org.jacoco.report) [INFO] Bundling direct dependency xml-apis-1.4.01.jar [INFO] Generating hpi src/jenkinsci/jacoco-plugin/target/jacoco.hpi [INFO] Building jar: src/jenkinsci/jacoco-plugin/target/jacoco.hpi
maven-hpi-plugin
output after
[INFO] --- maven-hpi-plugin:3.17:hpi (default-hpi) @ jacoco --- [INFO] Generating src/jenkinsci/jacoco-plugin/target/jacoco/META-INF/MANIFEST.MF [INFO] Checking for attached .jar artifact ... [INFO] Found attached .jar artifact: src/jenkinsci/jacoco-plugin/target/jacoco.jar [INFO] Exploding webapp... [INFO] Copy webapp webResources to src/jenkinsci/jacoco-plugin/target/jacoco [INFO] Assembling webapp jacoco in src/jenkinsci/jacoco-plugin/target/jacoco [INFO] Bundling direct dependency plexus-utils-3.2.1.jar [WARNING] Bundling transitive dependency org.jacoco.core-0.8.7.jar (via org.jacoco.report) [INFO] Bundling direct dependency org.jacoco.report-0.8.7.jar [WARNING] Bundling transitive dependency asm-analysis-9.1.jar (via org.jacoco.report) [WARNING] Bundling transitive dependency asm-commons-9.1.jar (via org.jacoco.report) [WARNING] Bundling transitive dependency asm-tree-9.1.jar (via org.jacoco.report) [WARNING] Bundling transitive dependency asm-9.1.jar (via org.jacoco.report) [INFO] Generating hpi src/jenkinsci/jacoco-plugin/target/jacoco.hpi [INFO] Building jar: src/jenkinsci/jacoco-plugin/target/jacoco.hpi
I noticed we are still bundling ASM 9:
[WARNING] Bundling transitive dependency asm-analysis-9.1.jar (via org.jacoco.report)
[WARNING] Bundling transitive dependency asm-commons-9.1.jar (via org.jacoco.report)
[WARNING] Bundling transitive dependency asm-tree-9.1.jar (via org.jacoco.report)
[WARNING] Bundling transitive dependency asm-9.1.jar (via org.jacoco.report)
This also seems to be the reason for maskClasses
. This is unnecessary since 2.274, which bundles ASM 9 in the WAR via jnr-posix
(formalized in the core BOM in jenkinsci/jenkins#5525). I suggest updating jenkins.version
to 2.277.1 or later, then excluding the ASM dependencies as is done in token-macro
. Then maskClasses
wouldn't be needed at all and this plugin would be slimmer as well.
@centic9 would you be able to merge and release this sometime this week please? |
@basil to be clear, I suppose you mean we should do this in general, not necessarily in this PR right? Thanks |
using an unshaded ASM is core is probably a mistake and it should not really happen. Jenkins core should not be pulling moar libraries into Jenkins core, and ASM specifically is known to not be compatible between versions, so this plugin could break at a moments notice if we updated |
@centic9 hi, can you please consider merging & relasing? We can help on this if you need it. Just let us know. Thanks a lot! |
Sorry, I was not aware of the impact of the changes as there was no mentioning in the PR. Unfortunately in general I can not spend much time on this plugin, only the bare minimum to keep it alive :( I can roll a release today or tomorrow. If there is someone who is interested in the plugin enough to step in and spend time on general maintenance, please contact me or simply apply for access rights! Otherwise it will probably soon go towards "unmaintained" state as there are other alternatives by now anyway... |
I pushed out 3.3.0 now with these changes. |
JENKINS-65757 The dependencies was a mess due to pulling libraries in that where comletely un-needed.
Even plexus could probably be removed with a bit more effort - but at least plexus is safe.
Maven etc was pulling in guva and a misguided attempt to bundle it along with the plugin first classloaded caused all hell to break loose as guice saw things loaded from separate classloaders and it was not happy
Added a proper realistic E2E test (there where not even any semi realistic ones) using
RealJenkinsRule
to ensure this still works with a FreeStyleProject creating jacoco coverage via maven (a tag of this project)