jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
142 stars 20 forks source link

Leiningen local jars are not picked up #131

Open yaitskov opened 1 month ago

yaitskov commented 1 month ago

leiningen project file has option resource-paths which can enumerate local jars to be loaded.

$ nix build .#clj-tuto
warning: Git tree '/home/iaitskovd/demo/clojure/hello-leiningen' is dirty
this derivation will be built:
  /nix/store/i0cv9s6syxbbjw6p6pjskfml6z01ms38-clj-tuto-1.0.drv
building '/nix/store/i0cv9s6syxbbjw6p6pjskfml6z01ms38-clj-tuto-1.0.drv'...
error: builder for '/nix/store/i0cv9s6syxbbjw6p6pjskfml6z01ms38-clj-tuto-1.0.drv' failed with exit code 1;
       last 19 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/xdn2x237qfr9d6wscncwnf8a0232wk0m-zbzajvrkba930qwzclzgzg2izplkkc5j-source
       > source root is zbzajvrkba930qwzclzgzg2izplkkc5j-source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: preBuildPhase
       > Running phase: buildPhase
       > Picked up JAVA_TOOL_OPTIONS: -Duser.home=/nix/store/6adp2xa2p37bjv8fb23wr09rjz4fkpik-clj-cache
       > Picked up JAVA_TOOL_OPTIONS: -Duser.home=/nix/store/6adp2xa2p37bjv8fb23wr09rjz4fkpik-clj-cache
       > Compiling hello-leiningen.core
       > Syntax error macroexpanding at (core.clj:1:1).
       > Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:445).
       > org.apache.commons.io.FileUtils
       >
       > Full report at:
       > /tmp/clojure-10162745145026503862.edn
       > Compilation failed: Subprocess failed (exit code: 1)
       For full logs, run 'nix log /nix/store/i0cv9s6syxbbjw6p6pjskfml6z01ms38-clj-tuto-1.0.drv'.
(defproject hello-leiningen "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  ; ...
  :resource-paths ["lib/commons-io-2.4.jar" ]
  ; ...
  )
(ns hello-leiningen.core
  (:import (com.google.common.collect Maps))
  (:import (org.apache.commons.io FileUtils)
           (java.io File))
  (:gen-class))

)
          clj-tuto = pkgs.mkCljBin {
            projectSrc = ./.;
            name = "demo/clj-tuto";
            version = "1.0";
            main-ns = "hello_leiningen.core";
            # jdkRunner = pkgs.jdk17_headless;
            # javacOpts = "-cp lib/commons-io-2.4.jar";
            buildCommand = "CLASSPATH=$PWD/lib/commons-io-2.4.jar ${pkgs.leiningen}/bin/lein uberjar";
            # mkDerivation attributes
            # doCheck = true;
            # checkPhase = "clj -M:test";
          };
jlesquembre commented 1 month ago

I've never personally used leiningen, I only added support for it because it was relatively straightforward. Therefore, fixing this issue is a lower priority for me.

That said, I'm open to pull requests.