Leiningen2 - humane build management for clojure

1,743 views

Published on

Managing project builds does not have to be an endless fight with XML. Using Leiningen for Clojure projects allows you to define the project in Clojure as well.

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,743
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Leiningen2 - humane build management for clojure

  1. 1. L e in in g e n 2 H u m a n e b u ild m a na g e m e n t fo rClojureMadeSimple.co.uk
  2. 2. slideshare.net/jr0cket This slide deck is available to follow along with on slideshare.net
  3. 3. of Java buildmanagement
  4. 4. ...there was Ant, Ant begat Ivy,Ant begat Maven
  5. 5. … and there was much XML all around
  6. 6. Here endeth the lesson..(except of course this is just the end of the beginning)
  7. 7. Human verses Computer readable build jobs
  8. 8. buildmanagement
  9. 9. Leiningen … more fun than Maven… easy way to kick-start your Clojure addiction
  10. 10. Installing LeiningenDownload the Leiningen 2 install script from leiningen.orgMove the lein file to an executable location, eg. ~/binMake the install script executable and run the install chmod u+x ~/bin/lein
  11. 11. All the usual tasks, and then somelein new Create a new clojure projectlein deps Download all dependencieslein run Run your applicationlein jar Deploy your app as a jarlein uberjar Deploy your app & clojure librarieslein repl Start the interactive shell (repl)lein jack-in Start repl server and connect (in Emacs)
  12. 12. Fire up the REPL REPL: read, evaluate, print loop – dynamiclein repl environment for Clojure and other lisps
  13. 13. View function documentation(doc map)
  14. 14. Show function source code(source map)
  15. 15. REPL driven developmentDevelop functions and data structures on the fly REPL: read, evaluate, print loop – dynamic environment for Clojure and other lisps
  16. 16. Loading code into the REPLDevelop functions and data structures on the fly REPL: read, evaluate, print loop – dynamic environment for Clojure and other lisps
  17. 17. Create a new projectlein new my-projectcd my-projectlein depsLein deps will check your project.clj configuration file anddownload any libraries (jar files) that are required by the project
  18. 18. Anatomy of a new project
  19. 19. Create a new projectlein new my-projectcd my-projectlein depsLein deps will check your project.clj configuration file anddownload any libraries (jar files) that are required by the project
  20. 20. Version your project with Gitcd my-projectgit initCreate a repo on github & add it to your projectgit remote add origin git@github.com/account/project.gitgit push -u origin master You may want to edit your .git-ignore file also
  21. 21. Open project in emacscd my-projectemacs project.clj
  22. 22. project.clj - project definitionLein deps will check this project.clj configuration file anddownload any libraries (jar files) that are required by the project
  23. 23. Dev DependenciesAdd libraries only needed for developmentNot packaged when code deployed
  24. 24. https://clojars.org/
  25. 25. http://search.maven.com
  26. 26. Add a REPL serverREPL: read, evaluate, print, loop – dynamic environment for Clojureand other lisps
  27. 27. Add REPL server to all projects~/.lein/profiles.clj
  28. 28. Fire up the REPL in Emacs M – x clojure- jack-inM – x represents the keyboard combination of the meta key followed by x.Then the command clojure-jack-in is entered.
  29. 29. Define your own Global short-cutOpen your .emacs.d/init.el file and add:(global-set-key (kbd "C-c C-j") clojure-jack- in)In Emacs, start the REPL with C – c C – j
  30. 30. REPL in Emacs
  31. 31. Add web based REPL ~/.lein/profiles.cljREPL: read, evaluate, print, loop – dynamic environment for Clojureand other lisps
  32. 32. Leiningen WebRepl plugin
  33. 33. Local Repositories (just like Maven)
  34. 34. Libraries kept in local .m2 folder
  35. 35. Nexus / Artefactory repositorieshttps://github.com/technomancy/leiningen/blob/pr eview/sample.project.clj
  36. 36. Running your project
  37. 37. Create a new projectlein runRuns the main function, or specify main with -m option
  38. 38. Long running processeslein trampoline run -m my-stuff.server 5000
  39. 39. Running Testslein testslein tests my.proj.code
  40. 40. Deployment
  41. 41. Jars & Uber Jarslein uberjar
  42. 42. Leiningen Plug-ins
  43. 43. Running scripts Copying files DVCS (git) ContinuousIntegration server (Jenkins)
  44. 44. Leiningen.org - Tutorials- Github Repository - News - Bug reporting
  45. 45. Choose Life...… choose Clojure
  46. 46. Th a n k yo u LondonClojurians.org @ r 0c ket j ClojureMadeSimple.co.ukslideshare.net/jr0cket

×