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

Version stored in .module doesn't match pom version for use with Gradle #281

Closed
petebankhead opened this issue Dec 11, 2024 · 6 comments
Closed

Comments

@petebankhead
Copy link

Very possible this is an issue of me not understanding, but I'm unable to access the version catalog in Gradle with the error

Could not resolve all artifacts for configuration 'incomingCatalogForSciJava0'.
> Could not find pom-scijava-19.0.0.toml (org.scijava:pom-scijava:39.0.0).
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/scijava/pom-scijava/39.0.0/pom-scijava-19.0.0.toml

Checking pom-scijava-38.0.1.module I see

{
  "formatVersion": "1.1",
  "component": {
    "group": "org.scijava",
    "module": "pom-scijava",
    "version": "19.0.0",
    "attributes": {
      "org.gradle.status": "release"
    }
  },

which seems to be the version of pom-scijava-base (19.0.0) and not of pom-scijava (38.0.1).

Since the logic for setting the version in build.gradle.kts is

version = File("../pom.xml").readText().substringAfter("<version>").substringBefore('<')

is this an error that occurs because of the order in which versions appear in the xml?

(The bigger picture: I'm having problems using scijava-pom for dependencies with native libraries, because it uses profile activation based on os.family and it seems Gradle doesn't support that - so I was hoping that a switch to use the version catalog here might help me figure out a workaround)

Thanks!

@ctrueden
Copy link
Member

ctrueden commented Dec 11, 2024

@petebankhead Thanks a lot for trying out the Gradle catalog! Much appreciated. 👍

I guess you are the first person to try using it in practice, because this is clearly a major error. I think your diagnosis of the issue is correct. It's too late now to fix the 38.0.1 or 39.0.0 pom-scijava releases, but I fixed the logic for the next release (8d52f8b). I will release version 40.0.0 ASAP, but in the course of testing this I found that I had neglected to reenable pom-scijava's integration tests for the past few weeks, so now they need to run (which can take hours), and then I need to fix any newly uncovered problems, before I can release 40.0.0. I'll keep you posted.

@ctrueden
Copy link
Member

ctrueden commented Dec 11, 2024

The issue with native library dependencies is something @elect86 was previously thinking about how best to address. Related issues and repositories: #241, scijava/pom-scijava-base#30, os-maven-plugin, native-lib-loader, scijava/native-lib-loader#50.

@ctrueden
Copy link
Member

ctrueden commented Dec 11, 2024

I've released pom-scijava 40.0.0 to OSS Sonatype; should be mirrored to Maven Central within the next few minutes. I'll be curious to hear what the next obstacle is when attempting to use it from Gradle. 😆

@petebankhead
Copy link
Author

It works, thanks! After importing the version catalog as sciJava, I can now work around the profile problem with

dependencies {
    implementation(sciJava.bundles.fiji)
    {
        exclude(group = "org.jogamp.gluegen")
        exclude(group = "org.jogamp.jogl")
        exclude(group = "org.jogamp.joal")
        exclude(group = "org.bytedeco", module = "ffmpeg")
    }
    implementation(sciJava.org.jogamp.gluegen.gluegenRt)
    implementation(sciJava.org.jogamp.jogl.joglAll)
    implementation(sciJava.org.bytedeco.ffmpeg)
    // Can apply the JavaCPP Gradle plugin to avoid getting dependencies for all platforms here
    implementation("org.bytedeco:ffmpeg-platform:${sciJava.org.bytedeco.ffmpeg.get().version}")

    val classifier = getJogampClassifier()
    if (classifier != null) {
        implementation("org.jogamp.gluegen:gluegen-rt:${sciJava.org.jogamp.gluegen.gluegenRt.get().version}:natives-macosx-universal")
        implementation("org.jogamp.jogl:jogl-all:${sciJava.org.jogamp.jogl.joglAll.get().version}:natives-macosx-universal")
        implementation("org.jogamp.joal:joal:${sciJava.org.jogamp.joal.joal.get().version}:natives-macosx-universal")
    } else {
        logger.warn("Native libraries not found for jogamp")
    }
}


fun getJogampClassifier(): String? {
    if (Os.isFamily(Os.FAMILY_MAC)) {
        return "natives-macosx-universal"
    }
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        return "natives-windows-amd64"
    }
    if (Os.isFamily(Os.FAMILY_UNIX)) {
        return if (Os.isArch("arm64")) {
            "natives-linux-aarch64"
        } else {
            "natives-linux-amd64"
        }
    }
    return null
}

@ctrueden
Copy link
Member

@petebankhead Awesome!

One question: I see these lines amongst the above:

implementation("org.jogamp.gluegen:gluegen-rt:${sciJava.org.jogamp.gluegen.gluegenRt.get().version}:natives-macosx-universal")
implementation("org.jogamp.jogl:jogl-all:${sciJava.org.jogamp.jogl.joglAll.get().version}:natives-macosx-universal")
implementation("org.jogamp.joal:joal:${sciJava.org.jogamp.joal.joal.get().version}:natives-macosx-universal")

This is hardcoding for macOS... it should instead be:

implementation("org.jogamp.gluegen:gluegen-rt:${sciJava.org.jogamp.gluegen.gluegenRt.get().version}:$classifier")
implementation("org.jogamp.jogl:jogl-all:${sciJava.org.jogamp.jogl.joglAll.get().version}:$classifier")
implementation("org.jogamp.joal:joal:${sciJava.org.jogamp.joal.joal.get().version}:$classifier")

Right?

@petebankhead
Copy link
Author

Oops, it should indeed, you can see what I was developing with....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants