What is "Required File Name Based Automules". warning means?

In my multi-module project, I created module-info.java for only a few modules. And during compilation with maven-compiler-plugin:3.7.0 I get the following warning:

[ATTENTION] * Necessary car modules are determined based on the file name. Please do not publish this project in a public repository of artifacts! *

What does it mean? Is it because I only have a few modules with module-info.java , and not the whole project?

+10
java maven maven-3 java-9 maven-compiler-plugin
source share
4 answers

Automatic module update

An explicit module (that is, one with module-info.java ) can only access the module code that it requires (ignoring Automatic modules - this is the answer: Any JAR that ends in the path to the module turns into a module. If the JAR does not contain a module declaration, the module system creates an automatic module with the following properties:

  • display name (this is an important bit here)
  • reads all other modules
  • export all packages

Maven relies on this mechanism, and after creating module-info.jar it puts all the dependencies in the module path.

Auto Names

There are two ways to display the name of an automatic module:

  • manifest entry
  • Suppose the JAR file name

In the first case, the name was intentionally chosen by the maintainer, so it can be considered stable (for example, it does not change when the project becomes modular). The second, obviously, is unstable throughout the ecosystem - not all project settings lead to the same filenames of their dependencies.

What does it mean?

The reason for the warnings is that some of your dependencies are automatic modules and do not determine their future module name in the manifest. Instead, their name comes from the file name, which makes them unstable

Stable names

So why are erratic names such problems? Suppose your library is published using requires guava , and my framework is published using requires com.google.guava . Now someone uses your library with my map, and they suddenly need the guava and com.google.guava modules on their way to the module. There is nothing a painless solution to this problem, so it must be prevented!

How? For example, discouraging developers from publishing artifacts that depend on automatic file-based modules. 😉

+8
source share

[WARNING] * Required auto-modules are determined based on the file name. Please do not publish this project in a public repository of artifacts! *

Is it because I only have a few modules with module-info.java, and not the whole project?

No, this is not due to the several modules listed in module-info.java , but the maven-compiler-plugin generated for all the automatic modules found in the module graph.


What does it mean?

The current project cannot be published, probably because it is expected that automatic modules will be converted to named or explicit modules by their owners, and then published to the repository, which can lead to a change in their module name. In addition, you should pay attention to the fact that according to the progress document Maven ~> Java + 9 + - + Jigsaw, they are still not completely ready with JDK9 compatible versions of plugins.


Just show an example of such use. Think about these lines -

  • I published an artifact com-foo-bar:1.0.0-SNAPSHOT:jar .
  • My com-xyz:1.0.0 project depends on this com-xyz:1.0.0 .
  • Ultimately, your project relies on com-foo-bar transitively through com-xyz
  • You plan to modulate your code and use something like

     module your.module { requires com.foo.bar; requires com.xyz; } 

    (you need to specify transitive dependencies in module declarations separately)

  • Everything worked fine, but until I decided to modulate my libraries.
  • Now the first thing I did was call my modules!
  • And I did something fantastic to explicitly state my efforts as follows: -

     module modular.com.foo.bar {} 
  • I end up breaking the code of any dependent library and, ultimately, any that depends on yours in a modular way.

Note I agree that I do not use SNAPSHOT in production, but there may be times when you ultimately rely on an artifact that is still under development.


Change From comments by @khmarbaise

He understood that people would want to publish in artifacts, but if they do not know about the consequences that you will be beaten into the future by this.

Maven would like to make it clear that the WARNING in this case is very serious, which could be MALFUNCTIONS, but it would be a bad user interface for work.

The ideal way to deal with this is that the library owners plan to transfer their artifacts to JDK9, and the tree intersects from the bottom up, in which case the named / explicit module will be the only aspect that exists without the need for automatic module names and such warnings.

+4
source share

With maven-compiler-plugin v3.7.0 this is an informational message. Not sure why you see this as a warning ...

This is what I get when I create my project based on Java 10 using module-info.java :

 [INFO] Required filename-based automodules detected. Please don't publish this project to a public artifact repository! 
0
source share

I received this warning when in my module-info.java file I added a class from the module itself, I had to do this to debug my test file in NetBeans, but this is clearly wrong, since it is not a module ..

 module net.my.package.xy { requires java.logging; requires java.naming; requires javax.jms.api; //THAT GENERATES THE WARNING: exports net.my.package.xy.MyClass; } 
0
source share

All Articles