java9-modularity / gradle-modules-plugin

This Gradle plugin helps working with the Java Platform Module System
https://javamodularity.com/
MIT License
233 stars 36 forks source link

Fix compatibility issue with Gradle 7.6+ #261

Closed big-andy-coates closed 7 months ago

big-andy-coates commented 7 months ago

fixes: https://github.com/java9-modularity/gradle-modules-plugin/issues/258

Gradle 7.6 is executing tasks in a different order, with mergeClasses being run after compileTestJava. This results in compileTestJava failing as it can't find the module-info.class which is generated by mergeClasses.

Fix looks to be to have the compileTestJava task, i.e. JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME, depend on the mergeClasses task. Thereby ensuring mergeClasses runs first and the module-info.class is available to compileTestJava.

It is possible/likely that the JavaPlugin.TEST_TASK_NAME task, i.e. test task, no longer needs to depend on mergeClasses. However, removing it may cause problems if there are other tasks run by test that require the output of mergeClasses. Of course, those tasks may also run foul of the re-ordering happening with Gradle 7.6.