Last active
February 9, 2022 09:14
-
-
Save CorneilleEdi/2125556867e7f268da0a75b7161b7895 to your computer and use it in GitHub Desktop.
Go to java Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JAVAC=javac | |
JAVA=java | |
JAVADOC=javadoc | |
OUT_DIR=out | |
DOCS_DIR=docs | |
SRC_DIR=. | |
JAVA_FILES=$(notdir $(wildcard $(SRC_DIR)/*.java)) | |
CLASS_FILES=$(JAVA_FILES:%.java=$(OUT_DIR)/%.class) | |
MAIN_CLASS=Main | |
all: dirs jar | |
jar: $(CLASS_FILES) | |
$(OUT_DIR)/%.class : $(SRC_DIR)/%.java | |
$(JAVAC) $< -d $(OUT_DIR) -classpath $(SRC_DIR) | |
# Can not run since we do not have a proper main. | |
# We have to run the server and then the Client. | |
run: all | |
$(JAVA) -server -XX:-AggressiveOpts -classpath $(OUT_DIR) $(MAIN_CLASS) | |
.PHONY: dirs clean | |
dirs: $(OUT_DIR) | |
doc : | |
mkdir -p $(DOCS_DIR) && $(JAVADOC) $(JAVA_FILES) -d $(DOCS_DIR) | |
$(OUT_DIR): | |
mkdir -p $@ | |
$(DOCS_DIR): | |
mkdir -p $@ | |
clean : | |
rm -rf $(DOCS_DIR) | |
rm -rf $(OUT_DIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My go-to java Makefile when I'm not working with an IDE