From bfd321cdb3487e6188b2ccdc6a1bbf4b7729c965 Mon Sep 17 00:00:00 2001 From: Sebastian Crane Date: Sat, 9 Apr 2022 21:25:07 +0100 Subject: [PATCH] Add build system This commit adds support for generating POM files and builds of matchbot as JAR or uberjar (standalone JAR) files. Resolves issue https://git.libregaming.org/LibreGaming/matchbot/issues/3 Signed-off-by: Sebastian Crane --- build.clj | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ deps.edn | 3 +- src/system.clj | 3 +- 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 build.clj diff --git a/build.clj b/build.clj new file mode 100644 index 0000000..1a2f9dd --- /dev/null +++ b/build.clj @@ -0,0 +1,77 @@ +;; SPDX-License-Identifier: Apache-2.0 +;; SPDX-FileCopyrightText: 2022 Sebastian Crane + +(ns build + (:require [clojure.tools.build.api :as b] + [tools-pom.tasks :as pom])) + +(def application 'org.libregaming/matchbot) +(def version "1.1.0-SNAPSHOT") +(def src-dirs ["src"]) +(def target-dir "target") +(def class-dir (format "%s/%s" target-dir "classes")) +(def basis (b/create-basis {:project "deps.edn"})) +(def pom-file (format "%s/pom.xml" target-dir)) +(def jar-file (format "%s/%s-%s.jar" target-dir (name application) version)) +(def uber-file (format "%s/%s-%s-standalone.jar" target-dir (name application) version)) + +(defn clean [_] + (b/delete {:path target-dir})) + +(defn uber [_] + (b/delete {:path class-dir}) + (b/copy-dir {:src-dirs src-dirs + :target-dir class-dir}) + (b/compile-clj {:basis basis + :src-dirs src-dirs + :class-dir class-dir}) + (b/uber {:class-dir class-dir + :uber-file uber-file + :basis basis + :main 'system})) + +(defn jar [_] + (b/delete {:path class-dir}) + (b/copy-dir {:src-dirs src-dirs + :target-dir class-dir}) + (b/jar {:class-dir class-dir + :jar-file jar-file})) + +(defn pom [_] + (pom/pom + {:lib application + :version version + :write-pom true + :validate-pom true + :pom + {:description + "A chatbot for announcing upcoming matches and finding fellow players, written for the LibreGaming community" + :url + "https://git.libregaming.org/LibreGaming/matchbot" + :licenses + [:license + {:name "Apache-2.0" + :url "https://www.apache.org/licenses/LICENSE-2.0.html"}] + :developers + [:developer + {:id "seabass" + :name "Sebastian Crane" + :email "seabass-labrax@gmx.com" + :organization "LibreGaming" + :organization-url "https://libregaming.org" + :roles [:role "Maintainer"] + :timezone "Europe/London"}] + :scm + {:url "https://git.libregaming.org/LibreGaming/matchbot" + :connection "scm:git:https://git.libregaming.org/LibreGaming/matchbot.git" + :developer-connection "scm:git:ssh://git@git.libregaming.org/LibreGaming/matchbot.git"} + :issue-management + {:system "Gitea" + :url "https://git.libregaming.org/LibreGaming/matchbot/issues"}}}) + (b/copy-file {:src "pom.xml" :target pom-file}) + (b/delete {:path "pom.xml"})) + +(defn all [_] + (jar nil) + (uber nil) + (pom nil)) diff --git a/deps.edn b/deps.edn index c3d279e..db158dc 100644 --- a/deps.edn +++ b/deps.edn @@ -9,4 +9,5 @@ :extra-deps {lambdaisland/kaocha {:mvn/version "1.60.972"}} :main-opts ["-m" "kaocha.runner"]} :build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.1" :git/sha "7d40500"} - com.github.pmonks/tools-pom {:mvn/version "1.0.74"}}}}} + com.github.pmonks/tools-pom {:mvn/version "1.0.74"}} + :ns-default build}}} diff --git a/src/system.clj b/src/system.clj index dc18b15..c2fa5b4 100644 --- a/src/system.clj +++ b/src/system.clj @@ -5,7 +5,8 @@ (:require [irc] [clojure.data.json :as json] [clojure.set :as set] - [clj-yaml.core :as yaml])) + [clj-yaml.core :as yaml]) + (:gen-class)) (defn setify-vals [x] (reduce #(assoc %1