Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

bash - Speed-up maven-deploy-plugin:deploy-file by comparing timestamps

I have a Maven project which depends on a large number of Ant projects, amongst others. I deploy all local jars possible of these dependencies into a single maven repo with this Bash script:

set -e
while IFS= read -r jarPath; do 
    mvn deploy:deploy-file -Dfile="$file" -DgroupId=${groupId} -DartifactId=$(basename "$jarPath") -Dversion=${version} -Dpackaging=jar -Durl=file:./repo/ -DrepositoryId=repo -DupdateReleaseInfo=true 
;done < list.txt
set +e

The script is executed every time these dependencies are rebuilt. The problem is, it takes together minutes of execution time for these effectively tenths of mvn deploy:deploy-file commands, even if normally there are only few jars or none which require an update.

Can Maven deploy only files with newer file stamps? I cannot see a relevant option in its docs. If there is no such possibility, can the analogous condition be implemented in the script as some Bash condition?

Each jar named ${jarPath} ends up as ./repo/${groupId with each '.' replaced by '/'}/${file}/${version}/${file}-${version}.jar where $file=$(basename "$jarPath") is a filename with the extension .jar. It contains only basic ASCII letters, digits, '-' and '.'. No special characters like spaces.

question from:https://stackoverflow.com/questions/65927920/speed-up-maven-deploy-plugindeploy-file-by-comparing-timestamps

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
GROUP=some.group.id
VERSION=0.0.1
REPO=repo

set -e
while IFS= read -r jarPath; do 
        F=$(basename "$jarPath")
        P=./${REPO}/$(echo ${GROUP} | tr '.' '/')/${F}/${VERSION}/${F}-${VERSION}.jar
        [ "$jarPath" -nt ${P} ] && mvn deploy:deploy-file -Dfile="$jarPath" -DgroupId=${GROUP} -DartifactId=${F} 
done < list.txt
set +e

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...