Liking cljdoc? Tell your friends :D

deps.clj

CircleCI Build status Clojars Project

A port of the clojure bash script to Clojure.

Rationale

If your clojure installation works well for you, then you don't need this. This repo can be seen as a proof of concept of what is possible with GraalVM and Clojure. Windows users might find the deps.exe executable of value if they have trouble getting their system up and running. This repo might also be a place to experiment with features that are not available in the original clojure command.

Arguably Bash and Powershell are less attractive languages for Clojure developers than Clojure itself. This repo provides the clojure bash script as a port in Clojure. It can be used as a JVM Clojure script (deps.clj), uberjar or library.

To get better startup, comparable to the original bash version, this project can be run as a binary called deps.exe or as a script called deps.clj with babashka.

Status

Experimental, breaking changes will happen. Feedback is welcome.

Installation

The deps.clj script can simply be downloaded from this repo. If you want a binary or uberjar, go to releases.

You don't need clojure to run this project, but you will need a clojure-tools jar. The clojure-tools jar is normally downloaded by the clojure installer itself (gz, zip). The deps.clj tool will try to resolve the jar in the directory $HOME/.deps.clj/ClojureTools. If it cannot it find it there, it will try to download it. You can override the location of the jar with the CLOJURE_TOOLS_CP environment variable.

Usage

Script

$ ./deps.clj -Spath -Sdeps '...'

Linux / Mac

$ ./deps.exe -Spath -Sdeps '...'

Windows

An example of how to set CLOJURE_TOOLS_CP on Windows and how to pass an -Sdeps value. Note the double double quotes.

C:\Users\borkdude\Downloads>set CLOJURE_TOOLS_CP=c:\Users\borkdude\Downloads\clojure-tools-1.10.1.492\ClojureTools\clojure-tools-1.10.1.492.jar

C:\Users\borkdude\Downloads>deps -Spath -Sdeps "{:deps {borkdude/deps.clj {:mvn/version ""0.0.1""}}}"

Non-standard options

The deps.clj script adds the following non-standard options:

 -Sdeps-file    Use this file instead of deps.edn
 -Scommand      A custom command that will be invoked. Substitutions: {{classpath}}, {{main-opts}}.

Example usage

Given this script-deps.edn file:

{:paths ["scripts"]
 :aliases
 {:main
  {:main-opts ["-m" "scripts.main"]}}}

and scripts/main.cljc:

(ns scripts.main)

(defn -main [& _args]
  (println "Hello from script!"))

you can invoke deps.clj as follows to invoke babashka:

$ deps.clj -Sdeps-file script-deps.edn -A:main -Scommand "bb -cp {{classpath}} {{main-opts}}"
Hello from script!

This can also be used with planck:

$ deps.clj -Sdeps-file script-deps.edn -A:main -Scommand "planck --classpath {{classpath}} {{main-opts}}"
Hello from script!

License

Copyright © 2019 Michiel Borkent

Distributed under the EPL License. See LICENSE.

This project is based on code from clojure/brew-install which is licensed under the same EPL License.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close