-
-
Notifications
You must be signed in to change notification settings - Fork 80
Optionally ban JUnit 4 imports #1178
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
Merged
timja
merged 6 commits into
jenkinsci:master
from
daniel-beck:optionally-ban-junit4-imports
Aug 15, 2025
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
260826a
Optionally ban JUnit 4 imports
daniel-beck 3d7cb1c
Add tests
daniel-beck 1f2fe33
Add documentation
daniel-beck ae29578
Fix typo in file path
daniel-beck a1fef44
Fix another typo in file path
daniel-beck 57ab9f3
Grammar
daniel-beck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why are we doing this at the source level and not banning the dep?
This means that IDEs will happily suggest junit4 etc in auto completion and tests in IDEs will pass (but the build will fail from the CLI).
Banning the dependencies directly in a profile activated by the property would seem to solve the issue by having compilation fail would it not?
@daniel-beck was there a reason that banning the dependency was not done rather than just banning the import?
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 it is harder to apply as this (IIRC) need to go in the
.mvn/maven.configrather than just a pom property, but we do that for CD releases so its nothing new per sayThere 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 did not consider that option.
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.
would that work with dependencies that depend on junit 4 ?
I am thinking of this long standing testcontainers issue as an example testcontainers/testcontainers-java#970
Uh oh!
There was an error while loading. Please reload this page.
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.
you would need to add exclusions on the dependency that brough junit4 in.
This would be almost every plugin due to https://github.com/jenkinsci/jenkins-test-harness/blob/0c38b4e6bcfa401dc675f39ce8112b839150cc75/pom.xml#L134-L137 but then that would serve as a reminder that perhaps some other things still need to happen first.
But I am not fully sure what you are asking - maven's invocation via surefire of things is platform aware so anything pure junit5 should work without exception (how gradle handles test engines is unknown to me).
And if it is not pure junit-5 then you would not opt in to the ban.