Typhon0 / AnimateFX

A library of +70 ready-to-use animations for JavaFX
Apache License 2.0
451 stars 66 forks source link

Omission of module-info descriptor/Automatic-Module-Name entry in the manifest file means gradle does not put dependency on module path #22

Closed strudelPie closed 3 months ago

strudelPie commented 2 years ago

Gradle build hits runtime error.

Please see StackOverflow question here for full annotated explanation: https://stackoverflow.com/questions/70137886/why-do-i-get-a-runtime-error-when-trying-to-use-and-run-external-library-animate

In particular please note the discussion in the StackOverflow comments section of the post. Essentially: Gradle only adds dependencies to the module-path if they have a module-info descriptor or if they have an Automatic-Module-Name entry in the manifest file. The AnimateFX library has neither, and so Gradle does not put the dependency on the module-path. I'm not sure if there's a way around this problem while keeping your code modular, which is a need.

System Information

tkslaw commented 2 years ago

For a reference to how Gradle determines if a dependency is a module or not, see the documentation for the Java Library plugin:

To tell the Java compiler that a Jar is a module, as opposed to a traditional Java library, Gradle needs to place it on the so called module path. It is an alternative to the classpath, which is the traditional way to tell the compiler about compiled dependencies. Gradle will automatically put a Jar of your dependencies on the module path, instead of the classpath, if these three things are true:

  • java.modularity.inferModulePath is not turned off

  • We are actually building a module (as opposed to a traditional library) which we expressed by adding the module-info.java file. (Another option is to add the Automatic-Module-Name Jar manifest attribute as described further down.)

  • The Jar our module depends on is itself a module, which Gradles decides based on the presence of a module-info.class — the compiled version of the module descriptor — in the Jar. (Or, alternatively, the presence of an Automatic-Module-Name attribute the Jar manifest)

Note the documentation for the Application plugin refers you back to the above documentation.

mkpaz commented 1 year ago

Could you please add module-info? It's pretty inconvenient to use moditect each time to generate module descriptor. The latter is mandatory for tools like jlink or jpackage, which is the primary way to distribute Java desktop apps. Recent JavaFX versions require JDK17. Does it worth to keep FX8 compatibility for that long...

dlemmermann commented 1 year ago

Yes, please add module-info! It is 2023 .... time to add it! :-)

Typhon0 commented 3 months ago

Solved with ##29