In my multi-module project, I created module-info.java only for few modules. And during compilation with maven-compiler-plugin:3.7.0 I\'m getting n
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
Is that because I have only a few modules with module-info.java and not the whole project?
No, its not because of a few module listed on the module-info.java but generated by the maven-compiler-plugin for all the automatic modules found in the module graph.
What does it mean?
Not to publish the current project is insisted probably since the automatic modules are expected to be converted to named or explicit modules by their owners and then published to repositories which might result in change to their module name as well. Additionally a precautionary point to note here is that according to the progress document of Maven ~> Java+9+-+Jigsaw, they are still not completely ready with the JDK9 compatible plugin versions.
Just to portray an example for such a use case. Think over these lines -
com-foo-bar:1.0.0-SNAPSHOT:jar.com-xyz:1.0.0 depends on it. com-foo-bar transitively via com-xyzYou plan to modularize your code and make use of something like
module your.module {
requires com.foo.bar;
requires com.xyz;
}
(you need to specify the transitive dependencies in the module declarations separately)
And I did something fantastic to explicitly call out my efforts like this:-
module modular.com.foo.bar {}
I end up breaking the code of any dependent library and eventually any that depends on yours in a modularized way.
Note: I agree over not practicing to use SNAPSHOTs in production, but there could be cases when eventually you rely on an artifact which is still in development phase.
Edit: From the comments by @khmarbaise
Its understood that people would wish to publish to artifactories but if they are not aware of the consequences you will be beaten in the future by this.
Maven would like to make it clear that the WARNING in this case is very serious which could have instead been a FAILURE but that would had been a bad user experience to deal with.
The ideal way to deal with this is that the library owners plan to migrate their artifacts to JDK9 and the tree is traversed bottom-up in which case the named/explicit module would be the only aspect prevailing without the need of the automatic module names and such warnings.