Skip to content
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

Set junit as Automatic-Module-Name in standalone JAR #4079

Closed
sormuras opened this issue Oct 18, 2024 · 8 comments
Closed

Set junit as Automatic-Module-Name in standalone JAR #4079

sormuras opened this issue Oct 18, 2024 · 8 comments

Comments

@sormuras
Copy link
Member

Running jar --describe-module --file junit-platform-console-standalone-X.Y.Z.jar yields:

No module descriptor found. Derived automatic module.

[email protected] automatic
requires java.base mandated
provides java.util.spi.ToolProvider with org.junit.platform.console.ConsoleLauncherToolProvider
provides org.junit.platform.engine.TestEngine with [...]JupiterTestEngine [...]SuiteTestEngine [...]VintageTestEngine
provides org.junit.platform.launcher.TestExecutionListener with [...]UniqueIdTrackingListener [...]OpenTestReportGeneratingListener
contains junit.extensions
contains junit.framework
contains junit.runner
contains junit.textui
contains org.apiguardian.api
contains org.hamcrest
contains org.hamcrest.core
contains org.hamcrest.internal
contains org.junit
contains org.junit.experimental
contains org.junit.experimental.categories
[...]
contains org.junit.vintage.engine.support
contains org.opentest4j
main-class org.junit.platform.console.ConsoleLauncher

The name of the derived automatic module is based on the file name - which is unstable if users or build tools rename the JAR file. It would be better to provide a stable name in the JAR's manifest for when the standalone JAR is put on the module path. As this JUnit Platform standalone JAR is often used as a drop-in replacment for JUnit 3/4, the automatic module name should be junit - just as the junit.jar has it since 2018 via:

@sormuras
Copy link
Member Author

With

Index: junit-platform-console-standalone/junit-platform-console-standalone.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/junit-platform-console-standalone/junit-platform-console-standalone.gradle.kts b/junit-platform-console-standalone/junit-platform-console-standalone.gradle.kts
--- a/junit-platform-console-standalone/junit-platform-console-standalone.gradle.kts	(revision 35d3dd71662beda795e3ce3c428b9a1215d8c9e4)
+++ b/junit-platform-console-standalone/junit-platform-console-standalone.gradle.kts	(date 1729247166506)
@@ -25,6 +25,7 @@
 tasks {
 	jar {
 		manifest {
+			attributes("Automatic-Module-Name" to "junit")
 			attributes("Main-Class" to "org.junit.platform.console.ConsoleLauncher")
 		}
 	}

applied, we'd get for jar --describe-module --file junit-platform-console-standalone-1.12.0-SNAPSHOT.jar:

No module descriptor found. Derived automatic module.

[email protected] automatic
[...]

@marcphilipp
Copy link
Member

junit is already used as automatic module name for JUnit 4 so I don't think we should use it for the console launcher:

https://github.com/junit-team/junit4/blob/ed47b7f487bafa48cff47f051af81a004cd36049/pom.xml#L361

@sormuras
Copy link
Member Author

Are you thinking about name clashes in cases where both artifacts (junit.jar and junit-platform-console-standalone.jar) land on the module path?

@marcphilipp
Copy link
Member

Yes, which happens as soon as one uses the Vintage engine. Moreover, it "feels wrong".

@sbrannen
Copy link
Member

I agree with Marc. We should not use junit as the automatic module name for the standalone console launcher artifact for two reasons.

  1. It's already used by JUnit 4.
  2. Even if it were not used by JUnit 4, the console launcher is not "JUnit".

@marcphilipp
Copy link
Member

@sormuras Ok to close this?

@sormuras
Copy link
Member Author

Yes.

@sormuras sormuras closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2024
Copy link

Please assign a status label to this issue.

@github-actions github-actions bot reopened this Nov 15, 2024
@marcphilipp marcphilipp closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants