1

I am having a problem where I can not use jlink for compiling and I now kind of know what is wrong: jlink can not compile automated modules because they have unstable names. Is there a workaround or a fix for this? Here are the relevant parts of my code:

module-info.java

module org.example {
    requires MathParser.org.mXparser;

    exports org.example;
}

pom.xml

...
<dependency>
    <groupId>org.mariuszgromada.math</groupId>
    <artifactId>MathParser.org-mXparser</artifactId>
    <version>4.4.2</version>
</dependency>
...

Main.java

...
import org.mariuszgromada.math.mxparser.*;
...

When compiling with jlink, it gives this error message:

Required filename-based automodules detected. Please don't publish this project to a public artifact repository!

This question is no duplicate because it was not answered yet. The suggested question did not receive a fix or a workaround. Still it answers the technical things: What does "Required filename-based automodules detected." warning mean?

  • For anyone wondering, the library is this one: MathParser.org-mXparser from org.mariuszgromada.math –  Jun 13 '20 at 20:47
  • You may want to read [ask]. – Robert Jun 13 '20 at 20:58
  • Changed my question –  Jun 13 '20 at 21:04
  • @PeterArbeitsloser Everyone can see that you changed the question, the edit log is public. No need to comment every time you edit. – Polygnome Jun 13 '20 at 21:44
  • Does this answer your question? [What does "Required filename-based automodules detected." warning mean?](https://stackoverflow.com/questions/46501047/what-does-required-filename-based-automodules-detected-warning-mean) –  Jun 13 '20 at 21:46
  • There was literally no fix or workaround provided... They just explained the problem. –  Jun 14 '20 at 08:32

1 Answers1

0

No, there is no workaround for your case. jlink doesn't support automatic modules (even stable names will not help). You need to convert your automatic module to an explicit module first. The good news is that you don't have to recompile your library. You can generate a module declaration with jdeps --generate-module-info and then inject it into the JAR. This was described in this question.

ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
  • Thank you for your suggestion, I will definitely try that out! –  Jun 16 '20 at 08:53
  • But I have one question: My Projects works with maven, where do I find the ```jar``` then? –  Jun 16 '20 at 08:57
  • @PeterArbeitsloser You can run `mvn dependency:build-classpath`. This will print the paths of all your dependencies. However, you shouldn't modify that JARs. Instead, you will need to copy them to a new folder and modify the copies. You can use `maven-dependency-plugin` for that. – ZhekaKozlov Jun 17 '20 at 05:33
  • Is there a tutorial on it? Because I do not know what to do now... I was able to generate the ```module-info.java``` but I did not know where to put it... And how do I copy the dependencies? –  Jun 18 '20 at 08:36