How to Manage Maven Third Party Jars

bin/mvn-install.sh

01.#!/usr/bin/env bash
02.#
03.# Install local jar files into Maven repository. The artifact name would be same
04.# as the filename minus the extension.
05.# :Author: Zemian Deng
06.# :Date: 2013/06/17
07.#
08.# Usage:
09.#   # Print as maven dependency used in pom file
10.#   mvn-install.sh mygroup 1.0.0 lib/*.jar
11.#
12.#   # Install jar files into local maven repo
13.#   RUN_TYPE=install mvn-install.sh mygroup 1.0.0 lib/*.jar
14.#
15.#   # Deploy jar files into remote maven repo
17.#   RUN_TYPE=deploy mvn-install.sh mygroup 1.0.0 lib/*.jar
18.#
19. 
20.# Capture command arguments and options
21.GROUP=$1
22.shift
23.VERSION=$1
24.shift
25.FILES="$@"
26.if [[ "$GROUP" == "" || "$VERSION" == "" || "$FILES" == "" ]]; then
27.printf "ERROR: invalid arguments: GROUP VERSION FILES...\n"
28.exit 1
29.fi
30. 
31.RUN_TYPE=${RUN_TYPE:="print"} # values: print|install|deploy
32.REPO_ID=${REPO_ID:="nexus-server"} # Id defined in user's settings.xml for authentication
34. 
35.# For each file, perform action based on run type.
36.for FILE in $FILES; do
37.ARTIFACT=`basename $FILE '.jar'`
38.if [[ "$RUN_TYPE" == "deploy" ]]; then
39.printf "Deploying file=$FILE as artifact=$ARTIFACT to repo=$REPO_URL\n"
40.mvn deploy:deploy-file \
41.-DrepositoryId=$REPO_ID -Durl=$REPO_URL \
42.-DgroupId=$GROUP -DartifactId=$ARTIFACT -Dversion=$VERSION -Dpackaging=jar \
43.-Dfile=$FILE
44.elif [[ "$RUN_TYPE" == "install" ]]; then
45.printf "Installing file=$FILE as artifact=$ARTIFACT\n"
46.mvn install:install-file \
47.-DgroupId=$GROUP -DartifactId=$ARTIFACT -Dversion=$VERSION -Dpackaging=jar \
48.-Dfile=$FILE
49.elif [[ "$RUN_TYPE" == "print" ]]; then
50.printf "        <dependency>\n"
51.printf "            <groupId>$GROUP</groupId>\n"
52.printf "            <artifactId>$ARTIFACT</artifactId>\n"
53.printf "            <version>$VERSION</version>\n"
54.printf "        </dependency>\n"
55.fi
56.done

你可能感兴趣的:(java,maven)