Skip to content

Instantly share code, notes, and snippets.

@projected1
Created January 18, 2021 12:56
Show Gist options
  • Save projected1/789cff9fccdbc8f956a03c0f42d1db58 to your computer and use it in GitHub Desktop.
Save projected1/789cff9fccdbc8f956a03c0f42d1db58 to your computer and use it in GitHub Desktop.
Deployes artifacts to Sonatype Nexus using Maven.
@rem ------------------------------------------------------
@rem Usage:
@rem nexus_mvn_deploy.bat <groupId> <artifactId> <version> <path/to/file> <path/to/maven_settings>
@rem
@rem ------------------------------------------------------
@echo off
setlocal
if "%1" == "" (
echo Group ID is missing and it's not optional
goto usage
)
if "%2" == "" (
echo Artifact ID is missing and it's not optional
goto usage
)
if "%3" == "" (
echo Version is missing and it's not optional
goto usage
)
if "%4" == "" (
echo File is missing and it's not optional
goto usage
)
if not exist %4 (
echo Failed to locate input file : %4
goto end
)
if not exist %5 (
echo Failed to locate Maven setting file: %5
goto end
)
if not "%6" == "" (
goto usage
)
set GROUP_ID=%1
set ARTIFACT_ID=%2
set VERSION=%3
set FILE=%4
set SETTINGS=%5
@rem TODO Replace with you own Nexus server host
set NEXUS_HOST=http://255.0.0.1:8081
mvn.cmd deploy:deploy-file -s %SETTINGS% -DgroupId=%GROUP_ID% -DartifactId=%ARTIFACT_ID% -Dversion=%VERSION% -Dpackaging=jar -Dfile=%FILE% -DrepositoryId=nexus -Durl=%NEXUS_HOST%/nexus/repository/thirdparty
:usage
echo %~nx0 ^<groupId^> ^<artifactId^> ^<version^> ^<path/to/file^> ^<path/to/maven_settings^>
:end
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment