jenkinsci / plugin-pom

Parent POM for Jenkins Plugins
https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial
MIT License
68 stars 77 forks source link

Fix hamcrest versioning #785

Closed timja closed 1 year ago

timja commented 1 year ago

Prior to this junit 4.x was bringing in hamcrest-core, causing https://github.com/jenkinsci/workflow-support-plugin/pull/220 to fail:

mvn dependency:tree | grep -B3 -A 2 hamcrest-core
[INFO] |  |  \- com.shapesecurity:salvation2:jar:3.0.1:test
[INFO] |  +- io.jenkins.lib:support-log-formatter:jar:1.2:test
[INFO] |  +- junit:junit:jar:4.13.2:test
[INFO] |  |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.eclipse.jetty:jetty-security:jar:10.0.15:test
[INFO] |  |  \- org.eclipse.jetty:jetty-server:jar:10.0.15:test

See the docs: https://hamcrest.org/JavaHamcrest/distributables

Care must be taken when upgrading from Hamcrest 1.3 or earlier. Due to the change in packaging, the version conflict resolution that happens in dependency management tools won’t happen automatically. A common example is projects that depend upon JUnit 4. JUnit 4 declares a transitive dependency upon hamcrest-core-1.3.jar. Because hamcrest-core is not the same artifact as hamcrest, it will not be upgraded.

Amends https://github.com/jenkinsci/plugin-pom/pull/762

Testing done

I've tested with a snapshot version of the pom:

mvn dependency:tree | grep -B3  hamcrest-core
[INFO] +- org.jenkins-ci.main:jenkins-test-harness:jar:2025.v6f97169a_d6a_f:test
[INFO] |  +- io.jenkins.lib:support-log-formatter:jar:1.2:test
[INFO] |  +- junit:junit:jar:4.13.2:test
[INFO] |  |  \- org.hamcrest:hamcrest-core:jar:2.2:test
### Submitter checklist
- [ ] Make sure you are opening from a **topic/feature/bugfix branch** (right side) and not your main branch!
- [ ] Ensure that the pull request title represents the desired changelog entry
- [ ] Please describe what you did
- [ ] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream changes
- [ ] Ensure you have provided tests - that demonstrates feature works or fixes the issue
basil commented 1 year ago

Should have been side-ported to jenkinsci/pom as in #475