종속성 및 플러그인 관리
외부 라이브러리를 추가하고 관리하며 플러그인을 활용하여 빌드 프로세스를 확장하는 방법을 학습합니다.
종속성 및 플러그인 관리은(는) CoddyKit의 무료 Clojure Functional Programming & JVM Backend Development 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Clojure Functional Programming & JVM Backend Development 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Clojure Functional Programming & JVM Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Libraries & Build Process
In any real-world project, you'll need external libraries to add functionality without writing everything from scratch. These are also called dependencies.
Build tools like Leiningen and Deps.edn help you manage these libraries, making it easy to add, update, and remove them automatically.
Leiningen: Adding Dependencies
With Leiningen, you declare dependencies in your project.clj file. They go into the :dependencies vector, which is a list of libraries your project needs.
Each dependency is a vector itself, containing the library's group ID, artifact ID, and version, for example:
[group-id/artifact-id "version"]
Leiningen: Using a Library
To use an external library like tick (a simple time library), you first add it to your project.clj file under the :dependencies key:
:dependencies [[org.clojure/clojure "1.11.1"]
[tick "0.5.0-RC1"]]
Once added, you can require the library in your namespace and use its functions. Try running this example:
(ns my-app.core
(:require [tick.core :as t]))
(defn -main
"Prints the current time using the tick library."
[& args]
(println "The current time is:" (t/now)))Deps.edn: Adding Dependencies
With deps.edn, dependencies are declared in the :deps map. This file is typically found at the root of your project.
Each entry in :deps maps a library name to a map containing its source, usually :mvn/version for Maven Central libraries:
{library-name {:mvn/version "version"}}
Deps.edn: Using a Library
To use the same tick library with deps.edn, you'd add it to your deps.edn file like this:
{:paths ["src"]
:deps {tick/tick {:mvn/version "0.5.0-RC1"}}}
With this in place, your code (e.g., in src/my_app/core.clj) can require and use the library. Try running it:
(ns my-app.core
(:require [tick.core :as t]))
(defn -main
"Prints the current time using the tick library."
[& args]
(println "The current time is:" (t/now)))Understanding Transitive Deps
When you add a library, it often relies on other libraries itself to function correctly. These are called transitive dependencies.
Your build tool automatically fetches these too. For example, the tick library might depend on clojure.java.time, which will also be downloaded.
This saves you from manually tracking every single required library for your project.
Excluding Transitive Deps
Sometimes, you might need to exclude a transitive dependency. This is usually done to avoid version conflicts with other libraries or to reduce your project's overall size.
In Leiningen, you can use the :exclusions key within a dependency vector. For example, if you wanted to exclude clojure.java.time from tick:
(defproject my-app "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.11.1"]
[tick "0.5.0-RC1" :exclusions [clojure.java-time]]]
:main ^:skip-aot my-app.core
:target-path "target/%s")Build Tool Plugins
Plugins extend the functionality of your build tool itself. They can add new tasks, automate processes, or integrate with other development tools.
Common uses include code formatting, static analysis, deployment, or running specific test suites.
Plugins are distinct from regular dependencies; they operate on the project's build process, not just provide libraries for your application code.
Leiningen: Using Plugins
Leiningen supports plugins defined in your project.clj under the :plugins key. Let's look at lein-ancient, which helps check for outdated dependencies.
You'd add [lein-ancient "0.6.15"] to your :plugins vector. Then, from your terminal, you can run lein ancient check to see if your libraries are up to date.
(defproject my-app "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.11.1"]]
:plugins [[lein-ancient "0.6.15"]]
:main ^:skip-aot my-app.core
:target-path "target/%s")Dependency Management Check
You've learned about managing dependencies and plugins in Clojure projects. Let's test your understanding.
Recap: Dependencies & Plugins
Great job! In this lesson, we covered:
- How to add external libraries (dependencies) using both Leiningen's
project.cljand Deps.edn'sdeps.edn. - The concept of transitive dependencies and how they are automatically managed.
- How to exclude specific transitive dependencies in Leiningen.
- The role of plugins in extending build tool functionality, distinct from regular libraries.
Mastering dependency and plugin management is crucial for maintaining healthy, efficient Clojure projects. Keep exploring new libraries and tools!
자주 묻는 질문
“종속성 및 플러그인 관리” 강의는 무료인가요?
네 — “종속성 및 플러그인 관리” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Clojure Functional Programming & JVM Backend Development 강의 전체를 잠금 해제할 수 있습니다. Clojure Functional Programming & JVM Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.
“종속성 및 플러그인 관리”에서 뭘 배우나요?
외부 라이브러리를 추가하고 관리하며 플러그인을 활용하여 빌드 프로세스를 확장하는 방법을 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 Clojure Functional Programming & JVM Backend Development을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Clojure Functional Programming & JVM Backend Development을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Clojure Functional Programming & JVM Backend Development은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“종속성 및 플러그인 관리” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Clojure Functional Programming & JVM Backend Development 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Clojure Functional Programming & JVM Backend Development 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Leiningen 및 Deps.edn 기초
- 종속성 및 플러그인 관리
- 빌드, 테스트 및 배포
- 프로필, 별칭 및 환경 관리