Function: projection-maven-resolve-and-extract-source-files

projection-maven-resolve-and-extract-source-files is an autoloaded and natively compiled function defined in projection-type-maven.el.

Signature

(projection-maven-resolve-and-extract-source-files)

Documentation

Resolve, download, and extract all dependencies of the currrent project.

Artifacts will be dumped to a subdirectory of projection-local-cache-directory. When invoked this function will clear any cached value for projection-maven-local-source-directories.

Source Code

;; Defined in /nix/store/j6y921qbdmdqxjnd43iibapbig3p4hai-emacs-packages-deps/share/emacs/site-lisp/elpa/projection-20260614.1822/projection-type-maven.el
;; Maven source download.

(defun projection-maven-resolve-and-extract-source-files ()
  "Resolve, download, and extract all dependencies of the currrent project.
Artifacts will be dumped to a subdirectory of
`projection-local-cache-directory'. When invoked this function will clear any
cached value for `projection-maven-local-source-directories'."
  (unless (executable-find "unzip")
    (user-error "Extracting java source files requires unzip to be installed"))
  (let ((output-file (make-temp-file "projection-maven")))
    (unwind-protect
        (progn
          (message "Resolving maven sources, this may take a while.")
          (projection--log :info "Resolving maven sources")

          (when (projection-maven--call-resolve-sources output-file)
            (with-temp-buffer
              (insert-file-contents output-file)
              (if (search-forward-regexp (rx "The following files have been resolved:") nil 'noerror)
                  (while-let ((resolved-source (projection-maven--next-resolved-source-line)))
                    (cl-destructuring-bind (group-id artifact-id artifact-format
                                                     artifact-type version location)
                        resolved-source
                      (when (and (string-equal artifact-format "jar")
                                 (string-equal artifact-type "sources"))
                        (message "Extracting %s" location)
                        (let ((dest-dir (projection-maven--resolved-source-local-source-directory
                                         group-id artifact-id version)))
                          (make-directory dest-dir 'parents)
                          (projection--shell-command-to-string
                           (projection--join-shell-command
                            `("unzip" "-d" ,dest-dir "-o" ,location)))))))
                (error "Unable to find start of resolved file list in output: %s" (buffer-substring (point-min) (point-max)))))))
      (delete-file output-file)
      (projection-cache-clear-single
       (projection--current-project 'no-error)
       'projection-maven-local-source-directories
       projection--project-cache))))