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

add simple-omero-client as dependency in a build.gradle file #30

Open
Rdornier opened this issue Jun 8, 2022 · 20 comments
Open

add simple-omero-client as dependency in a build.gradle file #30

Rdornier opened this issue Jun 8, 2022 · 20 comments

Comments

@Rdornier
Copy link
Contributor

Rdornier commented Jun 8, 2022

Hello @ppouchin,

I have an issue when I try to add simple-omero-client as a dependency in this build.gradle file but I has not been able to make it work.

I try to put implementation "fr.igred:simple-omero-client:5.9.1" in the "dependencies" but an error is thrown saying that org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find GReD-Clermont:simple-omero-client:5.9.1.
The same error occurs when I wrote implementation "com.github.pkg.maven:simple-omero-client:5.9.1".

I also try to add a repository in the "repositories" field using

maven{
       url "https://maven.pkg.github.com/GReD-Clermont/simple-omero-client"
   }

but it seems that it is not taken into account because the same error is thrown.

Do you know how to add the dependency to the build.gradle correctly ?

Thanks,
Rémy.

ping @romainGuiet

@ppouchin
Copy link
Member

ppouchin commented Jun 8, 2022

Hi @Rdornier,

I'm not sure how to properly configure GitHub Maven repos.
For now, I'm using a self-hosted repository, as can be seen in the ImageJ plugins using the library.

Maybe try with this URL first, and if it works, then that means the problem comes from the interaction with GitHub.
Have you tried the instructions from GitHub?

@Rdornier
Copy link
Contributor Author

Rdornier commented Jun 9, 2022

Hello @ppouchin ,

Thanks for your answer.
I try with the above URL for two projects : one written with maven and my current one with gradle.
It comes out that it perfectly work for a Maven project but it doesn't work for the gradle project, the one for which I want to link the dependency. It seems that the issue is coming from the fact that the new repository URL is never read. Here is how I implement the dependency in the gradle project.

repositories {
     mavenCentral()
    // some more maven repositories
     maven{
            url "https://artifacts.igred.fr/releases"
     }
}
dependencies {
     // some more dependencies
      implementation "fr.igred:simple-omero-client:5.9.1"
}

I read github instructions but it seems that the package is public so I don't need to authenticate, right ?
Here is the full error I get. There is no trace of the above url.

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find fr.igred:simple-omero-client:5.9.1.
Searched in the following locations:
  - https://repo.maven.apache.org/maven2/fr/igred/simple-omero-client/5.9.1/simple-omero-client-5.9.1.pom
  - https://maven.imagej.net/content/groups/public/fr/igred/simple-omero-client/5.9.1/simple-omero-client-5.9.1.pom
  - https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/fr/igred/simple-omero-client/5.9.1/simple-omero-client-5.9.1.pom
  - https://artifacts.openmicroscopy.org/artifactory/maven/fr/igred/simple-omero-client/5.9.1/simple-omero-client-5.9.1.pom
  - https://oss.sonatype.org/content/repositories/snapshots/fr/igred/simple-omero-client/5.9.1/simple-omero-client-5.9.1.pom

Thanks,
Rémy.

cc to @lacan and @NicoKiaru

@ppouchin
Copy link
Member

ppouchin commented Jun 9, 2022

Ok. This is strange.

I wanted to make a QuPath extension based on the OMERO Java API too a few months ago, but I still haven't had time to do so.
However, I did try to change the gradle build, and I don't get this error.

The attached patch works for me. Could it be a problem with the cache?
gradle.patch.txt

@Rdornier
Copy link
Contributor Author

Rdornier commented Jun 9, 2022

Yes, it's strange.
I try to clean gradle cache and do an "invalidate cache" on IntelliJ but the problem is still appearing. I looked at your piece of code; it looks similar to mine. I don't understand why I cannot add it to gradle dependencies.

By the way, we are currently working on a QuPath extension using the Java API and it is exactly this project for which I cannot add simple-omero-client dependency ! You can find the actual state of the code here ; it is a branch of the qupath-extension-omero named omero-raw.

@ppouchin
Copy link
Member

ppouchin commented Jun 9, 2022

That's what I guessed from the linked repo.
The patch I attached is exactly how I modified your build.gradle, and it works on my computer.

If I can, I'll try it later on a different OS with no trace of a Gradle project whatsoever, just to be sure.

@ppouchin
Copy link
Member

ppouchin commented Jun 9, 2022

Ok, I just tried it on a different system (Debian, never used for Java dev), and it works.
Maybe try to do a new clone of the project somewhere else and apply the patch to the omero-raw branch.
Sometimes, IntelliJ does weird things.

@Rdornier
Copy link
Contributor Author

Hello

Thanks to the great help of @lacan, we manage to add simple-omero-client as a dependance in gradle using this piece of code in the build.gradle file:

repositories {
    maven{
        url "https://artifacts.igred.fr/releases"
   }
}

dependencies {

    shadow "fr.igred:simple-omero-client:5.9.1"
}

The only thing is that we need to add simple-omero-client.jar in the project extension folder (where all other jar files are already saved).

By the way, I just want to mention that doing this way (with shadow dependencies), java reflection methods do not work in the IDE but they are working outside.

Thanks also to @NicoKiaru for the time spent to trying to debug and understand what's happened.

@Rdornier
Copy link
Contributor Author

Hello @ppouchin, @petebankhead

Sorry for reviving this issue.
I would like to properly add simple-omero-client as a dependency in my gradle-based qupath-omero extension but I always struggle with the same issue and cannot implement it properly.

My gradle file, where the dependency is included, is here ; the repo is also added "https://artifacts.igred.fr/releases" as a maven repo.

When I build, I get the following error, saying that the process fails in the build.gradle of the qupath-app (here)

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Remy\Github-projects\qupath-0.4.0\qupath\qupath-app\build.gradle' line: 75

* What went wrong:
A problem occurred configuring project ':qupath-app'.
> Could not resolve all files for configuration ':qupath-app:runtimeClasspath'.
   > Could not find fr.igred:simple-omero-client:5.14.2.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
       - https://maven.imagej.net/content/groups/public/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
       - https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
       - https://artifacts.openmicroscopy.org/artifactory/maven/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
       - https://oss.sonatype.org/content/repositories/snapshots/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
       - file:/D:/Remy/Github-projects/qupath-0.4.0/qupath/maven/repo/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
     Required by:
         project :qupath-app > project :qupath-extension-biop-omero

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':qupath-app'.
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:126)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:43)
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':qupath-app:runtimeClasspath'.
at build_9l16uvhz805t3w75o15r1z1qj$_run_closure3$_closure17$_closure18.doCall(D:\Remy\Github-projects\qupath-0.4.0\qupath\qupath-app\build.gradle:75)
at jdk.internal.reflect.GeneratedMethodAccessor247.invoke(Unknown Source)
at build_9l16uvhz805t3w75o15r1z1qj$_run_closure3$_closure17.doCall(D:\Remy\Github-projects\qupath-0.4.0\qupath\qupath-app\build.gradle:73)
at build_9l16uvhz805t3w75o15r1z1qj$_run_closure3.doCall(D:\Remy\Github-projects\qupath-0.4.0\qupath\qupath-app\build.gradle:72)
at jdk.internal.reflect.GeneratedMethodAccessor246.invoke(Unknown Source)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:126)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:43) 
Cause 1: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find fr.igred:simple-omero-client:5.14.2.
Searched in the following locations:
  - https://repo.maven.apache.org/maven2/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
  - https://maven.imagej.net/content/groups/public/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
  - https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
  - https://artifacts.openmicroscopy.org/artifactory/maven/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
  - https://oss.sonatype.org/content/repositories/snapshots/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
  - file:/D:/Remy/Github-projects/qupath-0.4.0/qupath/maven/repo/fr/igred/simple-omero-client/5.14.2/simple-omero-client-5.14.2.pom
Required by:
    project :qupath-app > project :qupath-extension-biop-omero

Do you have an idea on how I could make it work ?

Thanks,
Rémy.

@ppouchin
Copy link
Member

Hello @Rdornier ,

It looks like the build is failing in IntelliJ.
Does it fail if you build it in a separate Conda environment on the command line?

@petebankhead
Copy link

@Rdornier does the info here help? Specifically the bit about includeFlat
https://github.com/qupath/qupath-extension-template#set-up-in-an-ide-optional

@Rdornier
Copy link
Contributor Author

Sorry for my late answer.

Specifically the bit about includeFlat
https://github.com/qupath/qupath-extension-template#set-up-in-an-ide-optional

It still fails

Does it fail if you build it in a separate Conda environment on the command line?

I don't have any Conda environnement to built it. However, I tried adding the dependency in another gradle-based project and it worked without any issue. It seems to be intelliJ-qupath-related (or at least the qupath-project configuration on my intelliJ) but I cannot find out any clue...

@ppouchin
Copy link
Member

It seems to be intelliJ-qupath-related (or at least the qupath-project configuration on my intelliJ) but I cannot find out any clue...

If you try to setup the project anew on a different machine, or in a different folder, does it work? It think I did not encounter such a problem when I tried to build the project on my computer.

@Rdornier
Copy link
Contributor Author

Hello,
I tried on my personal computer and there is no differences. I'll do it on another computer but before, if it works for you, how did you do to make it work ?

@ppouchin
Copy link
Member

It was a while ago, but I think I just cloned it, opened it in IntelliJ and checked out the omero-raw branch.
I'll see if I can try again in an untouched environment.

@ppouchin
Copy link
Member

If it persists across devices, could it be a network problem alternatively?
Our repository is self-hosted, maybe something's blocking somewhere.
Can you access it from a browser? Sorry, I really find this weird...

@Rdornier
Copy link
Contributor Author

Ok, I tested two things

  1. I cloned only the repo qupath-extension-biop-omero, open it in intelliJ and there is so failure (gradle.build is correctly done and simple-omero-client is found)
  2. I clonedqupathrepo, built it => no failure. I then cloned qupath-extension-biop-omero inside the local qupath repo, added it to seetings.gradle. Then, when I re-build the whole project, I get the issue mentionned before.

Our repository is self-hosted, maybe something's blocking somewhere.
Can you access it from a browser?

Yes, I can access to it via the browser

If it persists across devices, could it be a network problem alternatively?

I tested the option 2. on my personal computer (outside the network) and on another computer on network but it gave the same.

I suspect a restriction in the build.gradle file of the qupath project but my little knowledge in gradle processes doesn't help me to find it out.

@petebankhead
Copy link

I haven't totally followed this, but I've just downloaded the code from qupath-extension-biop-omero and it builds fine for me locally.

Some notes:

  • My default JDK is 17, so I couldn't use gradlew directly - I needed to use Gradle 8.3, or else ./gradlew build -Dorg.gradle.java.home=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
  • I could use gradlew copyDependencies but only if I changed the build file to contain from configurations.runtimeClasspath instead of from configurations.default for the corresponding task

Doing the above gave me many dependencies inside build/libs/ - and this includes simple-omero-client-5.14.0.jar.

So building alone was fine. To get it working from QuPath v0.4.4, I made sure that the QuPath code was in a directory beside the extension code.

Then I changed two things in on the QuPath side:

  1. qupath/settings.gradle → add the line includeFlat 'qupath-extension-biop-omero-omero-raw' (or whatever the directory name is)
  2. qupath/buildSrc/src/main/groovy/qupath.commmon-convensions.gradle → add the repo as below
maven{
        url "https://artifacts.igred.fr/releases"
}

That was enough to make IntelliJ happy.

@petebankhead
Copy link

Basically, it seems that if you use includeFlat and want to launch from QuPath, then any extra repositories need to be added to QuPath - it's not enough to have them defined in the extension only.

There can also be some annoyances when it comes to library catalogs and plugins, whereby I sometimes need to modify my extension build.gradle to make it run-via-include-flat-friendly. So there's definitely something sub-optimal about trying to get QuPath and extensions working together nicely during development.

@Rdornier
Copy link
Contributor Author

  1. qupath/buildSrc/src/main/groovy/qupath.commmon-convensions.gradle → add the repo as below

Adding the repo here makes everything working fine !

Thank you very much @petebankhead @ppouchin for your help ! It was so annoying to add the jar/pom manually !

@petebankhead
Copy link

Good! There are so many places repos can be defined in Gradle (for code, plugins, extensions) that I don't have a good idea exactly where each declaration needs to be.

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

3 participants