From c2fb9eec0a018b2dced5078904a77d6adf75c6ab Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 16 Nov 2014 03:36:40 -0500 Subject: Support stubbing entry points without exposing the entire classpath And use this for modello in maven. --- Makefile | 50 ++++++++++++++++++++++++++++------------- conf/dependencies.mk | 3 ++- conf/sources.mk | 1 + rules/maven/Makefile | 3 +++ rules/maven/fix-build-xml.patch | 13 +++++++---- 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 @@ -@@ -125,10 +128,14 @@ +@@ -125,10 +128,19 @@ - + + -+ -+ -+ ++ ++ ++ ++ ++ ++ ++ ++ - -- cgit v1.2.3