How to avoid a gradle build error when a dependency does not exist, compile should be ok anyway

68 views Asked by At

How can I avoid a build error during dependency resolution in a Java Gradle plugin when programmatically adding a dependency whose name is calculated based on certain criteria? I need to handle cases where the dependency may not exist in my artifact repository, with its version being retrieved from a Maven BOM. Even if the dependency does not exist, I still want my build to proceed without errors. Any suggestions would be greatly appreciated. Thank you!

I tried to resolve my dependency using a detachedConfiguration and catching any Exception on the resolve() method so that I could add it to the exclusions of the respective configurations. This solution works, but I had to define the version of the dependency, whereas, as mentioned earlier, the version is defined by the Maven BOM.

0

There are 0 answers