summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-11-16 03:36:40 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-11-16 03:36:40 -0500
commitc2fb9eec0a018b2dced5078904a77d6adf75c6ab (patch)
tree5573bd54221de13336768199be4c163d2f93aa85
parent4503e3cf26c00f856a1a5a4ed63a193d7800b7d0 (diff)
Support stubbing entry points without exposing the entire classpath
And use this for modello in maven.
-rw-r--r--Makefile50
-rw-r--r--conf/dependencies.mk3
-rw-r--r--conf/sources.mk1
-rw-r--r--rules/maven/Makefile3
-rw-r--r--rules/maven/fix-build-xml.patch13
5 files changed, 49 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 03a7b36..dd2140a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,22 @@
top := $(shell pwd)
-CAT = cat
-CP = cp
-ECHO = echo
-EXISTS = test -e
-FAIL = exit 1
-FIND = find
-GIT = git
-MKDIRS = mkdir -p
-PATCH = patch
-RM = rm -f
-SED = sed
-SVN = svn
-TAR = bsdtar
-TOUCH = touch
-WGET = wget
+CAT = cat
+CP = cp
+ECHO = echo
+EXISTS = test -e
+FAIL = exit 1
+FIND = find
+GIT = git
+INSTALL = install
+JAVA = java
+MKDIRS = mkdir -p
+PATCH = patch
+RM = rm -f
+SED = sed
+SVN = svn
+TAR = bsdtar
+TOUCH = touch
+WGET = wget
all: package
@@ -46,6 +48,7 @@ export JAR_DIR := $(shell $(CAT) conf/jardir.txt)
# Post-processing for conf/sources.mk
packages := $(filter-out _%,$(variables))
packages_specific=$(filter $(patsubst rules/%/Makefile,%,$(wildcard rules/*/Makefile)),$(packages))
+packages_stub =$(foreach package,$(packages),$(if $(filter stub,$(call name2,type,$(package))),$(package)))
packages_generic =$(filter-out $(packages_specific) $(packages_stub),$(packages))
specs := $(foreach variable,$(variables),$(if $(findstring |,$($(variable))),$($(variable))))
@@ -87,7 +90,7 @@ build/download/tar/%: .tokens/network
# extract ######################################################################
-extract: PHONY $(addprefix build/extract,$(call spec2,file,$(specs)))
+extract: PHONY $(addprefix build/extract,$(call spec2,file,$(call specs_for,git svn tar union)))
# This is a little gross because to get the dependencies right for
# `git` and `tar`, we need to do a bit more complex processing of
@@ -203,6 +206,21 @@ build/packages/%: RECURSIVE build/workdir/% rules/_generic/Makefile
for dep in $(filter-out RECURSIVE,$^); do $(EXISTS) $$dep || { $(RM) -r '$@'; $(FAIL); }; done
$(call recurse,$(top)/rules/_generic/Makefile) || { $(RM) -r '$@'; $(FAIL); }
+$(addprefix build/packages/,$(packages_stub)): \
+build/packages/%: $(MAKEFILE_LIST)
+ { \
+ $(ECHO) '#!/bin/sh' && \
+ $(ECHO) 'CLASSPATH=$(call deps2classpath,$^):$${CLASSPATH:+:$${CLASSPATH}}' && \
+ $(ECHO) 'export CLASSPATH' && \
+ $(ECHO) 'exec $(JAVA) $(call name2,extra,$*)' ; \
+ } | $(INSTALL) -Dm755 /dev/stdin '$@/usr/bin/$(call name2,url,$*)' && \
+ { \
+ $(ECHO) '#!/bin/sh' && \
+ $(ECHO) 'CLASSPATH=$(call deps2classpath,$^):$${CLASSPATH:+:$${CLASSPATH}}' && \
+ $(ECHO) 'printf '%s\n' "$$CLASSPATH"' ; \
+ } | $(INSTALL) -Dm755 /dev/stdin '$@/usr/bin/$(call name2,url,$*)-classpath' || \
+ { $(RM) -r '$@'; $(FAIL); }
+
# boilerplate ##################################################################
clean: PHONY
diff --git a/conf/dependencies.mk b/conf/dependencies.mk
index 716e95b..725b639 100644
--- a/conf/dependencies.mk
+++ b/conf/dependencies.mk
@@ -7,6 +7,7 @@ dep-meta-modello-cli = \
build/packages/plexus-container-default \
build/packages/plexus-utils \
build/packages/xbean-bootstrap
+build/packages/modello-cli: $(dep-meta-modello-cli)
# What is needed to use the Plexus Metadata Generator command line
dep-meta-plexus-metadata-generator-cli = \
build/packages/commons-cli \
@@ -54,9 +55,9 @@ build/packages/httpcomponents-client-bootstrap: \
build/packages/httpcomponents-core
build/packages/maven: \
- $(dep-meta-modello-cli) \
$(dep-meta-plexus-metadata-generator-cli) \
$(dep-std-jsr330) \
+ build/packages/modello-cli \
build/packages/aether-core \
build/packages/guice-bootstrap \
build/packages/logback-core \
diff --git a/conf/sources.mk b/conf/sources.mk
index f7dfd81..ec27482 100644
--- a/conf/sources.mk
+++ b/conf/sources.mk
@@ -32,6 +32,7 @@ xbean-bootstrap = svn|$(_apache_svn)/geronimo/xbean
# Modello
modello-core = tar|https://github.com/sonatype/modello/archive/modello-1.8.1.tar.gz|modello-core
modello-plugins = tar|https://github.com/sonatype/modello/archive/modello-1.8.1.tar.gz|modello-plugins
+modello-cli = stub|modello|org.codehaus.modello.ModelloCli
# Plexus
plexus-build-api = tar|https://github.com/sonatype/sisu-build-api/archive/plexus-build-api-0.0.7.tar.gz
diff --git a/rules/maven/Makefile b/rules/maven/Makefile
index 199725b..3578d32 100644
--- a/rules/maven/Makefile
+++ b/rules/maven/Makefile
@@ -1,6 +1,9 @@
ANT = ant
FIND = find
+MODELLO_CLASSPATH := $(shell modello-classpath)
+export MODELLO_CLASSPATH
+
%:
# $@
bash -i
diff --git a/rules/maven/fix-build-xml.patch b/rules/maven/fix-build-xml.patch
index 06e6580..b2b9a2a 100644
--- a/rules/maven/fix-build-xml.patch
+++ b/rules/maven/fix-build-xml.patch
@@ -28,16 +28,21 @@
<!-- Pull the dependencies that Maven needs to build -->
<copy file="pom.xml" tofile="dependencies.xml" />
<replace file="${basedir}/dependencies.xml" token="&lt;!--bootstrap-start-comment--&gt;" value="&lt;!--" />
-@@ -125,10 +128,14 @@
+@@ -125,10 +128,19 @@
<localRepository path="${maven.repo.local}" />
<dependency groupId="org.codehaus.plexus" artifactId="plexus-component-metadata" version="${pom.properties.plexusVersion}" />
</artifact:dependencies>
-
+ </target>
+ <target name="pull-cached" depends="init" if="skip.pull">
-+ <path id="pom.pathid"><pathelement path="${env.CLASSPATH}"/></path>
-+ <path id="modello.pathid"><pathelement path="${env.CLASSPATH}"/></path>
-+ <path id="pmdg.pathid"><pathelement path="${env.CLASSPATH}"/></path>
++ <!-- Fall back to the global env.CLASSPATH if unset -->
++ <property name="env.POM_CLASSPATH" value="${env.CLASSPATH}"/>
++ <property name="env.MODELLO_CLASSPATH" value="${env.CLASSPATH}"/>
++ <property name="env.PMDG_CLASSPATH" value="${env.CLASSPATH}"/>
++ <!-- Import the various classpaths -->
++ <path id="pom.pathid" ><pathelement path="${env.POM_CLASSPATH}" /></path>
++ <path id="modello.pathid"><pathelement path="${env.MODELLO_CLASSPATH}"/></path>
++ <path id="pmdg.pathid" ><pathelement path="${env.PMDG_CLASSPATH}" /></path>
</target>
- <target name="process-classes" depends="pull" description="generates plexus component metadata.">