Skip to content

Commit

Permalink
fix cljdoc, remove org.corfield.build, rebuild uberjar task
Browse files Browse the repository at this point in the history
  • Loading branch information
garrett-hopper authored and dustingetz committed Aug 18, 2023
1 parent 2f6e711 commit 8a1edfa
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
node_modules
#src/**/*.js -- for tsc modules only, see https://github.com/hyperfiddle/photon/commit/0aa9b26c35d961151891c1e42ec13fcf52e38fa2
/target/
/pom.xml
tsconfig.tsbuildinfo
output.calva-repl

Expand Down
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

:build {:extra-paths ["src-build"]
:ns-default build
:extra-deps {io.github.clojure/tools.build {:git/tag "v0.8.2" :git/sha "ba1a2bf"}
io.github.seancorfield/build-clj {:git/tag "v0.8.0" :git/sha "9bd8b8a"}}}
:extra-deps {io.github.clojure/tools.build {:git/tag "v0.8.2" :git/sha "ba1a2bf"}
slipset/deps-deploy {:mvn/version "0.2.0"}}}
:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.22.10"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]
:jvm-opts ["-Xss2m"]}
Expand Down
23 changes: 23 additions & 0 deletions pom-template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>com.hyperfiddle</name>
<description>A reactive Clojure dialect for web development that uses a compiler to infer the frontend/backend boundary</description>
<url>https://github.com/hyperfiddle/electric</url>
<licenses>
<license>
<name>Eclipse Public License</name>
<url>http://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>
<developers>
<developer>
<name>Dustin Getz</name>
</developer>
</developers>
<scm>
<url>https://github.com/hyperfiddle/electric</url>
<connection>scm:git:git://github.com/hyperfiddle/electric.git</connection>
<developerConnection>scm:git:ssh://git@github.com/hyperfiddle/electric.git</developerConnection>
</scm>
</project>
56 changes: 40 additions & 16 deletions src-build/build.clj
Original file line number Diff line number Diff line change
@@ -1,44 +1,68 @@
(ns build
"build electric.jar library artifact"
(:require [clojure.tools.build.api :as b]
[org.corfield.build :as bb]
[clojure.java.shell :as sh]))
[clojure.java.shell :as sh]
[deps-deploy.deps-deploy :as dd]))

(def lib 'com.hyperfiddle/electric)
(def version (b/git-process {:git-args "describe --tags --long --always --dirty"}))
(def basis (b/create-basis {:project "deps.edn"}))

(def class-dir "target/classes")

(defn compile-java [_]
(b/javac {:src-dirs ["src"]
:class-dir "src"
:basis basis
:javac-opts ["-source" "8" "-target" "8"]}))

(def defaults {:src-pom "pom.xml" :lib lib})
(def defaults {:src-pom "pom-template.xml" :lib lib})

(defn clean-client [_] (b/delete {:path "resources/public/js"}))
(defn clean-server [_] (b/delete {:path "resources/private/electric/server_programs"}))

(defn clean [opts]
(clean-client opts)
(clean-server opts)
(bb/clean opts))

(defn jar [opts]
(bb/jar (merge defaults opts)))

(defn install [opts]
(bb/install (merge defaults opts)))
(b/delete {:path "target"}))

(defn jar [{:keys [version] :or {version version}}]
(let [jar-file (format "target/%s-%s.jar" (name lib) version)
opts (assoc defaults
:version version
:basis basis
:class-dir class-dir
:jar-file jar-file
:scm {:tag version}
:src-dirs ["src"])]
(println "Writing pom.xml")
(b/write-pom opts)
(println "Copying resources to" class-dir)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(println "Building jar" jar-file)
(b/jar opts)))

(defn install [{:keys [version] :or {version version}}]
(let [jar-file (format "target/%s-%s.jar" (name lib) version)]
(b/install {:basis basis
:lib lib
:version version
:jar-file jar-file
:class-dir class-dir})))

(defn deploy [opts]
(bb/deploy (merge defaults opts)))
(let [{:keys [lib version class-dir installer jar-file] :as opts} (merge defaults opts)]
(assert version ":version is required to deploy")
(when (and installer (not= :remote installer))
(println ":installer" installer "is deprecated -- use install task for local deployment"))
(let [jar-file (or jar-file (format "target/%s-%s.jar" (name (or lib 'application)) version))]
(dd/deploy (merge {:installer :remote :artifact (b/resolve-path jar-file)
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}
opts)))))

;; Uberjar

(def class-dir "target/classes")
(defn default-uberjar-name [{:keys [lib version] :or {version version}}]
(format "target/%s-%s-standalone.jar" "electric-demos" version))

(defn noop [_]) ; to preload mvn deps

(defn build-client [{:keys [optimize debug verbose version]
Expand Down Expand Up @@ -71,6 +95,6 @@

(println "Building uberjar")
(b/uber {:class-dir class-dir
:uber-file (str (or jar-name (default-uberjar-name {:version version})))
:uber-file (or jar-name (format "target/%s-%s-standalone.jar" "electric-demos" version))
:basis (b/create-basis {:project "deps.edn"
:aliases [:prod]})}))

0 comments on commit 8a1edfa

Please sign in to comment.