Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (79 loc) · 3.52 KB
/
Copy pathMakefile
File metadata and controls
98 lines (79 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Tarantool TCS DBeaver Plugin — local build & test helpers.
#
# Usage:
# make build # build plugin + feature + update-site
# make verify # build + run unit tests (one `mvn verify`)
# make test # run unit tests only (requires a prior build)
# make all # alias of `verify`
# make clean # remove build artifacts
# make help # show available targets
#
# You must point DBEAVER_PLUGINS at a DBeaver CE installation's plugins/ dir:
# make build DBEAVER_PLUGINS=/path/to/dbeaver/plugins
# # or set it once:
# export DBEAVER_PLUGINS=/path/to/dbeaver/plugins
DBEAVER_PLUGINS ?=
TYCHO_VERSION ?= 5.0.3
JUNIT_JAR ?= /tmp/junit-platform-console-standalone-6.1.0.jar
JUNIT_URL := https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/6.1.0/junit-platform-console-standalone-6.1.0.jar
PLUGIN_CLASSES := org.jkiss.dbeaver.ext.tarantool.tcs/target/classes
TEST_SRC := $(shell find test -name '*.java')
TEST_OUT := /tmp/tcs-test-out
.DEFAULT_GOAL := help
##@ Generate
.PHONY: target-dir
target-dir: ## Generate target/tcs.target from template tcs.target
@mkdir -p target \
&& sed 's|@dbeaver.plugins.path@|$(DBEAVER_PLUGINS)|' tcs.target > target/tcs.target
##@ Help
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make <target> [DBEAVER_PLUGINS=/path/to/dbeaver/plugins]\n\nTargets:\n"} \
/^[a-zA-Z_-]+:.*##/ { printf " %-12s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
##@ Build
.PHONY: build
build: target-dir check-dbeaver ## Build plugin + feature + p2 update-site
@mvn -B package
@echo "Build complete. Update site: org.jkiss.dbeaver.ext.tarantool.tcs.update-site/target/repository/"
##@ Test
.PHONY: test
test: check-dbeaver check-junit ## Run unit tests (requires 'make build' first)
@test -d $(PLUGIN_CLASSES) || (echo "ERROR: run 'make build' first"; exit 1)
@test -n "$(TEST_SRC)" || (echo "ERROR: no test sources found under test/"; exit 1)
@ECJARS=$$(find $(DBEAVER_PLUGINS) -name "*.jar" | tr "\n" ":"); \
rm -rf $(TEST_OUT) && mkdir -p $(TEST_OUT); \
javac -cp "$(PLUGIN_CLASSES):$$ECJARS:$(JUNIT_JAR)" -d $(TEST_OUT) $(TEST_SRC); \
CP="$(TEST_OUT):$(PLUGIN_CLASSES):$$ECJARS:$(JUNIT_JAR)"; \
printf -- "-cp\n%s\n" "$$CP" > /tmp/tcs-cp.txt; \
CLASSES=$$(find $(TEST_OUT) -name '*Test.class' \
| sed 's|^$(TEST_OUT)/||;s|/|.|g;s|\.class||'); \
SELECT=$$(for c in $$CLASSES; do printf -- "--select-class\n%s\n" "$$c"; done); \
java @/tmp/tcs-cp.txt org.junit.platform.console.ConsoleLauncher execute \
$$SELECT --disable-banner --details=tree
##@ Combo
.PHONY: verify
verify: target-dir check-dbeaver ## Build + run unit tests in one `mvn verify`
@mvn -B verify -Ddbeaver.plugins.path=$(DBEAVER_PLUGINS)
@echo "Verify complete (build + tests)."
.PHONY: all
all: verify ## Build + test (alias of `verify`)
##@ Cleanup
.PHONY: clean
clean: ## Remove Maven build artifacts
mvn -B clean
rm -rf $(TEST_OUT) /tmp/tcs-cp.txt
##@ Internal
.PHONY: check-dbeaver
check-dbeaver:
@if [ -z "$(DBEAVER_PLUGINS)" ]; then \
echo "ERROR: set DBEAVER_PLUGINS to your DBeaver CE plugins/ dir"; \
echo " make build DBEAVER_PLUGINS=/path/to/dbeaver/plugins"; \
exit 1; \
fi
@test -d "$(DBEAVER_PLUGINS)" || (echo "ERROR: $(DBEAVER_PLUGINS) not found"; exit 1)
.PHONY: check-junit
check-junit:
@if [ ! -f "$(JUNIT_JAR)" ]; then \
echo "Downloading JUnit standalone..."; \
curl -sL -o "$(JUNIT_JAR)" "$(JUNIT_URL)"; \
fi