Leiningen 및 Deps.edn 기초
프로젝트 생성, 종속성 관리 및 작업 자동화를 위한 Leiningen과 Deps.edn의 기본 개념을 이해합니다.
Leiningen 및 Deps.edn 기초은(는) CoddyKit의 무료 Clojure Functional Programming & JVM Backend Development 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Clojure Functional Programming & JVM Backend Development 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Clojure Functional Programming & JVM Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Why Clojure Needs Build Tools
In Clojure, build tools are essential for automating tasks like managing dependencies, compiling code, running tests, and packaging your application. They simplify project setup and ensure consistency.
Without them, you'd manually download libraries, set up classpaths, and invoke the JVM, which quickly becomes cumbersome for any non-trivial project.
Leiningen: The Clojure Workhorse
Leiningen is a popular and mature build automation tool for Clojure projects. It's inspired by Maven and handles everything from creating new projects to deploying them.
Its primary configuration file is project.clj, a Clojure data structure itself, making it very flexible.
Creating a Leiningen Project
You can create a new Leiningen application project using the lein new command. This command quickly generates a standard directory structure with boilerplate code.
Run this command in your terminal:
lein new app my-lein-appInside project.clj
The project.clj file defines your project's metadata and configuration. Key elements include:
:dependencies: A list of external libraries your project needs.:main: Specifies the main entry point for your application.:version: Your project's current version.
It's written in Clojure syntax, allowing for powerful, dynamic configurations.
(defproject my-lein-app "0.1.0-SNAPSHOT"
:description "A sample Leiningen project."
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.11.1"]]
:main ^:skip-aot my-lein-app.core
:target-path "target/%s")First Run with Leiningen
After creating your project, Leiningen provides an easy way to run your application. The lein run command executes the main function specified in project.clj.
Here's the default core.clj content that lein new app generates. Try running it!
(ns my-lein-app.core
(:gen-class))
(defn -main
"The entry point for our Leiningen app."
[& args]
(println "Hello from Leiningen!"))Deps.edn: The Official Tool
deps.edn is Clojure's official and more lightweight dependency management and build tool, introduced with Clojure 1.9. It focuses solely on managing dependencies and classpaths.
It uses EDN (Extensible Data Notation), a subset of Clojure, for its configuration, making it very readable and easy to parse.
Setting Up a Deps.edn Project
Unlike Leiningen, deps.edn doesn't have a new command to scaffold projects. You typically create the necessary files and directories manually.
A minimal project requires a deps.edn file in your project root and a source directory (e.g., src) for your code.
Inside deps.edn
The deps.edn file defines your project's dependencies and source paths. Key elements include:
:paths: A vector of directories where your source code is located.:deps: A map of external libraries and their versions, typically using Maven coordinates.
It's simpler than project.clj, focusing on classpath construction.
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/tools.cli {:mvn/version "1.0.206"}}}First Run with Deps.edn
To run a deps.edn project, you use the clj command (the Clojure CLI tool). You specify the main namespace using -m.
Here's a simple core.clj file that can be run with clj -m my-deps-app.core. Try it out!
(ns my-deps-app.core
(:gen-class))
(defn -main
"The entry point for our deps.edn app."
[& args]
(println "Hello from deps.edn!"))Leiningen vs. Deps.edn
Both Leiningen and deps.edn are excellent tools, but they serve slightly different philosophies:
- Leiningen: An all-in-one project manager with extensive plugin support for various tasks (testing, deployment, etc.).
deps.edn: A simpler, more focused tool for dependency and classpath management, often used with other CLI tools for specific tasks.
Many modern Clojure projects use deps.edn for its simplicity and directness, sometimes alongside Leiningen.
Build Tool Knowledge Check
Consider the core purpose and configuration approach of Leiningen and deps.edn.
Recap: Leiningen & Deps.edn Basics
We've explored the fundamentals of Clojure's two primary build tools:
- Leiningen: A full-featured tool using
project.cljfor configuration, offering project creation and task automation. deps.edn: A lightweight, official tool usingdeps.ednfor classpath and dependency management, typically used with thecljCLI.
Both are crucial for managing Clojure projects efficiently, allowing you to choose based on your project's needs.
AI 튜터와 함께 Clojure을(를) 배우세요 — 무료
브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.
- 코스
- 12
- 레슨
- 48
자주 묻는 질문
“Leiningen 및 Deps.edn 기초” 강의는 무료인가요?
네 — “Leiningen 및 Deps.edn 기초” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Clojure Functional Programming & JVM Backend Development 강의 전체를 잠금 해제할 수 있습니다. Clojure Functional Programming & JVM Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.
“Leiningen 및 Deps.edn 기초”에서 뭘 배우나요?
프로젝트 생성, 종속성 관리 및 작업 자동화를 위한 Leiningen과 Deps.edn의 기본 개념을 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 Clojure Functional Programming & JVM Backend Development을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Clojure Functional Programming & JVM Backend Development을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Clojure Functional Programming & JVM Backend Development은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.
“Leiningen 및 Deps.edn 기초” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Clojure Functional Programming & JVM Backend Development 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Clojure Functional Programming & JVM Backend Development 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Leiningen 및 Deps.edn 기초
- 종속성 및 플러그인 관리
- 빌드, 테스트 및 배포
- 프로필, 별칭 및 환경 관리