skeeto / javadoc-lookup

Quickly lookup Javadoc pages from Emacs
The Unlicense
56 stars 14 forks source link

Multiple Repositories to fetch from #1

Open delexi opened 11 years ago

delexi commented 11 years ago

I just stumbled upon this very handy tool and tried to fetch a library that is not in Maven Central, but in a repository hosted on google code. See: http://code.google.com/p/javabuilders/

Upon evaluation the following

  (javadoc-add-artifacts [org.javabuilders javabuilder-swing "1.1.0"])

I was presented this error:

Debugger entered--Lisp error: (error "Failed to fetch [org\\.javabuilders javabuilder-swing \"1.1.0\"]")
  signal(error ("Failed to fetch [org\\.javabuilders javabuilder-swing \"1.1.0\"]"))
  error("Failed to fetch %S" [org\.javabuilders javabuilder-swing "1.1.0"])
  javadoc-add-artifacts([org\.javabuilders javabuilder-swing "1.1.0"])
  eval((javadoc-add-artifacts [org\.javabuilders javabuilder-swing "1.1.0"]) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)

Is there a way to fetch this javadoc?

skeeto commented 11 years ago

Emacs literally just calls Maven to fetch these things, so, assuming it already works fine with Maven Central artifacts, all you need to do is configure Maven to use a repository that has this artifact (with Javadoc). I believe you can install the artifact locally somehow and Maven will fetch it from that local cache.

delexi commented 11 years ago

My pom.xml lists a repository that includes the required artifact and mvn dependency:resolve -Dclassifier=javadoc actually downloads the JavaDoc for org.javabuilders and puts them into ~/.m2/... What do you mean by installing the artifact locally?

skeeto commented 11 years ago

I actually know very little about Maven, so I could be completely mistaken. Isn't there an install command, which "Copies the project artifacts into your local repository"?

Anyway, you said you already have a repository configured so you're past that step. Except for the specific destination path, here's the command that javadoc-lookup would run to fetch this dependency. (Change the destination directory as needed to try this.)

mvn org.apache.maven.plugins:maven-dependency-plugin:2.6:get -Dartifact=org.javabuilders:javabuilder-swing:1.1.0:javadoc -Ddest=/tmp/tmp.jar

This process must be exiting with a non-zero exit code, but unfortunately javadoc-lookup is not catching any error messages from Maven right now so we're in the dark.

delexi commented 11 years ago

This command only succeeds, if the current working directory is a maven project with a pom.xml that has the right repository configured. Maybe javadoc-lookup executes mvn from the wrong directory?

skeeto commented 11 years ago

Ah, that explains it. I hadn't thought of that. Right now it's running Maven in whatever directory call-process uses by default, which may just be your home directory. Since this artifact could be being fetched at any time, like during Emacs initialization, it doesn't really have any particular place to run it.

To me, it appears the solution would to be to configure Maven to see this repository globally (i.e. like Maven Central), not from only within a particular project, so that the fetch can be done from any directory. You seem to know more about Maven than me, so does this make sense to you? Fetching only happens once and the result is cached by Emacs, so this configuration doesn't need to be in place forever.