Skip to content

Conversation

@strangelookingnerd
Copy link
Contributor

Ban JUnit 4 imports

To prevent regressions when adding new tests, jenkinsci/plugin-pom#1178 introduced a new flag that enables a Maven Enforcer rule banning org.junit.* imports while allowing org.junit.jupiter.*.

With this change, the build will fail if any org.junit.* imports are introduced.

Testing done

None. Rely on ci.jenkins.io.

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 demonstrate the feature works or the issue is fixed

@strangelookingnerd strangelookingnerd requested a review from a team as a code owner August 15, 2025 12:41
@strangelookingnerd
Copy link
Contributor Author

[2025-08-15T12:42:40.302Z] Rule 0: org.apache.maven.plugins.enforcer.RestrictImports failed with message:
[2025-08-15T12:42:40.302Z] 
[2025-08-15T12:42:40.303Z] Banned imports detected in TEST code:
[2025-08-15T12:42:40.303Z] 
[2025-08-15T12:42:40.303Z] Reason: Use JUnit 5 (org.junit.jupiter.*)
[2025-08-15T12:42:40.303Z] 	in file:///home/jenkins/agent/workspace/Plugins_jira-plugin_PR-733/src/test/java/hudson/plugins/jira/JiraEnvironmentVariableBuilderTest.java
[2025-08-15T12:42:40.303Z] 		static org.junit.Assert.assertEquals 	(Line: 7, Matched by: org.junit.**)
[2025-08-15T12:42:40.303Z] 		org.junit.Rule                       	(Line: 30, Matched by: org.junit.**)

Good catch, this Rule usage is obsolete. I'll post a PR shortly.

@strangelookingnerd strangelookingnerd mentioned this pull request Aug 15, 2025
6 tasks
@rantoniuk
Copy link
Member

Wouldn't it make more sense to enable it by default in the plugin-pom?

@strangelookingnerd
Copy link
Contributor Author

@rantoniuk please reopen, PR got auto-closed.

@strangelookingnerd
Copy link
Contributor Author

Wouldn't it make more sense to enable it by default in the plugin-pom?

There are still plenty of of plugins that have not yet been migrated, hence it's opt-in.

@rantoniuk rantoniuk reopened this Aug 18, 2025
@rantoniuk rantoniuk enabled auto-merge (squash) August 18, 2025 10:03
@rantoniuk rantoniuk merged commit e41d436 into jenkinsci:master Aug 18, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants