Skip to content

Commit

Permalink
Switch to using build.tools
Browse files Browse the repository at this point in the history
  • Loading branch information
wardle committed Jan 24, 2022
1 parent eb953eb commit c27c7db
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 27 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ clj -M:run install --db dmd-2021-07-01.db ~/Downloads/dmd-2021-07-01
```
or
```shell
java -jar dmd.jar --db dmd-2021-07-01.db ~/Downloads/dmd-2021-07-01
java -jar dmd-server-0.6.139.jar --db dmd-2021-07-01.db ~/Downloads/dmd-2021-07-01
```

This will look for files in the directory specified and create a new file-based
Expand All @@ -90,7 +90,7 @@ clj -M:run latest --api-key /var/local/trud/api-key.txt --cache-dir /var/local/t
```
or
```shell
java -jar dmd.jar latest --api-key /var/local/trud/api-key.txt --cache-dir /var/local/trud/cache
java -jar dmd-server-0.6.139.jar latest --api-key /var/local/trud/api-key.txt --cache-dir /var/local/trud/cache
```

This will create a file-based database named dmd-2021-04-12.db (or whatever release date is appropriate).
Expand All @@ -101,7 +101,7 @@ clj -M:run latest --api-key /var/local/trud/api-key.txt --cache-dir /var/local/t
```
or
```shell
java -jar dmd.jar latest --api-key /var/local/trud/api-key.txt --cache-dir /var/local/trud/cache --db dmd.db
java -jar dmd-server-0.6.139.jar latest --api-key /var/local/trud/api-key.txt --cache-dir /var/local/trud/cache --db dmd.db
```

Note: this does not support updating an existing datafile. It is much better
Expand All @@ -117,7 +117,7 @@ clj -M:run list --api-key /var/local/trud/api-key.txt
```
or
```shell
java -jar dmd.jar list --api-key /var/local/trud/api-key.txt
java -jar dmd-server-0.6.139.jar list --api-key /var/local/trud/api-key.txt
```


Expand Down Expand Up @@ -156,7 +156,7 @@ clj -M:run serve --db dmd-2021-04-12.db --port 8080
```
or
```shell
java -jar dmd.jar --db dmd-2021-04-12.db --port 8080
java -jar dmd-server-0.6.139.jar --db dmd-2021-04-12.db --port 8080
```

As it is very likely that the complete dm+d dataset will fit into the memory
Expand Down Expand Up @@ -697,12 +697,12 @@ clj -M:lint/kondo
#### Build library jar

```shell
clj -X:jar
clj -T:build jar
```

#### Build and run an uberjar

```shell
clj -X:uberjar
java -jar target/dmd.jar --help
clj -T:build jar
java -jar target/dmd-server-0.6.139.jar --help
```
69 changes: 69 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(ns build
(:require [clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))

(def lib 'com.eldrix/dmd)
(def version (format "0.6.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def jar-basis (b/create-basis {:project "deps.edn"}))
(def uber-basis (b/create-basis {:project "deps.edn"
:aliases [:run]}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def uber-file (format "target/%s-server-%s.jar" (name lib) version))

(defn clean [_]
(b/delete {:path "target"}))

(defn jar [_]
(clean nil)
(println "Building" lib version)
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis jar-basis
:src-dirs ["src"]
:scm {:url "https://github.com/wardle/dmd"
:tag (str "v" version)
:connection "scm:git:git://github.com/wardle/dmd.git"
:developerConnection "scm:git:ssh://[email protected]/wardle/dmd.git"}})
(b/copy-dir {:src-dirs ["src"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))

(defn install
"Installs pom and library jar in local maven repository"
[_]
(jar nil)
(println "Installing" lib version)
(b/install {:basis jar-basis
:lib lib
:class-dir class-dir
:version version
:jar-file jar-file}))


(defn deploy
"Deploy library to clojars.
Environment variables CLOJARS_USERNAME and CLOJARS_PASSWORD must be set."
[_]
(clean nil)
(jar nil)
(dd/deploy {:installer :remote
:artifact jar-file
:pom-file (b/pom-path {:lib lib
:class-dir class-dir})}))
(defn uber
"Build an executable uberjar file for hermes HTTP server"
[_]
(clean nil)
(b/copy-dir {:src-dirs ["src" "cmd" "resources"]
:target-dir class-dir})
(b/compile-clj {:basis uber-basis
:src-dirs ["src" "cmd"]
:ns-compile ['com.eldrix.dmd.cli]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis uber-basis
:main 'com.eldrix.dmd.cli}))
29 changes: 10 additions & 19 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
org.clojure/data.zip {:mvn/version "1.0.0"}
org.clojure/tools.logging {:mvn/version "1.1.0"}

com.eldrix/trud {:git/url "https://github.com/wardle/trud.git"
:sha "c73e7dcb4f7420b5e22e528f74c58d884bd6907e"}
com.wsscode/pathom {:git/url "https://github.com/wilkerlucio/pathom3"
:sha "1aec64d88ef915c9525ae54feffa60f3850faa96"}
com.eldrix/trud {:mvn/version "1.0.75"}

com.wsscode/pathom3 {:mvn/version "2021.07.10-1-alpha"}
datalevin/datalevin {:mvn/version "0.5.22"}}

:aliases {:dev
:aliases {:build
{:deps {io.github.clojure/tools.build {:git/tag "v0.7.5" :git/sha "34727f7"}
slipset/deps-deploy {:mvn/version "RELEASE"}}
:ns-default build}

:dev
{:extra-paths ["cmd" "test/src" "test/resources"]}

:run
Expand Down Expand Up @@ -74,17 +78,4 @@

:lint/eastwood
{:main-opts ["-m" "eastwood.lint" {:source-paths ["src"]}]
:extra-deps {jonase/eastwood {:mvn/version "RELEASE"}}}

:jar
{:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
:exec-fn hf.depstar/jar
:exec-args {:jar "target/dmd-lib.jar"}}

:uberjar
{:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
:exec-fn hf.depstar/uberjar
:exec-args {:jar "target/dmd.jar"
:aot true
:aliases [:run]
:main-class "com.eldrix.dmd.cli"}}}}
:extra-deps {jonase/eastwood {:mvn/version "RELEASE"}}}}}

0 comments on commit c27c7db

Please sign in to comment.