This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-19
Channels
- # aleph (9)
- # announcements (1)
- # asami (21)
- # aws (1)
- # babashka (4)
- # babashka-sci-dev (95)
- # beginners (35)
- # calva (27)
- # cider (17)
- # cljsrn (1)
- # clojure-europe (8)
- # clojure-norway (1)
- # clojuredesign-podcast (4)
- # clojurescript (18)
- # code-reviews (28)
- # core-logic (1)
- # cursive (3)
- # datalevin (2)
- # holy-lambda (3)
- # honeysql (1)
- # introduce-yourself (11)
- # kaocha (12)
- # lsp (11)
- # malli (9)
- # off-topic (46)
- # polylith (16)
- # re-frame (3)
- # reitit (2)
- # releases (2)
- # tools-deps (9)
- # web-security (1)
- # xtdb (2)
hello, i'm trying to import some java lib at clojure code and i'm using emacs, someone knows how could I see javadoc or parameters from those function at java code that I'm importing into my clojure code. I already tried with clojure-lsp but they don't have support yet to this. Does anyone know if cider do this?
I'm working with jgit java and would like to go to some definition inside java lib, like intellij do. Is this possible with emacs doom?
yes, 100%, javadocs and sources. You'd have to enable this option https://github.com/clojure-emacs/cider/blob/1e27eba570d265bc27317dc2a8f8c98d8b5414e0/cider.el#L428-L436 It only works for Lein projects. It's disabled by default because in big projects, occasionally it can create issues. Both things will be fixed in the next major CIDER release
For Java open source projects, I download the source code for the project and add the Java source code to the classpath.
(I think this is what the enrich paths function does in the background)
I use Clojure CLI and add the Java source code via an alias, adding an :extra-paths
that points to the Java source directory or zip archive
@U05254DQM this is my deps.edn, i'm trying go to jgit definitions, but jump to definition did not work. Even doc about the function/classes. I put extra-paths with the jgit source code.
{:paths ["src"]
:mvn/repos {"jgit-repository" {:url " "}}
:deps {org.clojure/clojure {:mvn/version "1.10.2"}
org.clojure/data.json {:mvn/version "1.1.0"}
org.clojure/tools.logging {:mvn/version "1.2.4"}
clj-jgit/clj-jgit {:mvn/version "1.0.2"
:exclusions [org.eclipse.jgit/org.eclipse.jgit.gpg.bc]}
clucie/clucie {:mvn/version "0.4.2"}
environ/environ {:mvn/version "1.2.0"}
middlesphere/clj-compress {:mvn/version "0.1.0"}
talltale/talltale {:mvn/version "0.4.3"}
org.eclipse.jgit/org.eclipse.jgit {:mvn/version "6.0.0.202111291000-r"}}
:aliases {:run {:ns-default chrondb.core
:exec-fn chrondb.core/-main}
:extra-paths ["/Users/matheusfrancisco/m/dev/jgit"]
:test {:extra-paths ["test"]
:extra-deps {clj-kondo/clj-kondo {:mvn/version "2022.02.09"}
com.cognitect/test-runner
{:git/url ""
:sha "76568540e7f40268ad2b646110f237a60295fa3c"}}
:main-opts ["-m" "cognitect.test-runner" "-d" "test"]}
:depstar {:extra-deps {seancorfield/depstar {:mvn/version "2.0.171"}}}
:uberjar {:replace-deps {seancorfield/depstar {:mvn/version "2.0.171"}}
:name "chrondb-standalone.jar"
:exec-fn hf.depstar/uberjar
:exec-args {:aot true
:jar "chrondb.jar"
:main-class "chrondb.core"
:sync-pom true}}}}
with project.clj adding the jgit to dependencies it work, but needs to type (.org.eclipse.jgit.lib.Repository) the whole path to goto definition work.
@UL618PRQ9 To include the Java standard library sources, I create an alias as follows (with the zip of the sources manually downloaded to the path specified)
:src/java17
{:extra-deps
{openjdk/java-sources {:local/root "/usr/lib/jvm/openjdk-17/lib/src.zip"}}}
I believe you should just need to move the jgit :extrapaths
into the :run
alias scope in the deps.edn file above
:aliases
{
:run {:extra-paths ["/Users/matheusfrancisco/m/dev/jgit"]
:ns-default chrondb.core
:exec-fn chrondb.core/-main}
,,,
}
Or probably they need to be a :local/root
to work (I havent tried just using the path), so that would then be
:aliases
{
:run {:extra-deps {jgit/src {:local/root "/Users/matheusfrancisco/m/dev/jgit"}}
:ns-default chrondb.core
:exec-fn chrondb.core/-main}
,,,
}
The jgit sources can be cloned from the Eclipse foundation Git service https://git.eclipse.org/c/jgit/jgit.git/ I assume the sources are not distributed in the jar files obtained from the Eclipse Maven repository, so should be downloaded separately.
git clone /Users/matheusfrancisco/m/dev/jgit
I made an example project here: https://github.com/practicalli-john/jgit-hack
There are several sub projects under the cloned repository above (I dont know if they are all needed). If other sub-projects are needed, then add an :extra-deps
for each sub-project.
In the jgit-hack project it only includes org.eclipse.jgit, so that is probably the only functions that will auto-complete and for which cider-find-var
command will work. cider-find-var
need a running repl process and at least one namespace from the clojure project to be evaluated (standard Cider function behaviour)
