Skip to content

Instantly share code, notes, and snippets.

@amusarra
Last active March 5, 2018 22:50
Show Gist options
  • Save amusarra/83ba654d1a422e55b05edd0f2758bcfe to your computer and use it in GitHub Desktop.
Save amusarra/83ba654d1a422e55b05edd0f2758bcfe to your computer and use it in GitHub Desktop.
Add Liferay Bundles to Maven Local Repository
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2018 Antonio Musarra's Blog - https://www.dontesta.it
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
set -e
! [ -x "$(command -v mvn)" ] && exit 1
if [ ! -z "$1" ]; then
LIFERAY_SOURCES_ROOT_PATH=$1
fi
: ${LIFERAY_SOURCES_ROOT_PATH:?"Need to set LIFERAY_SOURCES_ROOT_PATH environment and non-empty"}
[ -d "$LIFERAY_SOURCES_ROOT_PATH" ] && echo "Liferay Sources Code Path: $LIFERAY_SOURCES_ROOT_PATH" || (echo "The path $LIFERAY_SOURCES_ROOT_PATH does not exist" && exit 2)
[ -d "$LIFERAY_SOURCES_ROOT_PATH/tools/sdk/dist" ] && echo "Liferay SDK Dist Path : $LIFERAY_SOURCES_ROOT_PATH/tools/sdk/dist" || (echo "The path $LIFERAY_SOURCES_ROOT_PATH/tools/sdk/dist does not exist" && exit 3)
MAVEN_GROUP_ID="com.liferay"
MAVEN_PACKAGE="jar"
COUNT_JARS=`ls -l $LIFERAY_SOURCES_ROOT_PATH/tools/sdk/dist/*.jar | wc -l`
echo "There are ${COUNT_JARS} bundles to install"
for bundlename in $LIFERAY_SOURCES_ROOT_PATH/tools/sdk/dist/*.jar ; do
[[ "$bundlename" =~ ([[:digit:]]+.[[:digit:]]+.[[:digit:]]+) ]] && bundle_version=${BASH_REMATCH[1]}
[[ `basename $bundlename` =~ ([^-]*) ]] && bundle_name=${BASH_REMATCH[1]}
echo "Try to install the $bundle_name version $bundle_version in local maven repository..."
mvn install:install-file -Dfile=$bundlename \
-DgroupId=$MAVEN_GROUP_ID \
-DartifactId=$bundle_name \
-Dversion=$bundle_version \
-Dpackaging=$MAVEN_PACKAGE
done
@amusarra
Copy link
Author

amusarra commented Mar 5, 2018

Accept LIFERAY_SOURCES_ROOT_PATH from command arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment