工欲善其事,必先利其器之—MAC下搭建clojure的開發環境

羅兄發表於2018-06-29

前置環境

安裝JDK

安裝clojure sdk

嘗試使用homebew來安裝clojure SDK

brew install clojure
luogw@luogw-MacBook-Pro notes$ brew install clojure
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
docfx

==> Downloading https://download.clojure.org/install/clojure-tools-1.9.0.381.tar.gz

curl: (35) Server aborted the SSL handshake
Error: Failed to download resource "clojure"
Download failed: https://download.clojure.org/install/clojure-tools-1.9.0.381.tar.gz

網路有問題,安裝失敗,那就下載原始碼並編譯吧
如下是網官的指引

git clone https://github.com/clojure/clojure.git
cd clojure
./antsetup.sh
# 編譯clojure SDK
ant local

clone原始碼後,執行antsetup.sh遇到如下問題(程式碼cloen的目錄在/Users/luogw/dev_tool/clojure)

luogw@luogw-MacBook-Pro clojure$ ./antsetup.sh
./antsetup.sh: line 3: mvn: command not found
cat: maven-classpath: No such file or directory
cat: maven-classpath: No such file or directory
Wrote maven-classpath.properties for standalone ant use

出錯提示沒有安裝mvn
安裝mvn還有ant(注:後面編譯clojure時需要ant的!)

 brew install maven
 brew install ant

編譯成功後,目錄下有clojure.jar
在.bash_profile裡新增如下配置

# for clojure
alias start_clojure='java -jar /Users/luogw/dev_tool/clojure/clojure.jar'

命令列的開發環境

進入clojure 的REPL互動模式(執行前面新增的start_clojure命令 ),直接寫clojure指令碼

luogw@luogw-MacBook-Pro temp$ source  ~/.bash_profile
luogw@luogw-MacBook-Pro temp$ start_clojure
Clojure 1.10.0-master-SNAPSHOT
user=> println "hello, clojure"
#object[clojure.core$println 0x2ef14fe "clojure.core$println@2ef14fe"]
"hello, clojure"
user=>

IDE下的開發環境

IDEA的開發環境

TODO

外掛安裝

建立工程

編碼執行

互動式RELP模式

線上的編譯執行環境

https://repl.it/repls/BlueBountifulOpposites

參考資料

相關文章