Why is no one using make for Java?

前端 未结 17 1489
生来不讨喜
生来不讨喜 2020-12-12 09:09

Just about every Java project that I\'ve seen either uses Maven or Ant. They are fine tools and I think just about any project can use them. But what ever happened to make

17条回答
  •  温柔的废话
    2020-12-12 09:54

    Actually, make can handle the recompilation in one command of all outdated java files. Change the first line if you don't want to compile all files in the directory or want a specific order...

    JAVA_FILES:=$(wildcard *.java)
    #
    # the rest is independent of the directory
    #
    JAVA_CLASSES:=$(patsubst %.java,%.class,$(JAVA_FILES))
    
    .PHONY: classes
    LIST:=
    
    classes: $(JAVA_CLASSES)
            if [ ! -z "$(LIST)" ] ; then \
                    javac $(LIST) ; \
            fi
    
    $(JAVA_CLASSES) : %.class : %.java
            $(eval LIST+=$$<)
    

提交回复
热议问题