Skip to content

Commit

Permalink
Revert "Build Clojars (#20)" (#21)
Browse files Browse the repository at this point in the history
This reverts commit 9be71f3.
  • Loading branch information
1e16miin authored Feb 14, 2025
1 parent 9be71f3 commit 68a2846
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 112 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ jobs:
key: cljdeps-${{ hashFiles('deps.edn') }}

- name: Execute tests
# run: clojure -T:build compile-java && clojure -X:dev:test
run: clojure -X:dev:test
run: clojure -T:build compile-java && clojure -X:dev:test
147 changes: 43 additions & 104 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,116 +17,55 @@
(ns build
(:require [clojure.string :as string]
[clojure.tools.build.api :as build]
[deps-deploy.deps-deploy :as dd]
#_[net.lewisship.build :as b]))
[net.lewisship.build :as b]))

;; (def lib 'org.clojars.greenlabs/lacinia)
;; (def version (-> "VERSION.txt" slurp string/trim))
;; (def class-dir "target/classes")

;; (def jar-params {:project-name lib
;; :version version
;; :class-dir class-dir})

;; (defn clean
;; [_params]
;; (build/delete {:path "target"}))

;; (defn compile-java [_]
;; (build/javac {:src-dirs ["java"]
;; :class-dir class-dir
;; :basis (build/create-basis)
;; :javac-opts ["--release" "11"]}))

;; (defn jar
;; [_params]
;; (compile-java nil)
;; (b/create-jar jar-params))

;; (defn deploy
;; [_params]
;; (clean nil)
;; (b/deploy-jar (jar nil)))

;; (defn codox
;; [_params]
;; (b/generate-codox {:project-name lib
;; :version version
;; :aliases [:dev]}))

;; (def publish-dir "../apidocs/lacinia")

;; (defn publish
;; "Generate Codox documentation and publish via a GitHub push."
;; [_params]
;; (println "Generating Codox documentation")
;; (codox nil)
;; (println "Copying documentation to" publish-dir "...")
;; (build/copy-dir {:target-dir publish-dir
;; :src-dirs ["target/doc"]})
;; (println "Committing changes ...")
;; (build/process {:dir publish-dir
;; :command-args ["git" "commit" "-a" "-m" (str "lacinia " version)]})
;; (println "Pushing changes ...")
;; (build/process {:dir publish-dir
;; :command-args ["git" "push"]}))

(def lib 'org.clojars.greenlabs/lacinia)
(def version (format "1.0.%s" (build/git-count-revs nil)))
(def lib 'com.walmartlabs/lacinia)
(def version (-> "VERSION.txt" slurp string/trim))
(def class-dir "target/classes")

(def ^:private basis
(delay (build/create-basis {})))

(defn- pom-template
[version]
[[:description "A fork of lacinia developed and maintained by Greenlabs "]
[:url "https://github.com/green-labs/lacinia"]
[:licenses
[:license
[:name "Apache License, Version 2.0"]
[:url "http://www.apache.org/licenses/LICENSE-2.0"]]]
[:scm
[:url "https://github.com/green-labs/lacinia"]
[:connection "scm:git:https://github.com/green-labs/lacinia.git"]
[:developerConnection "scm:git:ssh:[email protected]:green-labs/lacinia.git"]
[:tag (str "v" version)]]])

(defn- jar-opts
[opts]
(println "Version:" version)
(assoc opts
:lib lib :version version
:jar-file (format "target/%s-%s.jar" lib version)
:basis @basis
:class-dir class-dir
:target "target"
:src-dirs ["src"]
:pom-data (pom-template version)))
(def jar-params {:project-name lib
:version version
:class-dir class-dir})

(defn clean
[_]
(println "Removing target/ ...")
[_params]
(build/delete {:path "target"}))

(defn build-jar
[opts]
(let [j-opts (jar-opts opts)]
(println "Writing pom.xml ...")
(build/write-pom j-opts)
(println "Copying source ...")
(build/copy-dir {:src-dirs ["src"] :target-dir class-dir})
(println "Building" (:jar-file j-opts) "...")
(build/jar j-opts)))
(defn compile-java [_]
(build/javac {:src-dirs ["java"]
:class-dir class-dir
:basis (build/create-basis)
:javac-opts ["--release" "11"]}))

(defn jar
[_params]
(compile-java nil)
(b/create-jar jar-params))

(defn deploy
"Build the jar and deploy it to Clojars. Expects env vars CLOJARS_USERNAME &
CLOJARS_PASSWORD."
[opts]
(clean opts)
(build-jar opts)
(let [{:keys [jar-file] :as opts} (jar-opts opts)]
(dd/deploy {:installer :remote
:artifact (build/resolve-path jar-file)
:pom-file (build/pom-path (select-keys opts [:lib :class-dir]))}))
opts)
[_params]
(clean nil)
(b/deploy-jar (jar nil)))

(defn codox
[_params]
(b/generate-codox {:project-name lib
:version version
:aliases [:dev]}))

(def publish-dir "../apidocs/lacinia")

(defn publish
"Generate Codox documentation and publish via a GitHub push."
[_params]
(println "Generating Codox documentation")
(codox nil)
(println "Copying documentation to" publish-dir "...")
(build/copy-dir {:target-dir publish-dir
:src-dirs ["target/doc"]})
(println "Committing changes ...")
(build/process {:dir publish-dir
:command-args ["git" "commit" "-a" "-m" (str "lacinia " version)]})
(println "Pushing changes ...")
(build/process {:dir publish-dir
:command-args ["git" "push"]}))
9 changes: 3 additions & 6 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
org.clojure/data.json {:mvn/version "2.4.0"}}
:paths ["src" "resources" "target/classes"]

#_#_:deps/prep-lib
:deps/prep-lib
{:ensure "target/classes"
:alias :build
:fn compile-java}

:tools/usage
{:ns-default lacinia}

:aliases
{:dev
{:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
Expand Down Expand Up @@ -55,8 +52,8 @@
:main-opts ["-m" "cloverage.coverage" "-p" "src" "-s" "test" "--codecov"]}

;; clj -T:build <command>
:build {:deps {io.github.clojure/tools.build {:mvn/version "RELEASE"}
slipset/deps-deploy {:mvn/version "RELEASE"}}
:build {:deps {io.github.hlship/build-tools
{:git/tag "0.10.1" :git/sha "7ecff5"}}
:ns-default build}}

:net.lewisship.build/scm
Expand Down

0 comments on commit 68a2846

Please sign in to comment.