apache / apache/maven-jmod-plugin
IT "mjmod-20-set-main-class" fails 99% when using compiler plugin 3.9.0+ due concurrency issue
- Dominant language
- Java
- Stars
- 16
- Forks
- 11
- Avg merge
- 7h 10m
- Merged PRs (30d)
- 1
Description
### Affected version
3.0.1-SNAPSHOT (current master)
### Bug description
_I already stumbled over this when upgrading to parent 48, but it turns out is has nothing to do with parent._
Sorry in advanced for the long description, but its really strange and flaky for me using: **Windows 11, Java 25 (Zulu)**
### Summary
Running IT `mjmod-20-set-main-class` with
* Maven 3.9.16 and compiler-plugin 3.8.x works,
* Maven 3.9.16 and compiler-plugin 3.9.0+ fails with "Failure during deleting of file" most of the time, rarely with "Module not found"
* Maven Maven 4.0.0-rc5, compiler-plugin 3.8.x and no declared jar-plugin pulls in latest jar-plugin available in local repository
* Maven Maven 4.0.0-rc5, compiler-plugin 3.8.x and parent's jar-plugin, fails almost every time with "Failure during deleting of file"
* Maven Maven 4.0.0-rc5, compiler-plugin 3.15.0 and parent's jar-plugin fails with "Module not found"
### Long description / test results
The easy part first / What I'm quite sure about:
* It has nothing to do with using `clean` together with the verify (should be set via invoker.goals anyways, see below)
* running the tests with admin rights or not.
* changing the `invoker.goals` from `verify` to `package`. This is no surprise because running `verify` includes `package`, but I noticed that all other tests except those this and one other run `package` goal. Many of the others also run clean, but this does not seem to make any difference too.
This is the current [POM](https://github.com/apache/maven-jmod-plugin/blob/master/src/it/mjmod-20-set-main-class/pom.xml), however the `compiler-plugin` is the one which causes trouble (from what I see and what is already described in the POM's comments)
```xml
org.apache.maven.plugins
maven-compiler-plugin
3.8.0
9
```
## Maven 3.9.16
Using **Maven 3.9.16** it seems to be consistent, regardless of how often I run the tests with the same versions. I did the following tests:
3.9.16 with compiler-plugin 3.8.0 (declared) and jar-plugin 3.5.0 (not declared as in current POM, pulled in from parent 48) --> ok
3.9.16 with compiler-plugin 3.15.0 (declared using `@version.maven-compiler-plugin@`) pulls in jar plugin 4.0.0-beta-1 which is not declared anywhere, but is the latest version in my HOME/.m2 repo -> NOK / Maven version incompat
```
[WARNING] Ignoring incompatible plugin version 4.0.0-beta-1
org.apache.maven.plugin.PluginIncompatibleException:
The plugin org.apache.maven.plugins:maven-jar-plugin:4.0.0-beta-1 has unmet prerequisites:
Required Maven version 4.0.0-beta-3 is not met by current version 3.9.16
```
3.9.16 with compiler-plugin 3.8.0 (declared) and jar-plugin 3.5.0 (declared using `@version.maven-jar-plugin@`) --> ok
3.9.16 with compiler-plugin 3.15.0 (declared using `@version.maven-compiler-plugin@`) and jar-plugin 3.5.0 (declared using `@version.maven-jar-plugin@`) --> NOK / Failure during deleting of file
```
Caused by: org.apache.maven.plugin.MojoFailureException: Failure during deleting of file D:\Github\Maven\maven-jmod-plugin\target\it\mjmod-20-set-main-class\world\target\jmods\myproject.world.jmod
at org.apache.maven.plugins.jmod.JModCreateMojo.deleteOutputIfAlreadyExists (JModCreateMojo.java:345)
at org.apache.maven.plugins.jmod.JModCreateMojo.execute (JModCreateMojo.java:316)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:919)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:285)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:207)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:565)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:362)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
```
This shows that there must be a problem with compiler plugin somewhere. So testing other versions of it.
3.9.16 with compiler-plugin 3.8.1 (declared) and jar-plugin 3.5.0 (declared using `@version.maven-jar-plugin@`) --> OK
3.9.16 with compiler-plugin 3.9.0 (declared) and jar-plugin 3.5.0 (declared using `@version.maven-jar-plugin@`) --> NOK / "Failure during deleting of file" (99% of the time) OR "Module not found"
```
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.15.0:compile (default-compile) on project myproject.greetings: Compilation failure
/D:/Github/Maven/maven-jmod-plugin/target/it/mjmod-20-set-main-class/greetings/src/main/java/module-info.java:[21,23] Modul nicht gefunden: myproject.world
```
The same is true for all my test with other compiler version higher then 3.8.1, starting from 3.9.0 up to current 3.15.0. Seems there is at least one problem with compiler-plugin 3.9.0+ when using Maven 3.9.16 in this IT.
## Maven 4.0.0-rc5
When using **Maven 4.0.0-rc5** its getting a bit flaky, but most of the time it fails
4.0.0-rc5 with compiler-plugin 3.8.0 (declared) and jar-plugin 3.5.0 (declared using `@version.maven-jar-plugin@`) --> NOK / Failure during deleting of file
Most of the runs it fails with the "Failure during deleting of file" error. In very few runs (maybe 2 or 3 out of 30+) the build is successful and only the output in build-info does not match the expected (which is okay and what I want to check for Maven 4 compat. I think I have a fix for the changed output, but this is another topic).
When running 4.0.0-rc5 with compiler-plugin version of 3.15.0 (declared using `@version.maven-compiler-plugin@`) and jar-plugin 3.5.0 (declared using `@version.maven-jar-plugin@`) the behavior changes and I constantly get a "Module not found"
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with src/it/mjmod-20-set-main-class/pom.xml and JModCreateMojo.java around deleteOutputIfAlreadyExists at line 345. Reproduce the IT with the listed Maven, compiler-plugin, and jar-plugin combinations, then compare the deletion and module-not-found failures. Done means the IT runs reliably with the affected versions and its expected build-info behavior is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100