kohlschutter / junixsocket

Unix Domain Sockets in Java 7 and newer (AF_UNIX), AF_TIPC, AF_VSOCK, and more
Apache License 2.0
433 stars 114 forks source link

Problem using maven-jlink-plugin with POM-only junixsocket-core artifact #153

Closed sblantipodi closed 5 months ago

sblantipodi commented 6 months ago

Hi all.

When I try to use jlink on software that uses junixsocket I get this error: [ERROR] The given dependency C:\Users\sblantipodi.m2\repository\com\kohlschutter\junixsocket\junixsocket-core\2.8.3\junixsocket-core-2.8.3.pom does not have a module-info.java file. So it can't be linked.

any plan to add a module-info?

Thanks :)

kohlschuetter commented 6 months ago

Hi @sblantipodi !

junixsocket-core is a POM-only dependency; it should not cause errors (the junixsocket jars are already modularized / contain module-info.class) Can you please provide a snippet that reproduces the issue?

kohlschuetter commented 6 months ago

As a workaround, you may replace the dependency to junixsocket-core with the dependencies declared in junixsocket-core directly, and (if necessary) add an exclusion for junixsocket-core from any of your dependencies (check with mvn dependency:tree or via your IDE)

    <dependencies>
        <dependency>
            <groupId>com.kohlschutter.junixsocket</groupId>
            <artifactId>junixsocket-native-common</artifactId>
            <version>${junixsocket.version}</version>
        </dependency>
        <dependency>
            <groupId>com.kohlschutter.junixsocket</groupId>
            <artifactId>junixsocket-common</artifactId>
            <version>${junixsocket.version}</version>
        </dependency>
    </dependencies>
sblantipodi commented 6 months ago

@kohlschuetter thanks for the kind answer, I appreciate it. Sources are available here.

junixsocket is used inside the dbus-java lib that I use in my project.

kohlschuetter commented 6 months ago

@sblantipodi Please see the new junixsocket-demo-jpackagejlink module for instructions how to use junixsocket with jlink and/or jpackage.

I'm using jlink-maven-plugin instead of maven-jlink-plugin, and that seems to work just fine.

Please let me know how that goes for your project. — I didn't see the place where you exactly get the error (maybe you could point me at it?)

On a related note: Did you look into using GraalVM native-image instead of jlink? That usually produces much more optimized code. junixsocket supports that, too.

Other than that: Your ambient light project looks really cool! I was reading about such a tool just a few days ago. Good to see that junixsocket can play a small role there. Keep up the great work!

kohlschuetter commented 6 months ago

@sblantipodi I've filed a bug with maven-jlink-plugin (MJLINK-82), along with a patch to fix the issue on their end.

I also updated the demo POM with a profile triggering the bug. If you use a local snapshot build of maven-jlink-plugin with the patch applied, linking should work just fine.

sblantipodi commented 6 months ago

@kohlschuetter wow, great! thanks for the awesome work :)

kohlschuetter commented 5 months ago

2.9.1 has been released, please verify. Thanks again for reporting!