2024 Clojure状态调查中分享您的想法!

欢迎!请查看关于页面以了解更多关于这个工作的信息。

0
tools.build
已关闭

这对于决定是否发布SNAPSHOT版本非常有用。

以下是任何人现在都可以用于其项目的可行实现

(ns build
  (:require [clojure.string :as str]
            [clojure.tools.build.api :as b]
            [clojure.tools.build.api.specs :as specs]))

(defn git-branch
  "Shells out to git and returns the current branch
    git branch --show-current
  Options:
    :dir - dir to invoke this command from, by default current directory"
  [{:keys [dir] :or {dir "."} :as params}]
  (@#'b/assert-specs "git-branch" params :dir ::specs/path)
  (-> {:command-args ["git" "branch" "--show-current"]
       :dir (.getPath (b/resolve-path dir))
       :out :capture}
    b/process
    :out
    str/trim))

(def lib 'my-group/my-lib)

(def version
  (if (= "master" (git-branch nil))
    (format "1.0.%s" (b/git-count-revs nil))
    (format "1.0.%s-SNAPSHOT" (b/git-count-revs nil))))
已关闭,备注: 从v0.6.5版本开始使用git-process:(api/git-process {:git-args "branch --show-current"})

1 答案

+1

选定
...