tools-deps 2023-08-26

I can ask it but perhaps it's easy enough What I am doing wrong here?

user> (tools.deps/resolve-deps {:deps '{com.google.cloud.opentelemetry/exporter-trace {:mvn/version "0.25.2"}}}
                                                         {})
Execution error (ArtifactNotFoundException) at org.eclipse.aether.internal.impl.DefaultArtifactResolver/resolve (DefaultArtifactResolver.java:496).
Could not find artifact org.apache:apache:pom:21
When depending on com.google.cloud.opentelemetry/exporter-trace via deps.edn, it works fine and it gets added to the classpath. But with programmatic usage, it chokes on https://mvnrepository.com/artifact/org.apache/apache/21 , which to be fair looks like an odd dependency: [org.apache/apache "21" :extension "pom"] I have tried different variations of programmatic usage, no luck

Alex Miller (Clojure team) 2023-08-26T12:32:40.659889Z

The last argument of resolve-deps is the procurer config - you’re passing an empty map which means you are defining no maven repos, so nothing will be found

Thanks, Alex! specifying :mvn/repos worked. Perhaps the behavior when they're nil/empty could be improved? In this thread I showed one way in which errors won't point in that direction. In this other question I posted another https://ask.clojure.org/index.php/13201/clojure-tools-deps-calc-basis-unable-resolve-version-range It would probably make sense to fail-fast when performing maven ops with no repos backing them? Or at least, include that info prominently in the ex-msg / ex-data.

Alex Miller (Clojure team) 2023-08-26T16:09:24.852319Z

It's important to separate the CLI (which provides a lot of assumptions and defaults) from the lib. The lib is a more general tool and you have to provide more context. You don't need to pass any maven repos if you're doing git-only stuff for example, so it's not an error to not have repos. If you get unable to resolve, that's what it means - the lib you asked for can't be found in the repos given. There's no way to know if that's because you didn't provide the right repos or if the lib doesn't exist.

Alex Miller (Clojure team) 2023-08-26T16:09:58.511459Z

even if you don't have repos you might be able to serve libs already in the local cache

Yes, I understand those principles, and in particular that there isn't a hard-and-fast way to determine the cause of a failure. However by including the :mvn/repos in the ex-data, users can make a more educated guess of what's going on.

Alex Miller (Clojure team) 2023-08-26T19:19:52.531269Z

well, I think you're probably wrong because no one actively looks at the ex-data

IDK, we Clojurists are a diverse and generally smart bunch :)

Alex Miller (Clojure team) 2023-08-26T19:52:35.314259Z

well that is true

Does the clojure.tools.deps ns have a function that given a "-M:what:ever" , will return (or at least include somewhere) the main program that will be executed? i.e. the name of the underlying java class

Alex Miller (Clojure team) 2023-08-26T15:56:23.556439Z

https://clojure.github.io/tools.deps/#clojure.tools.deps/create-basis is really the primary entry point now and it takes :aliases vector. all merged and resolved alias options will be in the :argmap of the return map

Alex Miller (Clojure team) 2023-08-26T15:57:55.723309Z

so (-> (create-basis {:aliases [:what :ever]}) :argmap :main-opts) should be something like ["MainClass" ...]

🤔 1

Thanks! I got it working