Forked from admanzoni/gist:8ef4e6eb115d6793ca64d524de803bb5
Last active
July 20, 2023 23:24
-
-
Save mkgl/44afd5c807a210b1c91bbfb363cccee4 to your computer and use it in GitHub Desktop.
Package local releases with maven2 repo layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Reference: http://roboojack.blogspot.in/2014/12/bulk-upload-your-local-maven-artifacts.html | |
if [ "$#" -ne 2 ] || ! [ -d "$1" ]; then | |
echo "Usage:" | |
echo " ./package-local-releases.sh <repoRootDirectory> <outputDirectory>" | |
echo "" | |
echo "" | |
echo " Where..." | |
echo " repoRootDirectory: The folder containing the repository tree." | |
echo " outputDirectory: The target directory where relevant local artifacts will be copied." | |
exit 1 | |
fi | |
repoRootDir=$1 | |
outputDir=$2 | |
find -E $repoRootDir -type d -regex "$1/info/magnolia/(.*/)?([a-zA-Z][a-zA-Z0-9_\-]*)/[0-9]+(\.[0-9]+)?(\.[0-9]+)?" | \ | |
while read -r line ; do | |
artifact_name=$(basename $(dirname $line)) | |
version=$(basename $line) | |
pomLocation="$line/$artifact_name-$version.pom" | |
relPath="${line#$1}" | |
relPath="${relPath%$version}" | |
if grep -q 'magnolia-parent-pom-internal\|<distribRepoPrefix>magnolia.internal</distribRepoPrefix>' "$pomLocation"; then | |
echo "Skipping $artifact_name:$version" | |
continue | |
fi | |
mkdir -p "$outputDir$relPath" | |
echo "Copying artifact $artifact_name\t[ $line ]" | |
#echo "[DEBUG]\tcp $line $outputDir$relPath" | |
cp -r $line "$outputDir$relPath" | |
find -E $outputDir -type f -regex '.*(\.sha1|\.repositories|\.lastUpdated|\.lastUpdate\.properties)' -exec rm {} \; | |
done | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment