From c2776ab72cd556546a84d7e9de87b80ad5525613 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 16:39:23 +0300 Subject: [PATCH 1/8] Add build script --- .gitignore | 3 ++- build.clj | 52 ++++++++++++++++++++++++++++++++++++++++++++ deps.edn | 3 +++ script/build/uberjar | 3 +++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 build.clj create mode 100755 script/build/uberjar diff --git a/.gitignore b/.gitignore index f300754a..40609fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ db-test/ convex-db convex-web.sublime-workspace .clj-kondo -*.pfx \ No newline at end of file +*.pfx +build/** \ No newline at end of file diff --git a/build.clj b/build.clj new file mode 100644 index 00000000..5157afba --- /dev/null +++ b/build.clj @@ -0,0 +1,52 @@ +(ns build + (:require + [clojure.tools.build.api :as b])) + +;; More info see https://clojure.org/guides/tools_build + +;; Project settings + +(def lib 'convex/convex-web) +(def main-class 'convex-web.core) +(def src-dirs ["src/main/clojure"]) +(def resource-dirs ["src/main/resources"]) + +;; General settings + +(def version (format "0.1.%s" (b/git-count-revs nil))) + +(def build-path "build") +(def class-dir (str build-path "/classes")) + +(def basis (b/create-basis {:project "deps.edn"})) +(def dirs-to-copy (concat src-dirs resource-dirs)) + + +(defn clean [_] + (b/delete {:path build-path})) + + +(def uber-file (format "%s-%s-standalone.jar" (name lib) version)) +(def uber-full-path (str build-path "/" uber-file)) +(def build-uberjar-name-file (str build-path "/" "UBERJAR_FILENAME")) + +(defn uberjar [{:as opts}] + (clean nil) + (b/write-pom {:class-dir class-dir + :lib lib + :version version + :basis basis + :src-dirs src-dirs}) + (b/copy-dir {:src-dirs dirs-to-copy + :target-dir class-dir}) + ;; Compile not necesary, we can skip this + (b/compile-clj {:basis basis + :src-dirs src-dirs + :class-dir class-dir + :java-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory"]}) + (b/uber {:class-dir class-dir + :uber-file uber-full-path + :basis basis + :main main-class}) + ;; Write filename to specific file for CI + (spit build-uberjar-name-file uber-file)) \ No newline at end of file diff --git a/deps.edn b/deps.edn index de37a617..abdd7e30 100644 --- a/deps.edn +++ b/deps.edn @@ -147,6 +147,9 @@ :logback-prod {:jvm-opts ["-Dlogback.configurationFile=logback/logback-prod.xml"]} + ;; -- Build configuration + :build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.2" :git/sha "ba1a2bf"}} + :ns-default build} ;; -- Check outdated dependencies ;; clj -M:outdated diff --git a/script/build/uberjar b/script/build/uberjar new file mode 100755 index 00000000..3ea8d40e --- /dev/null +++ b/script/build/uberjar @@ -0,0 +1,3 @@ +#!/bin/sh -x + +clj -T:build uberjar \ No newline at end of file From 01ba57d280d8820bde3c9172c2dbe2699c337681 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 16:39:40 +0300 Subject: [PATCH 2/8] Add CI release script --- .circleci/config.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++ script/ci/release | 5 ++++ 2 files changed, 60 insertions(+) create mode 100644 .circleci/config.yml create mode 100755 script/ci/release diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..72369805 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,55 @@ +# Clojure CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-clojure/ for more details +# +version: 2.1 + +jobs: + deploy: + docker: + - image: cimg/clojure:1.11.1 + working_directory: ~/repo + # resource_class: large + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "deps.edn" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + # - run: + # name: Run JVM tests + # command: | + # script/test + # script/run_lib_tests + - run: + name: Create uberjar + command: | + script/build/uberjar + RELEASE=/tmp/release + script/ci/release + - store_artifacts: + path: /tmp/release + destination: release + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "deps.edn" }} + + +workflows: + version: 2 + ci: + jobs: + # - short-if-irrelevant + # - jvm: + # requires: + # - short-if-irrelevant + - deploy: + # filters: + # branches: + # only: master + # requires: + # - jvm + diff --git a/script/ci/release b/script/ci/release new file mode 100755 index 00000000..98e4e357 --- /dev/null +++ b/script/ci/release @@ -0,0 +1,5 @@ +#!/bin/sh -x + +UBERJAR_FILENAME=$(cat build/UBERJAR_FILENAME) +cp build/${UBERJAR_FILENAME} $RELEASE +java -cp "$RELEASE" clojure.main -e '(println "OK")' From e4757ae6ac270bda3c2cdbf18c16b3e1e870d151 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 15:42:52 +0200 Subject: [PATCH 3/8] Updated config.yml --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 72369805..030129fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,10 +46,10 @@ workflows: # - jvm: # requires: # - short-if-irrelevant - - deploy: - # filters: - # branches: - # only: master - # requires: - # - jvm + - deploy + # filters: + # branches: + # only: master + # requires: + # - jvm From 46ec615aade8a87d245b758bf208010cbba241b0 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 16:44:32 +0300 Subject: [PATCH 4/8] Use clojure instead of clj --- script/build/uberjar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/build/uberjar b/script/build/uberjar index 3ea8d40e..d8d7ec51 100755 --- a/script/build/uberjar +++ b/script/build/uberjar @@ -1,3 +1,3 @@ #!/bin/sh -x -clj -T:build uberjar \ No newline at end of file +clojure -T:build uberjar \ No newline at end of file From f23e0468d2cba2fa13bd2fc061b6f83ba51f9724 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 16:51:31 +0300 Subject: [PATCH 5/8] Make env variable available to script --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 030129fc..19fa1af8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,9 +26,8 @@ jobs: - run: name: Create uberjar command: | - script/build/uberjar - RELEASE=/tmp/release - script/ci/release + script/build/uberjar + RELEASE=/tmp/release script/ci/release - store_artifacts: path: /tmp/release destination: release From 86ddd261b69d1079af85b870513296a3da9eee17 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 16:55:35 +0300 Subject: [PATCH 6/8] CI Config wip --- .circleci/config.yml | 7 ++++--- script/ci/release | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 19fa1af8..2e447c50 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,11 +26,12 @@ jobs: - run: name: Create uberjar command: | - script/build/uberjar - RELEASE=/tmp/release script/ci/release + script/build/uberjar + mkdir -p /tmp/release + DIR=/tmp/release script/ci/release - store_artifacts: path: /tmp/release - destination: release + destination: release.jar - save_cache: paths: - ~/.m2 diff --git a/script/ci/release b/script/ci/release index 98e4e357..751eb621 100755 --- a/script/ci/release +++ b/script/ci/release @@ -1,5 +1,6 @@ #!/bin/sh -x UBERJAR_FILENAME=$(cat build/UBERJAR_FILENAME) +RELEASE="$DIR/$UBERJAR_FILENAME" cp build/${UBERJAR_FILENAME} $RELEASE java -cp "$RELEASE" clojure.main -e '(println "OK")' From 3324b5b1627c3e68db03e84577fea166fb529122 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 16:56:59 +0300 Subject: [PATCH 7/8] Remove extension --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2e447c50..0baf3a8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,7 +31,7 @@ jobs: DIR=/tmp/release script/ci/release - store_artifacts: path: /tmp/release - destination: release.jar + destination: release - save_cache: paths: - ~/.m2 From dfea6e3d5944678b392db782f94cd42488d940c1 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Sun, 12 Jun 2022 17:09:39 +0300 Subject: [PATCH 8/8] Add :gen-class --- src/main/clojure/convex_web/core.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/clojure/convex_web/core.clj b/src/main/clojure/convex_web/core.clj index d2de0a63..ae0a384e 100644 --- a/src/main/clojure/convex_web/core.clj +++ b/src/main/clojure/convex_web/core.clj @@ -4,7 +4,8 @@ [clojure.tools.logging :as log]) (:import - (convex.core.util Shutdown))) + (convex.core.util Shutdown)) + (:gen-class)) (def system nil)