bat自动上传Maven jar包

Bat 自动上传Maven jar包

批处理相关处理

setlocalenabledelayedexpansion变量延迟

 

@echo off

set a=4

set a=5&echo !a!

pause

结果为4

 

@echo off

setlocal enabledelayedexpansion

set a=4

set a=5&echo !a!

pause

结果为5

 

例子:

setlocal EnableDelayedExpansion

for %%i in (*.jar) do (                 //遍历文件夹以.jar结尾的

set name=%%i                            //name赋值为filename

set jarName=!name:.jar=!      //jarName为去除.jar的string

echo !jarName!                           //输出

)

Pause//等待

 

set /p channelName=                //接收输入的数据,赋值给channelName

echo !channelName!                 //输出

 

 

setlocal EnableDelayedExpansion

set /p channelName=      //输入channelName

set /p version=                   //输入版本号

set path=%cd%               //获取当前目录路径

for %%i in (*.jar) do (

set name=%%i

set jarName=!name:.jar=!

set fileNamePath=!path!\!name!            //拼接全路径.jar

set fileNamePath=!fileNamePath: =!

echo !channelName!

echo !version!

echo !name!

echo !jarName!

echo !path!

echo !fileNamePath!

//执行mvn上传

E:\mytools\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin\mvndeploy:deploy-file -DgroupId=cn.gyyx.sdk.!channelName! -DartifactId=!jarName!-Dversion=!version! -Dpackaging=jar -Dfile=!fileNamePath!-Durl=http://192.168.6.182/content/repositories/AndroidMaven/-DrepositoryId=AndroidMaven

)

Pause

添加文本文件

 -----------------

echo^^cn.gyyx.sdk.%channelName%^^%%~ni^^%version%^^>>1.txt

 

Echo %name%>>1.txt变量name的值追加到1.txt中

^< 特殊字符转义文本中<

Maven相关配置

1.下载Maven

2.配置环境变量

MAVEN_HOME

E:\mytools\apache-maven-3.3.9-bin\apache-maven-3.3.9

Path

;%MAVEN_HOME%\bin

3.cmd执行mvn –v即可测试maven是否配置完毕。


bat文件命令

setlocal EnableDelayedExpansion
set /p channelName=
set /p version=
for %%i in (*.jar) do (
set name=%%i
set jarName=!name:.jar=!
E:\mytools\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin\mvn deploy:deploy-file -DgroupId=cn.gyyx.sdk.%channelName% -DartifactId=%%~ni -Dversion=%version% -Dpackaging=jar -Dfile=%cd%\%%i -Durl=http://192.168.6.182/content/repositories/AndroidMaven/ -DrepositoryId=AndroidMaven
echo ^^cn.gyyx.sdk.%channelName%^^%%~ni^^%version%^^>>1.txt
)
pause

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