 (defn deser-dep [dep-map]
   (-> dep-map 
     (update-in [:path] #(File. ^String %))
-    (update-in [:native-path] #(File. ^String %))))
+    (update-in [:native-path] #(File. ^String %))
+    (update-in [:source-attachment-path] #(when % (File. ^String %)))))
 
 (defn load-project-dependencies
   "Retrieve from disk (from the Plugin state directory), the deps for the project.

  [project-dependencies]
  (let [entry-list (map library-entry project-dependencies)]
    (make-leiningen-classpath-container entry-list)))

(defn resolve-dependencies
  "ADAPTED FROM LEININGEN-CORE resolve-dependencies.

                 (map #(.getAbsolutePath %) ~'dependencies))))]
    (map #(File. ^String %) deps-paths)))

(defn ser-dep [path native-path source-attachment-path]
  (let [s {:path (.getAbsolutePath (io/as-file path))
           :native-path (.getAbsolutePath (io/as-file native-path))}]
    (if source-attachment-path
      (assoc s :source-attachment-path (.getAbsolutePath (io/as-file source-attachment-path)))
      s)))

(defn get-project-dependencies
  "Return the dependencies sorted alphabetically via their file name.
   Throws Aether exceptions if a problem occured"
  [project-name lein-project]
  (let [dependencies (resolve-dependencies project-name :dependencies lein-project)
        default-native-platform-path (u/lein-native-platform-path lein-project)
        srcmap (get-source-map lein-project)]
    ;(println "default-native-platform-path:" default-native-platform-path)
    (->> dependencies
      (filter #(re-find #"\.(jar|zip)$" (.getName ^File %)))
      (sort-by #(.getName ^File %))
      (map #(ser-dep %
                     default-native-platform-path
                     (get srcmap %)
                     #_(or #_(u/lein-native-dependency-path lein-project %) ;; TODO make this work :-(
                         default-native-platform-path))))))

