summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-05-30 02:18:47 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-05-30 02:18:47 -0400
commit5b9bc1f149a566f447e3fc1c0144f2a35746c0ab (patch)
treed257c05d4067f5e0dff4d1f4ca6c08de6b8f846e
parentbabd394e9d68471e62e15607ab338060f1e097d3 (diff)
mvn-simple: support overriding build/sourceDirectory in the POM
-rw-r--r--makefiles/mvn-simple.mk15
1 files changed, 8 insertions, 7 deletions
diff --git a/makefiles/mvn-simple.mk b/makefiles/mvn-simple.mk
index 5bf8254..37ccee7 100644
--- a/makefiles/mvn-simple.mk
+++ b/makefiles/mvn-simple.mk
@@ -14,17 +14,18 @@ RM = rm -f
JAR = jar
# Detect information from POMs
-artifact := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:artifactId pom.xml)
+artifact := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:artifactId -n pom.xml)
version := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:version -n -c /_:project/_:parent/_:version pom.xml) $(version))
group := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:groupId -n -c /_:project/_:parent/_:groupId pom.xml))
+srcdir := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:sourceDirectory -n pom.xml) $(srcdir) src/main/java)
mvn_subdirs := $(patsubst %/pom.xml,%,$(wildcard */pom.xml))
subdirs := $(if $(subdirs),$(filter $(mvn_subdirs),$(subdirs)),$(mvn_subdirs))
-targets := pom $(if $(wildcard src/main/),jar)
+targets := pom $(if $(wildcard src/main/ $(srcdir)),jar)
################################################################################
jar_add_dir = $(foreach file,$(wildcard $1/*), -C $1 $(patsubst $1/%,%,$(file)) )
-dep_dir = $1 $(shell $(FIND) $1)
+dep_dir = $1 $(shell $(FIND) $1 2>/dev/null)
dep_optdir = $(shell $(FIND) $1 2>/dev/null)
# all
@@ -40,7 +41,7 @@ target/$(artifact)-$(version).jar: \
target/META-INF/maven/$(group)/$(artifact)/pom.properties \
target/META-INF/maven/$(group)/$(artifact)/pom.xml \
$(call dep_dir,target/classes) \
- $(call dep_dir,src/main)
+ $(call dep_optdir,src/main/resources)
$(MKDIRS) $(@D)
$(JAR) -cf $@ -C target META-INF $(call jar_add_dir,target/classes) $(call jar_add_dir,src/main/resources)
@@ -57,9 +58,9 @@ target/META-INF/maven/$(group)/$(artifact)/pom.properties: pom.xml
'artifactId=$(artifact)' \
> $@
-target/classes: $(call dep_optdir,src/main/java)
+target/classes: $(call dep_optdir,$(srcdir))
$(MKDIRS) $@
- $(if $^,$(FIND) src/main/java -name '*.java' -exec $(JAVAC) -d $@ {} + || { $(RM) -r $@; exit 1; })
+ $(if $^,$(FIND) $(srcdir) -name '*.java' -exec $(JAVAC) -d $@ {} + || { $(RM) -r $@; exit 1; })
# install
@@ -78,7 +79,7 @@ clean: PHONY $(addsuffix /clean,$(subdirs))
# recurse
$(addsuffix /%,$(subdirs)): PHONY
- version='$(version)' $(MAKE) -C $(@D) -f '$(abspath $(firstword $(MAKEFILE_LIST)))' '$(@F)'
+ srcdir='$(srcdir)' version='$(version)' $(MAKE) -C $(@D) -f '$(abspath $(firstword $(MAKEFILE_LIST)))' '$(@F)'
# boilerplate