项目作者: borkdude

项目描述 :
Infer mvn deps from sources
高级语言: Clojure
项目地址: git://github.com/borkdude/deps-infer.git
创建时间: 2021-02-24T11:01:11Z
项目社区:https://github.com/borkdude/deps-infer

开源协议:Eclipse Public License 1.0

下载


deps-infer

Infer mvn deps from sources.

Status

Proof of concept, subject to change. Improvements welcome!

Use cases

This tool can be used to:

  • Make implicit deps explicit
  • Check which deps you are not using by comparing the output with your existing deps.edn
  • Port a lein project.clj or boot build.boot to deps.edn
  • Port scripts (e.g. babashka
    scripts) to a deps.edn project.
  • Migrate from git deps to mvn deps
  • Check if there is a newer version available

Run

  1. $ clojure -M -m deps-infer.main

This will index your .m2/repository and will analyze your sources under src
and test.

By default it will write the analysis output on a .deps-infer/ inside the --repo
directory. You can change the location using the --cache-dir option.

After that it will suggest a list of dependencies that you can add to your
deps.edn. It will always pick the newest version that is available in your .m2
repo.

For this project it will print:

  1. babashka/fs {:mvn/version "0.0.1"}
  2. clj-kondo/clj-kondo {:mvn/version "2021.02.13"}
  3. org.clojure/clojure {:mvn/version "1.10.3-rc1"}
  4. org.clojure/tools.cli {:mvn/version "1.0.194"}
  5. version-clj/version-clj {:mvn/version "2.0.1"}

Namespaces that cannot be resolved will cause a warning to be printed:

  1. $ cat corpus/non_existing.clj
  2. (ns non-existing
  3. (:require [foo.bar :as x]))
  1. $ clojure -M -m deps-infer.main --analyze corpus/non_existing.clj
  2. WARNING: no dep found for foo.bar

CLI options

  • --repo: The location of the mvn repo.
  • --analyze: The file, directory or directories of sources to analyze. You can
    combine multiple files and directories using the OS-specific path separator:
    src:test.
  • --snapshots: Suggest SNAPSHOT versions.

Possible improvements

PRs welcome.

  • Download an index of all of Clojars for inferencing of deps that are not
    1. in your local `.m2/repository`. This index must be kept up to date,
    2. e.g. daily, and be committed to some git repo where we can then fetch it.

Troubleshooting

To re-index your repo, remove the index of namespaces to jars, run:

  1. $ rm -rf .work/index.edn

and then run this tool again.

Credits

License

Copyright © 2021 Michiel Borkent

Distributed under the EPL License. See LICENSE.