Skip to content

Commit

Permalink
Fixes #12391: Make maven faster and correct MAVEN_OPS
Browse files Browse the repository at this point in the history
  • Loading branch information
fanf committed Apr 10, 2018
1 parent 13b9871 commit 8d1b9fc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ license.sign
*.pubkey
*.privkey
pom.xml
makefiles/m2_location.cache
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ clean:
rm -f pom.xml
for i in $(ALL); do cd $$i; $(MAKE) clean; cd ..; done

very-clean: clean
./makefiles/find_m2_repo.sh clean


.PHONY: $(LIBS) $(PLUGINS)
4 changes: 2 additions & 2 deletions makefiles/common-scala-plugin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ TARGET_KEY_CLASSPATH = license.pubkey
# PUBLIC_KEY_PATH: path towards the public key to embed

std-files:
mvn $(MAVEN_OPTS) package
$(MVN_CMD) package
mkdir -p target/$(NAME)
mv target/$(NAME)-*-jar-with-dependencies.jar target/$(NAME)/$(NAME).jar

licensed-files: check-license
mvn $(MAVEN_OPTS) -Dlimited -Dplugin-resource-publickey=$(TARGET_KEY_CLASSPATH) -Dplugin-resource-license=$(TARGET_LICENSE_PATH) -Dplugin-declared-version=$(VERSION) package
$(MVN_CMD) -Dlimited -Dplugin-resource-publickey=$(TARGET_KEY_CLASSPATH) -Dplugin-resource-license=$(TARGET_LICENSE_PATH) -Dplugin-declared-version=$(VERSION) package
mkdir -p target/$(NAME)
mv target/$(NAME)-*-jar-with-dependencies.jar target/$(NAME)/$(NAME).jar
cp $(PUBLIC_KEY_PATH) target/$(TARGET_KEY_CLASSPATH)
Expand Down
27 changes: 27 additions & 0 deletions makefiles/find_m2_repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

#
# This file help find M2_REPO.
# This is not trivial as M2_REPO can be defined in a multitude of
# place, so the safe solution is to ask mvn directly.
# But even that is not easy, because mvn doesn't reply simply.
# And as it is very long, we want to cache the result
#

SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
M2_REPO_LOC_CACHE=${SCRIPT_DIR}/m2_location.cache

case $1 in

"clean")
rm -f ${M2_REPO_LOC_CACHE}
;;

*)
if [ ! -f ${M2_REPO_LOC_CACHE} ]; then
mvn ${MVN_PARAMS} help:evaluate -Dexpression="localRepository" | grep basedir | sed -e "s/.*>\(.*\)<.*/\1/" > ${M2_REPO_LOC_CACHE}
fi
cat ${M2_REPO_LOC_CACHE}

esac

5 changes: 2 additions & 3 deletions makefiles/global-vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ endif
LIB_COMMON_NAME = plugins-common
LIB_PRIVATE_NAME = plugins-common-private

# if you want to add maven option, add them with MVN_OPS
MAVEN_OPTS = $(MVN_OPS) --batch-mode

# if you want to add maven command line parameter, add them with MVN_PARAMS
MVN_CMD = mvn $(MVN_PARAMS) --batch-mode

generate-pom:
cp pom-template.xml pom.xml
Expand Down
6 changes: 3 additions & 3 deletions makefiles/make-plugins-common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include ../makefiles/global-vars.mk


# maven local repo
MAVEN_LOCAL_REPO = $(shell mvn help:evaluate -Dexpression="localRepository" | grep basedir | sed -e "s/.*>\(.*\)<.*/\1/")
MAVEN_LOCAL_REPO = $(shell $(MVN_PARAMS) ../makefiles/find_m2_repo.sh)

NAME = $(LIB_$(LIB_TYPE)_NAME)
VERSION = $(RUDDER_BRANCH)-$(LIB_$(LIB_TYPE)_VERSION)
Expand All @@ -23,11 +23,11 @@ PARENT_POM = $(MAVEN_LOCAL_REPO)/com/normation/plugins/plugins-parent/$(PARENT_V
# hand. Yep, most beautiful tool.
$(PLUGINS_JAR_PATH): $(PARENT_POM)
test -n "$(LIB_TYPE)" # $$LIB_TYPE must be defined to COMMON or PRIVATE
mvn $(MAVEN_OPTS) clean install
$(MVN_CMD) clean install

$(PARENT_POM):
echo $(PARENT_POM)
cd .. && mvn $(MAVEN_OPTS) -pl com.normation.plugins:plugins-parent install
cd .. && $(MVN_CMD) -pl com.normation.plugins:plugins-parent install
clean:
rm -f pom.xml
rm -rf target

0 comments on commit 8d1b9fc

Please sign in to comment.