Files
inquiry_robot/deploy/_remote_install_maven.ps1
T

28 lines
1010 B
PowerShell

# Install portable Maven under E:\wwwroot\tools if missing.
$ErrorActionPreference = "Stop"
$tools = "E:\wwwroot\tools"
New-Item -ItemType Directory -Force -Path $tools | Out-Null
$mvnHome = Join-Path $tools "apache-maven-3.9.9"
$mvnCmd = Join-Path $mvnHome "bin\mvn.cmd"
if (Test-Path $mvnCmd) {
Write-Output ("maven_exists=" + $mvnHome)
& $mvnCmd -v
exit 0
}
$zip = Join-Path $tools "apache-maven-3.9.9-bin.zip"
$url = "https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip"
# fallback archive
$url2 = "https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip"
Write-Output "downloading maven..."
try {
Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing
} catch {
Write-Output "primary failed, try archive..."
Invoke-WebRequest -Uri $url2 -OutFile $zip -UseBasicParsing
}
Expand-Archive -Path $zip -DestinationPath $tools -Force
if (-not (Test-Path $mvnCmd)) { throw "maven extract failed" }
Write-Output "MAVEN_OK"
& $mvnCmd -v