# Authoritative build rules
#
# If you don't have GNU Make on your system, use this file as a guide for
# performing build tasks
#
MODULE_NAME_OVERRIDE = {{name}}

.PHONY: help build deploy dev clean repl \
	release-major release-minor release-patch \
	test test-watch version-info

## Display this help text.
help:
	$(info Available targets)
	@awk '/^[a-zA-Z\-\_0-9]+:/ {                    \
	  nb = sub( /^## /, "", helpMsg );              \
	  if(nb == 0) {                                 \
	    helpMsg = $$0;                              \
	    nb = sub( /^[^:]*:.* ## /, "", helpMsg );   \
	  }                                             \
	  if (nb)                                       \
	    print  $$1 "\t" helpMsg;                    \
	}                                               \
	{ helpMsg = $$0 }'                              \
	$(MAKEFILE_LIST) | column -ts $$'\t' |          \
	grep --color '^[^ ]*'

## Build JAR artifacts.
build: clean
	bin/build

## Deploy JAR artifacts to a repository.
deploy: build
	bin/deploy

## Start a development REPL.
dev: repl

## Clean all build targets.
clean:
	rm -Rf target/

## Start a development REPL.
repl:
	$(warning "See `bin/dev` script, or run clojure command directly.")
	$(warning "OSX may not correctly pipe the interactive shell.")
	clojure -Adev:rebel:test

## Gitops for a release with breaking changes.
release-major:
	bin/release major
## Gitops for a release with new features.
release-minor:
	bin/release minor
## Gitops for a release with no user-facing changes.
release-patch:
	bin/release patch

## Run tests.
test:
	bin/test

## Run tests with an interactive file watch.
test-watch:
	bin/test --watch

## Print information about current version.
version-info:
	clj -A:metav -m metav.display \
	  --config-file .metav.edn \
	  --module-name-override $(MODULE_NAME_OVERRIDE)
