summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-07-23 13:03:55 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-07-23 13:03:55 -0400
commitc63599f77c3c139abb3bb36a15888c5563e7b269 (patch)
tree65e61bda8ecf78ff629fc00809d115ac4bf34b34
parent755761fbdd192e781c956e5bb64eb2ab0dcf86dc (diff)
rules/generic: Get the Java version and encoding from POM
-rw-r--r--rules/commons-lang2/encoding.mk2
-rw-r--r--rules/commons-lang2/java4-enum.mk6
-rw-r--r--rules/generic/Makefile32
3 files changed, 24 insertions, 16 deletions
diff --git a/rules/commons-lang2/encoding.mk b/rules/commons-lang2/encoding.mk
index c4085a7..365809f 100644
--- a/rules/commons-lang2/encoding.mk
+++ b/rules/commons-lang2/encoding.mk
@@ -1 +1 @@
-JAVAC += -encoding ISO-8859-1
+project.build.sourceEncoding = ISO-8859-1
diff --git a/rules/commons-lang2/java4-enum.mk b/rules/commons-lang2/java4-enum.mk
deleted file mode 100644
index 7689b64..0000000
--- a/rules/commons-lang2/java4-enum.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-# error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
-# package org.apache.commons.lang.enum;
-# ^
-# (use -source 1.4 or lower to use 'enum' as an identifier)
-
-JAVAC += -source 1.4
diff --git a/rules/generic/Makefile b/rules/generic/Makefile
index dbadab2..7229a88 100644
--- a/rules/generic/Makefile
+++ b/rules/generic/Makefile
@@ -21,21 +21,35 @@ SED = sed
TOUCH = touch
XMLSTARLET = xml
+JAVAC_FLAGS += $(if $(maven.compiler.source),-source $(maven.compiler.source))
+JAVAC_FLAGS += $(if $(maven.compiler.target),-target $(maven.compiler.target))
+JAVAC_FLAGS += $(if $(project.build.sourceEncoding),-encoding $(project.build.sourceEncoding))
+
# Detect information from POMs
-artifactId := $(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))
-groupId := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:groupId -n -c /_:project/_:parent/_:groupId pom.xml))
+pom_get = $(shell $(XMLSTARLET) sel -T -t $(foreach xpath,$1, -c $(subst /,/_:,$(xpath)) -n) pom.xml)
+
+artifactId := $(call pom_get,/project/artifactId)
+version := $(firstword $(call pom_get,/project/version /project/parent/version) $(value version))
+groupId := $(firstword $(call pom_get,/project/groupId /project/parent/groupId))
-sourceDirectory := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:sourceDirectory -n pom.xml) $(value sourceDirectory) src/main/java)
-$(eval sourceDirectory = $(sourceDirectory))
-resources := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:resources -n pom.xml)
-resources := $(if $(resources),$(resources),src/main/resources)
+sourceDirectory := $(firstword $(call pom_get,/project/build/sourceDirectory ) $(value sourceDirectory) src/main/java )
+resources := $(firstword $(call pom_get,/project/build/resources ) $(value resources) src/main/resources)
+maven.compiler.source := $(firstword $(call pom_get,/project/properties/maven.compile.source \
+ /project/properties/maven.compiler.source ) $(value maven_compiler_source) )
+maven.compiler.target := $(firstword $(call pom_get,/project/properties/maven.compile.target \
+ /project/properties/maven.compiler.target ) $(value maven_compiler_target) )
+project.build.sourceEncoding := $(firstword $(call pom_get,/project/properties/project.build.sourceEncoding) $(value project_build_sourceEncoding) )
basedir = .
project.basedir = $(basedir)
subdirs = $(patsubst %/pom.xml,%,$(wildcard */pom.xml))
targets = pom $(if $(wildcard src/main/ $(sourceDirectory) $(resources)),jar)
+# Post-processing
+
+inherit_vars = version sourceDirectory resources maven.compiler.source maven.compiler.target project.build.sourceEncoding
+$(foreach var,$(inherit_vars),$(eval $(var) = $($(var))))
+
$(if $(extra_makefiles),$(eval include $(extra_makefiles)))
subdirs := $(subdirs)
@@ -85,7 +99,7 @@ target/classes: \
$(RM) -r $@
$(MKDIRS) $@
$(FIND) $(wildcard $(resources) target/generated-resources) -mindepth 1 -maxdepth 1 -exec $(CP) -r {} $@ \; || { $(RM) -r $@; $(FAIL); } # process-resources
- $(FIND) $(wildcard $(sourceDirectory) target/generated-sources) -name '*.java' -exec $(JAVAC) -d $@ {} + || { $(RM) -r $@; $(FAIL); } # compile
+ $(FIND) $(wildcard $(sourceDirectory) target/generated-sources) -name '*.java' -exec $(JAVAC) $(JAVAC_FLAGS) -d $@ {} + || { $(RM) -r $@; $(FAIL); } # compile
$(TOUCH) $@
# package ######################################################################
@@ -119,7 +133,7 @@ deps2classpath = $(shell $(ECHO) $(abspath $(call deps2jars,$1)) $(CLASSPATH) |
define recurse-rule
$1/%: PHONY $(addsuffix /all,$($1_deps))
- CLASSPATH='$$(call deps2classpath,$$^)' sourceDirectory='$$(value sourceDirectory)' version='$$(value version)' $$(MAKE) -C '$1' -f '$$(abspath $$(firstword $$(MAKEFILE_LIST)))' '$$*'
+ CLASSPATH='$$(call deps2classpath,$$^)' $(foreach var,$(inherit_vars),$(subst .,_,$(var))='$$(value $(var))') $$(MAKE) -C '$1' -f '$$(abspath $$(firstword $$(MAKEFILE_LIST)))' '$$*'
endef
$(foreach subdir,$(subdirs),$(eval $(call recurse-rule,$(subdir))))