Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #12391: Make maven faster and correct MAVEN_OPS #28

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,3 +15,4 @@ license.sign
*.pubkey
*.privkey
pom.xml
makefiles/m2_location.cache
4 changes: 4 additions & 0 deletions Makefile
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
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
@@ -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
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
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