Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help]: Gradle plugin does not download platform-specific artifacts from maven repository #33

Open
rkechols opened this issue Feb 6, 2025 · 6 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@rkechols
Copy link

rkechols commented Feb 6, 2025

I'm trying to use the gradle javacpp platform plugin to incorporate platform-specific artifacts into a project, and it seems that the plugin is not downloading the platform-specific artifacts at all to be incorporated into the build.

See also atsushieno/ktmidi#98

To focus in on the problem (as highlighted in the issue linked above), platform-specific artifacts are published on maven (visible here) but they are not pulled into the build as expected.

I've made a simple example project to illustrate the issue:
https://github.com/rkechols/ktmidi-demo

Reproducing the issue should be as simple as cloning that repository, and running ./gradlew run, which gives output like this:

$ ./gradlew run                                                                                                                                                                                                                                                                                                     
Type-safe project accessors is an incubating feature.                                                                                                                                                                                                                                                               

> Configure project :composeApp
platform = windows-x86_64

> Task :composeApp:run
osName: windows 11
Warning: Version of dev.atsushieno:libremidi_javacpp could not be found.
Failed to use LibreMidiAccess: java.lang.UnsatisfiedLinkError: no jnilibremidi in java.library.path: C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin;C:\WINDOWS\Sun\Java\bin;<truncated>;.
Warning: Version of dev.atsushieno:rtmidi_javacpp could not be found.
Failed to use RtMidiAccess: java.lang.UnsatisfiedLinkError: no jnirtmidi in java.library.path: C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin;C:\WINDOWS\Sun\Java\bin;<truncated>;.
Using JvmMidiAccess as last resort
# of input devices via jvm: 1

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.9/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 3s
11 actionable tasks: 1 executed, 10 up-to-date

My primary platform for testing is Windows 11 x86_64, but I also have Linux and macOS systems available to test on that experience the same issue.

I'm not sure whether this is actually a problem with gradle-javacpp, a problem with the artifacts/libraries from dev.atsushieno I'm trying to use, or a problem with my project setup, but I'd much appreciate help narrowing down the problem from someone well-versed with gradle-javacpp.

@saudet
Copy link
Member

saudet commented Feb 6, 2025

I don't see any platform artifacts.

@saudet saudet added help wanted Extra attention is needed question Further information is requested labels Feb 6, 2025
@rkechols
Copy link
Author

rkechols commented Feb 6, 2025

I don't see any platform artifacts.

At the link posted above (https://repo1.maven.org/maven2/dev/atsushieno/libremidi-javacpp/0.1.4/) I see these platform-specific artifacts (among other artifacts):

libremidi-javacpp-0.1.4-linux-x86_64.jar          2025-02-05 15:13    187997      
libremidi-javacpp-0.1.4-macosx-arm64.jar          2025-02-05 15:13     87178      
libremidi-javacpp-0.1.4-macosx-x86_64.jar         2025-02-05 15:13     94403      
libremidi-javacpp-0.1.4-windows-x86_64.jar        2025-02-05 15:13    754981      

Are those somehow not visible to you? Or do they somehow not "count"?

I sincerely apologize if my naiveté bothers you; your patience would be much appreciated as I learn a new tool.

@saudet
Copy link
Member

saudet commented Feb 7, 2025

When I talk about platform artifacts, I mean artifacts with the string "platform" in their names. I don't see any files with "platform" in their names.

@atsushieno
Copy link

atsushieno commented Feb 7, 2025

Let me help you understand how Maven Central locates Maven artifacts so that you can easily guess where you can find "platform" artifacts. It would help you understand how your own Maven artifacts for javacpp-presets are located as well.

When you see some Maven artifacts URL such as ^ (https://repo1.maven.org/maven2/dev/atsushieno/libremidi-javacpp/0.1.4/), it means that the artifact is published at https://repo1.maven.org/maven2/ (for other artifacts, there can be other repository URLs).

When gradle-javacpp publishes its target artifacts (one for the primary module and another for -platform module) they are published to the same destination.

From the URL above, you can see some path parts /dev/atsushieno/libremidi-javacpp/0.1.4/ . This means that the package identifier is dev.atsushieno:libremidi-javacpp:0.1.4 in short notation.

If you think "there should be -platform artifact", then you can guess that there should be the corresponding package located at /dev/atsushieno/libremidi-javacpp-platform/0.1.4/. Let's see if it is correct. If you open the URL above, the page should look like this:

Image

Click ".." part, and then you are navigated to the parent directory:

Image

Now you'll see all packages I have published in the past. Scroll down to l and find libremidi-javacpp:

Image

You can find there is libremidi-javacpp-platform ! Enter the directory, and pick up the corresponding version (it is versioned as well). Now you can find the package contents here:

https://repo1.maven.org/maven2/dev/atsushieno/libremidi-javacpp-platform/0.1.4/

The same locating principles apply to javacpp-presets e.g. flycapture:

I hope this helps!

@saudet
Copy link
Member

saudet commented Feb 7, 2025

Thanks @atsushieno ! So the platform artifacts are there, but they don't contain any dependencies on the platform-specific artifacts (the linux, mac, windows, etc ones):
https://repo1.maven.org/maven2/dev/atsushieno/libremidi-javacpp-platform/0.1.5/
You'll need to add the dependencies in there.

@atsushieno
Copy link

but they don't contain any dependencies on the platform-specific artifacts (the linux, mac, windows, etc ones)

It is actually what I did not understand when I published my version 0.1.4 that removed them all, and I brought back (or "tried to", I'd say) at 0.1.5: atsushieno/libremidi-javacpp@f50ebff

It is based on what samples/zlib/build.gradle does: https://github.com/bytedeco/gradle-javacpp/blob/e4de6606200654777ea9f6af30df10bf835e713d/samples/zlib/build.gradle#L17C1-L31C2

If it does not generate the dependencies (like how flycapture-platform has), then I assume gradle-javacpp is failing to deal with these items. Or some other parts in my build.gradle is bringing in conflicts, overwrites etc. But as far as I read gradle-javacpp sources I don't see any code that generates this dependencies section. Any hints are appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants