Add build system

This commit adds support for generating POM files and builds of matchbot
as JAR or uberjar (standalone JAR) files.

Resolves issue LibreGaming/matchbot#3

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
This commit is contained in:
Sebastian Crane 2022-04-09 21:25:07 +01:00
parent 69e154ea87
commit bfd321cdb3
3 changed files with 81 additions and 2 deletions

77
build.clj Normal file
View File

@ -0,0 +1,77 @@
;; SPDX-License-Identifier: Apache-2.0
;; SPDX-FileCopyrightText: 2022 Sebastian Crane <seabass-labrax@gmx.com>
(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))

View File

@ -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}}}

View File

@ -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