-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (50 loc) · 2.46 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
PROJECT = Lagari
VERSION = 1.0.3
PROJECT_ROOT = /root/$(PROJECT)
JAR = $(PROJECT)-$(VERSION).jar
SNAPSHOT_JAR = target/$(PROJECT)-$(VERSION)-SNAPSHOT.jar
PODMAN ?= podman
IMAGE ?= localhost/openjdk17:alpine
M2_ROOT = /root/.m2
MVN = sh $(SPIGOTMC_ROOT)/apache-maven-3.6.0/bin/mvn
SPIGOTMC_VERSION ?= 1.20
SPIGOTMC_ROOT = $(PROJECT_ROOT)/spigotmc
SPIGOTMC_JAR = $(SPIGOTMC_ROOT)/spigot-$(SPIGOTMC_VERSION).jar
SPIGOTMC_API_JAR = $(SPIGOTMC_ROOT)/Spigot/Spigot-API/target/spigot-api-$(SPIGOTMC_VERSION)-R0.1-SNAPSHOT-shaded.jar
BUILDTOOLS_URL = https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
SPIGOTMC_NAME ?= spigotmc
SPIGOTMC_DATA ?= spigotmc-data
PODMAN_OPTIONS = --rm --security-opt label=disable --volume "$(CURDIR):$(PROJECT_ROOT)"
.PHONY: all run clean distclean image
all: $(JAR)
$(JAR): | spigotmc
mkdir -p .m2
$(PODMAN) run $(PODMAN_OPTIONS) --volume "$(CURDIR)/.m2:$(M2_ROOT)" --workdir $(PROJECT_ROOT) $(IMAGE) \
$(MVN) install:install-file -Dfile=$(SPIGOTMC_API_JAR)
$(PODMAN) run $(PODMAN_OPTIONS) --volume "$(CURDIR)/.m2:$(M2_ROOT)" --workdir $(PROJECT_ROOT) $(IMAGE) $(MVN) verify
mv $(SNAPSHOT_JAR) $@
run: $(JAR)
mkdir -p $(SPIGOTMC_DATA)/plugins
[ -f $(SPIGOTMC_DATA)/eula.txt ] || echo "eula=true" > $(SPIGOTMC_DATA)/eula.txt
[ -f $(SPIGOTMC_DATA)/plugins/$(JAR) ] || cp $(JAR) $(SPIGOTMC_DATA)/plugins
$(PODMAN) run $(PODMAN_OPTIONS) --detach --interactive --name $(SPIGOTMC_NAME) --publish 25565:25565 --tty \
--volume "$(CURDIR)/$(SPIGOTMC_DATA):$(PROJECT_ROOT)/$(SPIGOTMC_DATA)" --workdir $(PROJECT_ROOT)/$(SPIGOTMC_DATA) $(IMAGE) \
java -jar $(SPIGOTMC_JAR)
doc: | spigotmc
mkdir -p $@
$(PODMAN) run $(PODMAN_OPTIONS) --workdir $(PROJECT_ROOT)/$@ $(IMAGE) \
javadoc -classpath $(SPIGOTMC_API_JAR) -sourcepath $(PROJECT_ROOT)/src/main/java com.github.justinjereza.Lagari
clean:
-$(PODMAN) image exists $(IMAGE) && $(PODMAN) run $(PODMAN_OPTIONS) --workdir $(PROJECT_ROOT) $(IMAGE) $(MVN) clean
$(RM) -r $(JAR) $(SPIGOTMC_DATA)/plugins/$(JAR)
distclean: clean
$(RM) -r .m2 doc spigotmc
$(PODMAN) image rm $(IMAGE)
image:
-$(PODMAN) image exists $(IMAGE) || $(PODMAN) build --tag $(IMAGE) $(CURDIR)
spigotmc: image
mkdir -p $@
$(PODMAN) run $(PODMAN_OPTIONS) --workdir $(SPIGOTMC_ROOT) $(IMAGE) \
sh -c "[ -f BuildTools.jar ] || wget $(BUILDTOOLS_URL)"
$(PODMAN) run $(PODMAN_OPTIONS) --workdir $(SPIGOTMC_ROOT) $(IMAGE) \
sh -c "[ -f $(SPIGOTMC_JAR) ] || java -jar BuildTools.jar -rev $(SPIGOTMC_VERSION)"