Skip to content

Instantly share code, notes, and snippets.

@zhiyb
Last active February 21, 2018 23:17
Show Gist options
  • Select an option

  • Save zhiyb/1336bf58d068f81fd347423a5401d297 to your computer and use it in GitHub Desktop.

Select an option

Save zhiyb/1336bf58d068f81fd347423a5401d297 to your computer and use it in GitHub Desktop.
Makefile for downloading all Minecraft client & server jars
MANIFEST_URL ?= https://launchermeta.mojang.com/mc/game/version_manifest.json
.DELETE_ON_ERROR:
.PHONY: manifest
manifest:
curl -s -o version_manifest.json -L $(MANIFEST_URL)
$(MAKE) JSON_URL="`jq -r < version_manifest.json '.versions|.[]|.url' | xargs`" versions
VERSIONS := $(basename $(notdir $(JSON_URL)))
.PHONY: versions
versions: $(VERSIONS:%=v-%)
v-%:
$(MAKE) VER=$* URL="$(filter %/$*.json, $(JSON_URL))" v
.PHONY: v
v: $(VER)/$(VER).json
$(MAKE) JAR_URL="`jq < $< -r '.downloads|[.client?,.server?]|.[]|.url//empty' | xargs`" version
$(VER):
mkdir -p $@
%.json: | $(VER)
curl -s -o $@ -L $(URL)
.PHONY: version
version: $(addprefix $(VER)/,$(notdir $(JAR_URL)))
$(VER)/%.jar:
curl --progress-bar -o $@ -L $(filter %/$*.jar, $(JAR_URL))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment