# Usage invoke-mave "maven command" "relative path from the script"
function invoke-maven {
param(
$command,
$RELATIVE_PATH
)
Write-Host "***"
Write-Host "*** Running: $command"
Write-Host "***"
$LOCATION = Get-Location
Set-Location "$LOCATION$RELATIVE_PATH"
$SUCCESS = $false
Invoke-Expression "$command" | foreach {
Write-Host $_
if($_.Contains("BUILD SUCCESS")){
$SUCCESS = $true
}
}
Set-Location "$LOCATION"
if( -not $SUCCESS){
Write-Host "***"
Write-Host "*** Build failure for: '$command'"
Write-Host "***"
exit
}
}
invoke-maven "mvn install" "/my-lib"
invoke-maven "mvn -Psomeprofile install" "/my-client"
invoke-maven "mvn install" "/my-server"
Monday, August 23, 2010
Maven and Powershell
So i have recently started working with powershell and i have created a script that lets me build multiple maven targets. If you have multiple maven projects that are dependent on each other you probably whant to build them all at once. Here maven doesn't help you because it doesn't act outside its own project. So i built this script that runs maven on multiple projects and halts if one of them fails. Because maven doesn't return correct error code i had to scan the output from maven and look for "BUILD SUCCESS" to know if the build was successfull.
Feel free to use it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment