Clojure from zero to hero (1) - explaining project.clj

Jun 25, 2019

(ns com.georgeracu.site.posts.fzth.one)

Dependencies

This area declares which dependencies are required for the project. From the version of Clojure to the version of the libraries used to put together the app. In this case, is a simple file where we use only Pedestal, Jetty for web server and Logback and SLF4J for logging.

For those who want to use a different web server, there is an option to enable Mutant or Tomcat. Just uncomment the line for the desired web server and comment the one for Jetty. There cannot be two active web servers at the same time.

Lein

Lein version declares which version of Leiningen we use to build our project. Think of it like Maven or Gradle.

Resource paths

Being a web app we need some directories to store our config files and static resources. These section helps to inform Leiningen where to look for them when building our project. We should place all our config files in config and static resources in resources.

Profiles

These section of the file describes what profiles are available for the command lein. You can use lein run-dev to start the app in development mode or lein uberjar to package the app in a fat jar, bundled with all dependencies required to run it as a JAR file. After packaging in a fat JAR, the Clojure app can be run from command line with: java -jar target/pedestal-api-0.0.1-SNAPSHOT-standalone.jar The server should start and run at http://localhost:8080.

Full project.clj file

(defproject pedestal-api "0.0.1-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [io.pedestal/pedestal.service "0.5.7"]

                 ;; Remove this line and uncomment one of the next lines to
                 ;; use Immutant or Tomcat instead of Jetty:
                 [io.pedestal/pedestal.jetty "0.5.7"]
                 ;; [io.pedestal/pedestal.immutant "0.5.7"]
                 ;; [io.pedestal/pedestal.tomcat "0.5.7"]

                 [ch.qos.logback/logback-classic "1.2.3" :exclusions [org.slf4j/slf4j-api]]
                 [org.slf4j/jul-to-slf4j "1.7.26"]
                 [org.slf4j/jcl-over-slf4j "1.7.26"]
                 [org.slf4j/log4j-over-slf4j "1.7.26"]]
  :min-lein-version "2.0.0"
  :resource-paths ["config", "resources"]
  ;; If you use HTTP/2 or ALPN, use the java-agent to pull in the correct alpn-boot dependency
  ;:java-agents [[org.mortbay.jetty.alpn/jetty-alpn-agent "2.0.5"]]
  :profiles {:dev {:aliases {"run-dev" ["trampoline" "run" "-m" "pedestal-api.server/run-dev"]}
                   :dependencies [[io.pedestal/pedestal.service-tools "0.5.7"]]}
             :uberjar {:aot [pedestal-api.server]}}
  :main ^{:skip-aot true} pedestal-api.server)

Tags: programmingclojure

Archives

  1. December 2024
  2. Keeping Software Simple to speed up Software Development
  3. October 2024
  4. The Kanban Café - A Story of Flow
  5. A Story on Accidental Complexity in Software Development
  6. February 2024
  7. Maximizing Software Development Productivity: The Power of Flow and Minimizing Interruptions
  8. December 2023
  9. Clean Code in Java: Writing Code that Speaks
  10. Clean Code in Java: A concise guide
  11. Understanding Value Objects in Java: A Brief Guide
  12. August 2023
  13. Must Have on Message Payload
  14. Centralised Management System For Message Schemas
  15. Consuming RabbitMQ Messages with Clojure: A Step-by-Step Tutorial with Tests
  16. January 2023
  17. Running a Spring Boot service with kubernetes
  18. December 2022
  19. Hosting a PWA with Jekyll and Github pages
  20. November 2022
  21. Global Day of Code Retreat
  22. Facilitating a mini Code Retreat
  23. October 2022
  24. The Curse of Optional
  25. September 2022
  26. Testing Spring Boot Microservices - Presentation
  27. March 2022
  28. TDD Workshop
  29. February 2022
  30. Value Objects in Java
  31. Efficient Java
  32. January 2022
  33. Spring Boot testing - Focus on your changes
  34. Product users - Personas
  35. December 2021
  36. Write code fit for testing
  37. November 2020
  38. Running a Spring Boot app with kubernetes
  39. September 2019
  40. Setup GPG on Mac and sign git repositories
  41. July 2019
  42. Running a Clojure Pedestal application on Raspberry Pi model B revision 2
  43. Clojure from zero to hero (part 3) - First endpoint
  44. Clojure from zero to hero (part 2) - A bit of syntax
  45. June 2019
  46. Clojure from zero to hero (1) - explaining project.clj
  47. Clojure from zero to hero (0) - creating a Pedestal app
  48. November 2017
  49. Introduction to Docker
  50. April 2015
  51. Git micro commits
  52. July 2014
  53. Google Glass Development - setup tools, environment and turn on debugging on Glass
  54. June 2013
  55. How To: Get the rendered HTML of a webpage with Python
  56. Set union of two lists in Python