forked from chaosblade-io/chaosblade-exec-jvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (66 loc) · 2.58 KB
/
Makefile
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
.PHONY: build clean
BLADE_SRC_ROOT=`pwd`
UNAME := $(shell uname)
ifeq ($(BLADE_VERSION), )
BLADE_VERSION=1.7.3
endif
PLUGINS_PATH=plugins
TARGET_PATH=target
BUILD_TARGET=build-target
BUILD_TARGET_DIR_NAME=chaosblade-$(BLADE_VERSION)
BUILD_TARGET_PKG_DIR=$(BUILD_TARGET)/chaosblade-$(BLADE_VERSION)
BUILD_TARGET_BIN=$(BUILD_TARGET_PKG_DIR)/bin
BUILD_TARGET_LIB=$(BUILD_TARGET_PKG_DIR)/lib
BUILD_TARGET_YAML=$(BUILD_TARGET_PKG_DIR)/yaml
# cache downloaded file
BUILD_TARGET_CACHE=$(BUILD_TARGET)/cache
# yaml file name
JVM_YAML_FILE_NAME=chaosblade-jvm-spec-$(BLADE_VERSION).yaml
# agent file name
JVM_AGENT_FILE_NAME=chaosblade-java-agent-$(BLADE_VERSION).jar
# oss url
BLADE_OSS_URL=https://chaosblade.oss-cn-hangzhou.aliyuncs.com/agent/release
# sandbox
JVM_SANDBOX_VERSION=1.3.3
JVM_SANDBOX_NAME=sandbox-$(JVM_SANDBOX_VERSION)-bin.zip
JVM_SANDBOX_OSS_URL=https://chaosblade.oss-cn-hangzhou.aliyuncs.com/agent/github/sandbox/$(JVM_SANDBOX_NAME)
JVM_SANDBOX_DEST_PATH=$(BUILD_TARGET_CACHE)/$(JVM_SANDBOX_NAME)
JVM_SANDBOX_TARGET_PATH=$(BUILD_TARGET_LIB)/sandbox
# used to java agent attach
BLADE_JAVA_TOOLS_JAR_NAME=tools.jar
BLADE_JAVA_TOOLS_JAR_DEST_PATH=$(BUILD_TARGET_CACHE)/$(BLADE_JAVA_TOOLS_JAR_NAME)
BLADE_JAVA_TOOLS_JAR_DOWNLOAD_URL=$(BLADE_OSS_URL)/$(BLADE_JAVA_TOOLS_JAR_NAME)
build: pre_build build_java
cp $(PLUGINS_PATH)/$(JVM_YAML_FILE_NAME) $(BUILD_TARGET_YAML)/
cp $(TARGET_PATH)/$(JVM_AGENT_FILE_NAME) $(JVM_SANDBOX_TARGET_PATH)/module/
# download sandbox for java chaos experiment
download_sandbox:
ifneq ($(BUILD_TARGET_CACHE), $(wildcard $(BUILD_TARGET_CACHE)))
mkdir -p $(BUILD_TARGET_CACHE)
endif
ifneq ($(JVM_SANDBOX_DEST_PATH), $(wildcard $(JVM_SANDBOX_DEST_PATH)))
wget "$(JVM_SANDBOX_OSS_URL)" -O $(JVM_SANDBOX_DEST_PATH)
endif
ifneq ($(BLADE_JAVA_TOOLS_JAR_DEST_PATH), $(wildcard $(BLADE_JAVA_TOOLS_JAR_DEST_PATH)))
wget "$(BLADE_JAVA_TOOLS_JAR_DOWNLOAD_URL)" -O $(BLADE_JAVA_TOOLS_JAR_DEST_PATH)
endif
pre_build: download_sandbox
rm -rf $(BUILD_TARGET_PKG_DIR)
mkdir -p $(BUILD_TARGET_BIN) $(BUILD_TARGET_LIB) $(BUILD_TARGET_YAML)
# unzip jvm-sandbox
unzip $(JVM_SANDBOX_DEST_PATH) -d $(BUILD_TARGET_LIB)
# cp tools.jar to lib/sandbox
cp $(BLADE_JAVA_TOOLS_JAR_DEST_PATH) $(JVM_SANDBOX_TARGET_PATH)
build_java:
rm -rf $(PLUGINS_PATH)
mkdir -p $(PLUGINS_PATH)
mvn clean package -Dmaven.test.skip=true -U
cp $(BLADE_SRC_ROOT)/chaosblade-exec-plugin/chaosblade-exec-plugin-*/target/chaosblade-exec-plugin-*.jar $(PLUGINS_PATH)
mvn clean assembly:assembly -Dmaven.test.skip=true -U
# test
test:
mvn clean test -U
# clean all build result
clean:
rm -rf $(BUILD_TARGET)
all: build test