Skip to content
/ metabill Public

A minimal library to read build timestamp from JAR/WAR manifests.

Notifications You must be signed in to change notification settings

xcoo/metabill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metabill

Clojars Project

Clojars Project

A tiny library to handle the build meta information.

Prepare

Put jp.xcoo/metabill into the dependencies and jp.xcoo/lein-metabill into the plugins of your leiningen's project.clj. And run lein metabill before building for production, then it automatically generates resources/metabill.edn, which has some build metadata.

The default configuration of leiningen includes the resources directory as the classpath, so you don't need to do more. Note that if you have modified resource-paths, you need to add metabill.edn to the classpath.

Usage

Avoid browser's caching

You can prevent browsers from caching old JS and CSS files using with-build-time:

(ns hello-world.view
  (:require [hiccup.page :refer [html5 include-css include-js]]
            [metabill.core :refer [with-build-time]]))

(defn frame
  [req]
  (html5
   [:head
    [:title "Hello World!"]
    [:meta {:charset "utf-8"}]
    (include-css (with-build-time "/css/main.css"))]
   [:body
    [:div#app]
    (include-js (with-build-time "/js/main.js"))]))

network

You can also use commit hash:

(ns hello-world.view
  (:require [hiccup.page :refer [html5 include-css include-js]]
            [metabill.core :refer [with-build-commit-hash]]))

(defn frame
  [req]
  (html5
   [:head
    [:title "Hello World!"]
    [:meta {:charset "utf-8"}]
    (include-css (with-build-commit-hash "/css/main.css"))]
   [:body
    [:div#app]
    (include-js (with-build-commit-hash "/js/main.js"))]))

Embed meta information of the build

If you want to handle only the build metadata, you can use it as follows:

(ns hello-world.core
  (:require [metabill.core :refer [get-build-time get-build-commit-hash]]))

(defn print-build-info
  []
  (println "This system is built on" (get-build-commit-hash) "commit at" (get-build-time) "unix epoc."))

License

Copyright Xcoo, Inc.

Licensed under the Apache License, Version 2.0.

About

A minimal library to read build timestamp from JAR/WAR manifests.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published