summaryrefslogtreecommitdiff
path: root/makefiles/plexus.mk
diff options
context:
space:
mode:
Diffstat (limited to 'makefiles/plexus.mk')
-rw-r--r--makefiles/plexus.mk61
1 files changed, 61 insertions, 0 deletions
diff --git a/makefiles/plexus.mk b/makefiles/plexus.mk
new file mode 100644
index 0000000..16f0f37
--- /dev/null
+++ b/makefiles/plexus.mk
@@ -0,0 +1,61 @@
+DESTDIR ?=
+MAVEN_LOCAL_REPO ?= ~/.m2
+
+version=$(shell xml sel -T -t -c /_:project/_:version pom.xml)
+artifact=$(shell xml sel -T -t -c /_:project/_:artifactId pom.xml)
+group=org.codehaus.plexus
+
+####
+
+all: PHONY \
+ target/$(artifact)-$(version).pom \
+ target/$(artifact)-$(version).jar
+
+target/$(artifact)-$(version).pom: pom.xml
+ install -Dm644 $< $@
+
+target/$(artifact)-$(version).jar: \
+ target/META-INF/maven/$(group)/$(artifact)/pom.properties \
+ target/META-INF/maven/$(group)/$(artifact)/pom.xml \
+ target/classes \
+ src/main
+ mkdir -p $(@D)
+ jar -cf $@ \
+ -C target/classes org \
+ -C target META-INF \
+ $([[ ! -d src/main/resources ]] || { cd src/main/resources && printf ' -C src/main/resources %q ' *; })
+
+target/META-INF/maven/$(group)/$(artifact)/pom.xml: pom.xml
+ install -Dm644 $< $@
+
+target/META-INF/maven/$(group)/$(artifact)/pom.properties: pom.xml
+ mkdir -p $(@D)
+ printf '%s\n' \
+ '#Generated by Make' \
+ "#$$(LC_ALL=C date)" \
+ 'version=$(version)' \
+ 'groupId=$(group)' \
+ 'artifactId=$(artifact)' \
+ > $@
+
+target/classes: src/main/java FORCE
+ mkdir -p $@
+ find $< -name '*.java' -exec javac $(JAVAC_FLAGS) -d $@ {} +
+
+####
+
+install: PHONY \
+ $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(group))/$(artifact)/$(version)/$(artifact)-$(version).pom \
+ $(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(group))/$(artifact)/$(version)/$(artifact)-$(version).jar
+
+$(DESTDIR)$(MAVEN_LOCAL_REPO)/$(subst .,/,$(group))/$(artifact)/$(version)/%: target/%
+ install -Dm644 $< $@
+
+####
+
+clean: PHONY
+ rm -rf target
+
+####
+
+.PHONY: PHONY FORCE