summaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-08 01:28:08 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-06-08 01:28:08 -0400
commit9b89cd1b21280111a87aced6e6c857a8d0b69664 (patch)
tree1601df82486ab137a1ae5d9811b580150ba5a903 /rules
parent7c4de79ba6f95d88a7adde236aac52f38a94bdd1 (diff)
Add cal10n, and make required changes to generic/Makefile.
This means handling resources in a manner more similar to actual maven.
Diffstat (limited to 'rules')
-rw-r--r--rules/cal10n/subdir-deps.mk4
-rw-r--r--rules/generic/Makefile34
2 files changed, 26 insertions, 12 deletions
diff --git a/rules/cal10n/subdir-deps.mk b/rules/cal10n/subdir-deps.mk
new file mode 100644
index 0000000..5830ddd
--- /dev/null
+++ b/rules/cal10n/subdir-deps.mk
@@ -0,0 +1,4 @@
+JAVAC += -encoding ISO-8859-1
+
+maven-cal10n-plugin-smoke_deps = cal10n-api
+maven-cal10n-plugin_deps = cal10n-api
diff --git a/rules/generic/Makefile b/rules/generic/Makefile
index b80fc50..a7a0309 100644
--- a/rules/generic/Makefile
+++ b/rules/generic/Makefile
@@ -5,24 +5,29 @@ DESTDIR ?=
MAVEN_LOCAL_REPO ?= ~/.m2
# Utilities
-XMLSTARLET = xml
+CP = cp
+ECHO = echo
FAIL = exit 1
FIND = find
-JAVAC = javac
INSTALL = install
+JAR = jar
+JAVAC = javac
MKDIRS = mkdir -p
+PRINTF = printf
RM = rm -f
-JAR = jar
-CP = cp
+XMLSTARLET = xml
# 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))
+
sourceDirectory := $(firstword $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:sourceDirectory -n pom.xml) $(sourceDirectory) src/main/java)
+resources := $(shell $(XMLSTARLET) sel -T -t -c /_:project/_:build/_:resources -n pom.xml)
+resources := $(if $(resources),$(resources),src/main/resources)
subdirs = $(patsubst %/pom.xml,%,$(wildcard */pom.xml))
-targets = pom $(if $(wildcard src/main/ $(sourceDirectory)),jar)
+targets = pom $(if $(wildcard src/main/ $(sourceDirectory) $(resources)),jar)
$(if $(extra_makefiles),$(eval include $(extra_makefiles)))
@@ -46,20 +51,19 @@ target/$(artifactId)-$(version).jar: %.jar: %
target/$(artifactId)-$(version): %: \
target/META-INF/maven/$(groupId)/$(artifactId)/pom.properties \
target/META-INF/maven/$(groupId)/$(artifactId)/pom.xml \
- $(call dep_dir,target/classes) \
- $(call dep_optdir,src/main/resources)
+ $(call dep_dir,target/classes)
$(RM) -r $@
$(MKDIRS) $@
- $(CP) -r target/META-INF $(wildcard target/classes/* src/main/resources/*) $@
+ $(CP) -r target/META-INF $(wildcard target/classes/*) $@
target/META-INF/maven/$(groupId)/$(artifactId)/pom.xml: pom.xml
- install -Dm644 $< $@
+ $(INSTALL) -Dm644 $< $@
# That is almost the default date format for locale=C, but the DOM is
# 0-padded instead of space-padded.
target/META-INF/maven/$(groupId)/$(artifactId)/pom.properties: pom.xml
$(MKDIRS) $(@D)
- printf '%s\n' \
+ $(PRINTF) '%s\n' \
'#Generated by Make' \
"#$$(LC_ALL=C date '+%a %b %d %H:%M:%S %Z %Y')" \
'version=$(version)' \
@@ -67,9 +71,15 @@ target/META-INF/maven/$(groupId)/$(artifactId)/pom.properties: pom.xml
'artifactId=$(artifactId)' \
> $@
-target/classes: $(call dep_optdir,$(sourceDirectory))
+exec_nonempty_q = $(if $(strip $1),@$(ECHO) $2; $(subst {},$1,$2))
+exec_nonempty_v = $(if $(strip $1),$(subst {},$1,$2))
+# Maven puts `target/classes` in the classpath, but that's unnecessary
+# here, as we don't do incremental/segmented compilation.
+target/classes: $(call dep_optdir,$(sourceDirectory) $(resources))
+ $(RM) -r $@
$(MKDIRS) $@
- @echo $(JAVAC) -d $@ ...; $(if $^,$(JAVAC) -d $@ $(filter %.java,$^) || { $(RM) -r $@; $(FAIL); })
+ $(call exec_nonempty_q,$(wildcard $(addsuffix /*,$(resources))),$(CP) -r {} $@ || { $(RM) -r $@; $(FAIL); })
+ $(call exec_nonempty_q,$(filter %.java,$^) ,$(JAVAC) -d $@ {} || { $(RM) -r $@; $(FAIL); })
# install