1

Are there some useful ways of triggering complete rebuilds in lein? I'm finding it hard to understand how / when lein reruns/reloads code. Altering files doesn't always seems to result in the changes being applied, and manually requesting recompile for gen-class doesn't always seem to generate files.

Manually deleting files in the target directory doesn't always work, as even if I recompile those files are not always generated so I'll get ClassNotFound errors. How do I have lein properly rebuild everything on each invocation?

edit: most of my confusion was due to not specifying classes created with gen-class in the project.clj file with an :aot directive as suggested in @juan.facorro's comment, e.g.

(defproject 
     ...
      :aot [mytestclass.full.packagename.TestClass1 mytestclass.full.packagename.TestClass2 ]
     ...
    )
4
  • Does running lein clean before doing any compilation through any of the other commands (i.e. lein compile, lein run, lein repl) not work? Commented Jan 27, 2014 at 18:50
  • yes, with 2 caveats - a) it deletes things from /lib where I'm storing some extra jars, so that's a minor hassle, and b) more seriously, it doesn't seem to always generate the classes I've defined in gen-class. Even if my run method explicitly calls (compile .. ). Which makes no sense to me at all.
    – Steve B.
    Commented Jan 27, 2014 at 19:04
  • 1
    Have you tried adding the ns where the :gen-class is used to the :aot option in your leiningen project.clj? I can't seems to reproduce the behavior you describe though, doing lein clean removes the target directory, and adding either (compile 'the.Example) or :aot [the.Example] generates the the/Class.class file. Can you post the steps you follow when you see this behavior? Commented Jan 27, 2014 at 19:50
  • Yes, the aot specification was what I was missing, thanks.
    – Steve B.
    Commented Jan 29, 2014 at 17:47

1 Answer 1

1

This sounds like part of a bigger issue: making the clojure development cycle shorter. Once you have your project running happily in the REPL (and this is the first goal) there are several things thats can really drag down the development speed. Changing protocol deffinitions for instance requires you to hunt down and reload every namespace that has instances of that protocol. Stewart Sierra made a great project, gave a presentation and interview about how to set up your project and process so everything that needs reloading is reloaded as quickly as possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.