Maven运行命令随记:修订间差异
来自三线的随记
小无编辑摘要 |
小无编辑摘要 |
||
第18行: | 第18行: | ||
需要将 ~/.m2/repository 中相应的jar包提前cp出来再进行deploy | 需要将 ~/.m2/repository 中相应的jar包提前cp出来再进行deploy | ||
<br /> | |||
==== 使用Maven向Nexus 批量 upload jar 包 ==== | |||
原脚本内容: | |||
#!/bin/sh | |||
# Reference: <nowiki>http://roboojack.blogspot.in/2014/12/bulk-upload-your-local-maven-artifacts.html</nowiki> | |||
if [ "$#" -ne 3 ] || ! [ -d "$1" ]; then | |||
echo "Usage:" | |||
echo " bash run.sh <repoRootFolder> <repositoryId> <repositoryUrl>" | |||
echo "" | |||
echo "" | |||
echo " Where..." | |||
echo " repoRootFolder: The folder containing the repository tree." | |||
echo " Ensure you move the repository outside of ~/.m2 folder" | |||
echo " or whatever is configured in settings.xml" | |||
echo " repositoryId: The repositoryId from the <server> configured for the repositoryUrl in settings.xml." | |||
echo " Ensure that you have configured username and password in settings.xml." | |||
echo " repositoryUrl: The URL of the repository where you want to upload the files." | |||
exit 1 | |||
fi | |||
while read -r line ; do | |||
echo "Processing file $line" | |||
pomLocation=${line/./} | |||
pomLocation=$PWD${pomLocation/jar/pom} | |||
jarLocation=${line/./} | |||
jarLocation=$PWD${jarLocation/pom/jar} | |||
#echo $pomLocation | |||
#echo $jarLocation | |||
mvn deploy:deploy-file -DpomFile=$pomLocation -Dfile=$jarLocation -DrepositoryId=$2 -Durl=$3 | |||
done < <(find $1 -name "*.jar") | |||
该脚本解析location似乎有问题,改了一下 | |||
#!/bin/sh | |||
# Reference: <nowiki>http://roboojack.blogspot.in/2014/12/bulk-upload-your-local-maven-artifacts.html</nowiki> | |||
if [ "$#" -ne 3 ] || ! [ -d "$1" ]; then | |||
echo "Usage:" | |||
echo " bash run.sh <repoRootFolder> <repositoryId> <repositoryUrl>" | |||
echo "" | |||
echo "" | |||
echo " Where..." | |||
echo " repoRootFolder: The folder containing the repository tree." | |||
echo " Ensure you move the repository outside of ~/.m2 folder" | |||
echo " or whatever is configured in settings.xml" | |||
echo " repositoryId: The repositoryId from the <server> configured for the repositoryUrl in settings.xml." | |||
echo " Ensure that you have configured username and password in settings.xml." | |||
echo " repositoryUrl: The URL of the repository where you want to upload the files." | |||
exit 1 | |||
fi | |||
while read -r line ; do | |||
echo "Processing file $line" | |||
Location=${line/.jar} | |||
pomLocation=${Location}.pom | |||
jarLocation=${Location}.jar | |||
echo $pomLocation | |||
echo $jarLocation | |||
mvn deploy:deploy-file -DpomFile=$pomLocation -Dfile=$jarLocation -DrepositoryId=$2 -Durl=$3 | |||
done < <(find $1 -name "*.jar") | |||
使用命令 bash script.sh m2 <repositoryId> <repositoryUrl> | |||
[[分类:Maven]] | [[分类:Maven]] | ||
[[分类:Java]] | [[分类:Java]] |
2021年8月4日 (三) 11:52的版本
Maven在运行命令中设置代理
mvn -B -DproxySet=true -Dhttp.proxyHost=proxy_host -Dhttp.proxyPort=1080 -Dhttp.nonProxyHosts="nonproxy.com|nonproxy.net:8080" package
Relation article
https://stackoverflow.com/questions/1251192/how-do-i-use-maven-through-a-proxy
该帖子中还会提到另一种设置http proxy以及socket proxy的参数,仅供参考,有待验证
使用Maven向Nexus upload jar包
mvn deploy:deploy-file -DgroupId={groupId} -DartifactId={artifactId} -Dversion={version} -Dpackaging=jar -Dfile=/jar-path.jar -Durl=http://nexus/repository/maven-uploaded-url
如果nexus有密码认证的话则需要-DrepositoryId=参数调用写在了settings.xml文件中servers段内的账号密码进行认证
mvn deploy:deploy-file -DgroupId={groupId} -DartifactId={artifactId} -Dversion={version} -Dpackaging=jar -Dfile=/jar-path.jar -DrepositoryId=nexus -Durl=http://nexus/repository/maven-uploaded-url
注意mvn deploy-file不支持上传处于本地repo中的jar包,即: Cannot deploy artifact from the local repository
需要将 ~/.m2/repository 中相应的jar包提前cp出来再进行deploy
使用Maven向Nexus 批量 upload jar 包
原脚本内容:
#!/bin/sh # Reference: http://roboojack.blogspot.in/2014/12/bulk-upload-your-local-maven-artifacts.html if [ "$#" -ne 3 ] || ! [ -d "$1" ]; then echo "Usage:" echo " bash run.sh <repoRootFolder> <repositoryId> <repositoryUrl>" echo "" echo "" echo " Where..." echo " repoRootFolder: The folder containing the repository tree." echo " Ensure you move the repository outside of ~/.m2 folder" echo " or whatever is configured in settings.xml" echo " repositoryId: The repositoryId from the <server> configured for the repositoryUrl in settings.xml." echo " Ensure that you have configured username and password in settings.xml." echo " repositoryUrl: The URL of the repository where you want to upload the files." exit 1 fi while read -r line ; do echo "Processing file $line" pomLocation=${line/./} pomLocation=$PWD${pomLocation/jar/pom} jarLocation=${line/./} jarLocation=$PWD${jarLocation/pom/jar} #echo $pomLocation #echo $jarLocation mvn deploy:deploy-file -DpomFile=$pomLocation -Dfile=$jarLocation -DrepositoryId=$2 -Durl=$3 done < <(find $1 -name "*.jar")
该脚本解析location似乎有问题,改了一下
#!/bin/sh # Reference: http://roboojack.blogspot.in/2014/12/bulk-upload-your-local-maven-artifacts.html if [ "$#" -ne 3 ] || ! [ -d "$1" ]; then echo "Usage:" echo " bash run.sh <repoRootFolder> <repositoryId> <repositoryUrl>" echo "" echo "" echo " Where..." echo " repoRootFolder: The folder containing the repository tree." echo " Ensure you move the repository outside of ~/.m2 folder" echo " or whatever is configured in settings.xml" echo " repositoryId: The repositoryId from the <server> configured for the repositoryUrl in settings.xml." echo " Ensure that you have configured username and password in settings.xml." echo " repositoryUrl: The URL of the repository where you want to upload the files." exit 1 fi while read -r line ; do echo "Processing file $line" Location=${line/.jar} pomLocation=${Location}.pom jarLocation=${Location}.jar echo $pomLocation echo $jarLocation mvn deploy:deploy-file -DpomFile=$pomLocation -Dfile=$jarLocation -DrepositoryId=$2 -Durl=$3 done < <(find $1 -name "*.jar")
使用命令 bash script.sh m2 <repositoryId> <repositoryUrl>