Skip to content

juxt/pack.alpha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pack (alpha)

Package up Clojure projects in various ways, based on a deps.edn file.

Want to have a chat before opening a ticket? Need help or support from the community? Find us in the Clojurians Zulipchat #JUXT stream.

Usage

With tools.build

Pack provides the namespace juxt.pack.api which works well alongside tools.build. Find reference documentation on the vars.

When using tools.build in a monorepo with multiple projects, it can be useful to leverage clojure.tools.build.api/with-project-root to specify the directory containing the deps.edn file for a particular project. Pack supports with-project-root by taking advantage of the included tools.deps library. Simply wrap all Pack calls with clojure.tools.deps.util.dir/with-dir and pass the tools.build project root as the first argument.

(ns build
  (:require [clojure.java.io :as jio]
            [clojure.tools.build.api :as b]
            [clojure.tools.deps.util.dir :as t]
            [juxt.pack.api :as pack]))

(defn pack
 [_]
 (b/with-project-root "path/to/project/root"
  (t/with-dir (jio/file b/*project-root*)
    (pack/...))))

Note that the project root is passed as a Java file via clojure.java.io/file.

As a tool

Pack also works standalone as a tool you can invoke with deps.edn. Add this alias to your project:

;; add this to :aliases:
:pack {:deps {io.github.juxt/pack.alpha {:git/sha "843475881c5b3ba1a2c9f102f6f5f86f3293a574"}}
       :ns-default juxt.pack.cli.api}

Then you can invoke it with clj -T:pack. To see usage information, use clojure -A:deps -T:pack help/dir

Features

Pack provides fast, conflict-less, ways to package Clojure programs. It provides:

  • Docker images

  • AWS Lambda deployment package

  • Self-executable jars (Using One-JAR)

  • "Skinny" jars (Jars which do not contain their dependencies)

  • Library jars

What does conflict-less mean?

Pack will always package your application so you don’t need to worry about multiple copies of the same file on the classpath. Pack preserves the classpath for all of it’s output formats.

Uberjars require that files on the classpath are uniquely named. To do this, they have to resolve conflicts between files with the same name. For example, if you two dependencies com.example/A and com.example/B, and both contain the file "data_readers.clj" in them, what do you do? Often configuration is needed to get this right, as many libraries aren’t supported out of the box. Some tools will even ignore copyright restrictions that require you to keep them in your final jar as a convenience.

Examples

PR your project here!

Guides

PR your guide here!