Skip to content

Commit

Permalink
wip - attempt to fix cljdoc build
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Sep 5, 2024
1 parent da30cb3 commit 9948fc0
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 23 deletions.
9 changes: 5 additions & 4 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
:test {:extra-paths ["test"]
:exec-fn cognitect.test-runner.api/test
:jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true" "-XX:-OmitStackTraceInFastThrow"] ;; https://archive.md/NNt9r
:extra-deps {org.clojure/core.async {:mvn/version "1.6.681"} ; for interop helpers only
:extra-deps {org.clojure/core.async {:mvn/version "1.6.681", :hyperfiddle.electric.cljdoc/include? true} ; for interop helpers only
ch.qos.logback/logback-classic {:mvn/version "1.4.14"}
io.github.cognitect-labs/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git" :sha "cc75980b43011773162b485f46f939dc5fba91e4"}
org.clojure/test.check {:mvn/version "1.1.1"}
com.datomic/local {:mvn/version "1.0.285"} ; for hyperfiddle.transaction-test
com.datomic/client-cloud {:mvn/version "1.0.130"} ; for hyperfiddle.transaction-test
com.datomic/local {:mvn/version "1.0.285", :hyperfiddle.electric.cljdoc/include? true} ; for hyperfiddle.transaction-test
com.datomic/client-cloud {:mvn/version "1.0.130", :hyperfiddle.electric.cljdoc/include? true} ; for hyperfiddle.transaction-test
thheller/shadow-cljs {:mvn/version "2.26.2"} ; for hooks tests
ring/ring-core {:mvn/version "1.11.0"}
ring/ring-core {:mvn/version "1.11.0", :hyperfiddle.electric.cljdoc/include? true}
http-kit/http-kit {:mvn/version "2.5.1", :hyperfiddle.electric.cljdoc/include? true}
}}
:build {:extra-paths ["src-build"]
:ns-default build
Expand Down
1 change: 1 addition & 0 deletions docs/cljdoc.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:cljdoc/languages ["clj"]}
45 changes: 42 additions & 3 deletions src-build/build.clj
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
(ns build
"build electric.jar library artifact"
(:require [clojure.tools.build.api :as b]
(:require [clojure.data.xml :as xml]
[clojure.tools.build.api :as b]
[clojure.tools.build.tasks.write-pom :as wp]
[clojure.tools.deps.util.maven :as maven]
[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"}))

(defn alias-deps [basis alias] (get-in basis [:aliases alias :extra-deps]))

(defn extend-basis [basis deps]
(b/create-basis (update (:basis-config basis) :extra merge {:deps deps})))

(defn cljdoc-deps [deps]
(into {} (filter (fn [[_k v]] (contains? v :hyperfiddle.electric.cljdoc/include?)) deps)))

(def basis-with-cljdoc-provided-deps (->> (alias-deps basis :test) cljdoc-deps (extend-basis basis)))

(def class-dir "target/classes")

(def defaults {:src-pom "src-build/pom-template.xml" :lib lib :class-dir class-dir})

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

(xml/alias-uri 'pom "http://maven.apache.org/POM/4.0.0")

(let [original @#'wp/to-dep]
(defn to-dep [[lib {:keys [hyperfiddle.electric.cljdoc/include?] :as coord}]]
(cond-> (original [lib coord])
include? (conj [::pom/scope "provided"]))))

(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
:basis basis-with-cljdoc-provided-deps
:class-dir class-dir
:jar-file jar-file
:scm {:tag version}
:src-dirs ["src"])]
(println "Writing pom.xml")
(b/write-pom opts)
(with-redefs [wp/to-dep to-dep]
(b/write-pom opts))
(println "Copying resources to" class-dir)
(b/copy-dir {:src-dirs ["src"], :target-dir class-dir})
(println "Building jar" jar-file)
Expand Down Expand Up @@ -54,3 +75,21 @@
:class-dir "src"
:basis basis
:javac-opts ["-source" "8" "-target" "8"]}))


;; To run cljdoc analysis locally:
;; 1 - build jar
;; 2 - instal
;; 3 - run next to deps.edn:
;; mkdir -p .cljdoc-preview
;; docker run --rm \
;; --volume $(pwd) \
;; --volume "$HOME/.m2:/root/.m2" \
;; --volume ./.cljdoc-preview \
;; --platform linux/amd64 \
;; --entrypoint clojure \
;; cljdoc/cljdoc -Sforce -M:cli ingest \
;; --project com.hyperfiddle/electric \
;; --version $HYPERFIDDLE_ELECTRIC_BUILD
;; --git . \
;; --rev $(git rev-parse HEAD)
4 changes: 2 additions & 2 deletions src/contrib/datomic_contrib.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns contrib.datomic-contrib
(ns ^:no-doc contrib.datomic-contrib
(:require [contrib.data :refer [index-by unqualify]]
[contrib.datomic-m :as d]
[hyperfiddle.electric :as e] ; ?
Expand Down Expand Up @@ -224,4 +224,4 @@
{20512488927800905 #:db{:id 20512488927800905},
68459991991856131 #:db{:id 68459991991856131}}
nil]
nil)
nil)
2 changes: 1 addition & 1 deletion src/contrib/datomic_contrib_2020.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns contrib.datomic-contrib-2020
(ns ^:no-doc contrib.datomic-contrib-2020
(:require [contrib.datomic-contrib :refer [identify]]
clojure.set
[contrib.data :refer [update-existing]]
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/datomic_m.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns contrib.datomic-m
(ns ^:no-doc contrib.datomic-m
"datomic compatibility facade"
(:require contrib.deptector
[clojure.tools.logging :as log]
Expand Down
4 changes: 2 additions & 2 deletions src/contrib/datomic_peer_m.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns contrib.datomic-peer-m
(ns ^:no-doc contrib.datomic-peer-m
(:import (datomic.db Datum))
(:require [clojure.core.protocols :as ccp :refer [nav]]
[clojure.datafy :refer [datafy]]
Expand Down Expand Up @@ -171,4 +171,4 @@

(defn history [db] (m/sp (d/history db)))

(defn squuid [] (d/squuid))
(defn squuid [] (d/squuid))
2 changes: 1 addition & 1 deletion src/contrib/electric_codemirror.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns contrib.electric-codemirror
(ns ^:no-doc contrib.electric-codemirror
;; #?(:cljs (:require-macros contrib.electric-codemirror))
(:require
[clojure.edn :as edn]
Expand Down
4 changes: 2 additions & 2 deletions src/contrib/test/datomic_peer_mbrainz.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns contrib.test.datomic-peer-mbrainz
(ns ^:no-doc contrib.test.datomic-peer-mbrainz
"Don't use for inline tests, this has external database connection dependency
not in-mem"
(:require #_[contrib.datomic-contrib :as dx] ; no cycle
Expand Down Expand Up @@ -47,4 +47,4 @@ not in-mem"
:label/type #:db{:id 17592186045475},
:label/country #:db{:id 17592186045691},
:label/startYear 1972}
nil)
nil)
2 changes: 1 addition & 1 deletion src/hyperfiddle/api.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hyperfiddle.api
(ns ^:no-doc hyperfiddle.api
(:import [hyperfiddle.electric Pending]
#?(:cljs [goog.math Long]))
(:require clojure.edn
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfiddle/electric/shadow_cljs/hooks3.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hyperfiddle.electric.shadow-cljs.hooks3
(ns ^:no-doc hyperfiddle.electric.shadow-cljs.hooks3
(:require [shadow.build.compiler]
[hyperfiddle.electric.impl.lang3 :as lang]
[hyperfiddle.electric.impl.cljs-analyzer2 :as cljs-ana]))
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfiddle/electric_fulcro_dom_adapter.cljc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;; TODO Port to v3 if needed
(ns hyperfiddle.electric-fulcro-dom-adapter
(ns ^:no-doc hyperfiddle.electric-fulcro-dom-adapter
(:require [hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2]
#?(:cljs [goog.object :as gobj])
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfiddle/popover.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hyperfiddle.popover
(ns ^:no-doc hyperfiddle.popover
#?(:cljs (:require-macros hyperfiddle.popover))
(:import [hyperfiddle.electric Pending])
(:require [hyperfiddle.api :as hf]
Expand Down
2 changes: 1 addition & 1 deletion src/hyperfiddle/spool.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hyperfiddle.spool
(ns ^:no-doc hyperfiddle.spool
#?(:cljs (:require-macros hyperfiddle.spool))
(:require [hyperfiddle.electric :as e]
[hyperfiddle.incseq :as i]
Expand Down
4 changes: 2 additions & 2 deletions src/hyperfiddle/txn.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hyperfiddle.txn
(ns ^:no-doc hyperfiddle.txn
(:require [contrib.datomic-contrib-2020 :as dx]
[clojure.set :as set]
[hyperfiddle.api :as hf]
Expand Down Expand Up @@ -787,4 +787,4 @@
[[:db/retractEntity 4]])
:= [[:db/retractEntity 4]])

(defn minimal-tx [db tx] tx)
(defn minimal-tx [db tx] tx)

0 comments on commit 9948fc0

Please sign in to comment.