29 lines
1.0 KiB
PowerShell
29 lines
1.0 KiB
PowerShell
$ErrorActionPreference = 'Continue'
|
|
$candidates = @(
|
|
'E:\wwwroot\tools\apache-maven-3.9.9\bin\mvn.cmd',
|
|
'C:\yutongda\tools\apache-maven-3.9.9\bin\mvn.cmd',
|
|
'C:\Program Files\Apache\maven\bin\mvn.cmd'
|
|
)
|
|
foreach ($c in $candidates) {
|
|
if (Test-Path $c) {
|
|
Write-Host "FOUND=$c"
|
|
& $c -v
|
|
exit 0
|
|
}
|
|
}
|
|
Write-Host 'NO_LOCAL_MAVEN'
|
|
# install under E:\wwwroot\tools
|
|
$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-Host "FOUND=$mvnCmd"; & $mvnCmd -v; exit 0 }
|
|
$zip = Join-Path $tools 'apache-maven-3.9.9-bin.zip'
|
|
$url2 = 'https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip'
|
|
Write-Host 'downloading maven on remote...'
|
|
Invoke-WebRequest -Uri $url2 -OutFile $zip -UseBasicParsing
|
|
Expand-Archive -Path $zip -DestinationPath $tools -Force
|
|
if (-not (Test-Path $mvnCmd)) { throw 'maven extract failed' }
|
|
Write-Host "FOUND=$mvnCmd"
|
|
& $mvnCmd -v
|