Hi! I’m adding to the project a specific dependenc...
# community-support
j
Hi! I’m adding to the project a specific dependency that requires a custom repository to be added. If the repository is absent, we end up with an exception like:
Copy code
> Could not resolve all files for configuration ':jetbrainsRuntimeDependency'.
         > Could not find com.jetbrains:jbr:jbr_jcef-17.0.10-windows-aarch64-b1087.21.
           Searched in the following locations:
             - <https://repo.maven.apache.org/maven2/com/jetbrains/jbr/jbr_jcef-17.0.10-windows-aarch64-b1087.21/jbr-jbr_jcef-17.0.10-windows-aarch64-b1087.21.pom>
             - <https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/jetbrains/jbr/jbr_jcef-17.0.10-windows-aarch64-b1087.21/jbr-jbr_jcef-17.0.10-windows-aarch64-b1087.21.pom>
           Required by:
               project :
Is it possible to handle such a case for the specific dependency or the whole configuration to log a nice warning instead?
v
How would the "nice" message be? It tells where it searched and that it was not found. Or do you mean like "stupid you, add the repository XXX to resolve that dependency"?
j
We provide a set of helpers that let you add required repositories more easily — I want to advertise them + link to docs.
v
If the latter, I don't think this is really possible, because you don't know which repository might fulfill the need. In corporate environments it is quite usual to have an internal repository that has all dependencies, including that one.
Well, you could maybe provide a task that tries to do the resolution with a lenient artifact view and then check whether the dependency in question could be resolved or not or something like that.
But I'm not aware of any "do this if resolution someone else is doing failed" capability
You could maybe create a detached configuration, add your dependency non-transitively, and try to resolve it with a lenient artifact view or something like that.
But then it would do the dependency resolution at that time which might be unwanted.
plus1 1
a
Those 'dependency failed' events are available when using the tooling api. IntelliJ uses that to run Gradle, right? You could write an IntelliJ plugin to intercept them? 😁
The only events available to a Gradle Plugin are 'task finished' events https://docs.gradle.org/8.6/userguide/build_services.html#operation_listener
j
Bummer — I need to think about how to handle that as we use several custom repositories, and all of them need to be added explicitly now. I push as much as possible to Maven Central, but we cannot host i.e. JBRs there. 😭
a
if you have a Configuration that you know must contain a specific dependency, you could resolve it with
artifactView{ lenient(true) }
, and if the expected dependency is missing, then print a pretty error
j
Oh, I need to try it out — this is precisely my scenario. Thanks!
✨ 1
v
I already said that above, but šŸ¤·ā€ā™‚ļø šŸ™‚
j
In missed that, sorry! I'll definitely try this approach then.
v
I even described additionally a related approach where you add the dependency to a detached configuration and then on that use a lenient artifact view. This way you know that it resolves exactly what you want and also only that.