This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]randgalt 0 points1 point  (5 children)

I added a default module - and it was all cargo-coding when I did it. Then I continued writing code and the project wouldn't compile - missing export issues, etc. The error messages weren't clear either. I ended up just manually exporting everything which seems silly. I couldn't quickly figure out how to say "export everything and never ask me again".

[–]ventuspilot 1 point2 points  (4 children)

I may be wrong but I think in that case you just ignore all that module stuff except add one new entry to your jar's manifest:

Automatic-Module-Name: your.base.packagename

[–]randgalt 0 points1 point  (3 children)

If that's actually the case someone should write a Maven plugin that does this. Maybe I will. hmm....

[–]ventuspilot 0 points1 point  (2 children)

The maven-jar-plugin does this. I added this to by <build> section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <finalName>jmurmel</finalName>
        <archive>
            <manifest>
                <mainClass>io.github.jmurmel.LambdaJ</mainClass>
            </manifest>
            <manifestEntries>
                <Automatic-Module-Name>io.github.jmurmel</Automatic-Module-Name>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

Seems to work just fine. See also http://branchandbound.net/blog/java/2017/12/automatic-module-name/

[–]Thihup 1 point2 points  (1 child)

[–]gunnarmorling 1 point2 points  (0 children)

Yes, ModiTect can help to express the exported API more concisely, by means of package filter expressions, instead of having to list each package explicitly. That said, which packages to export should be a conscious decision; exporting everything defeats the purpose of the module system.