-
Notifications
You must be signed in to change notification settings - Fork 68
/
install_maven.ps1
32 lines (23 loc) · 1018 Bytes
/
install_maven.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Write-Host "Installing Apache Maven 3.8.3 ..." -ForegroundColor Cyan
$apachePath = "${env:ProgramFiles(x86)}\Apache"
$mavenPath = "$apachePath\Maven"
if(Test-Path $mavenPath) {
Remove-Item $mavenPath -Recurse -Force
}
if(-not (Test-Path $apachePath)) {
New-Item $apachePath -ItemType directory -Force
}
Write-Host "Downloading..."
$zipPath = "$env:TEMP\apache-maven-3.8.3-bin.zip"
(New-Object Net.WebClient).DownloadFile('https://dlcdn.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip', $zipPath)
Write-Host "Unpacking..."
7z x $zipPath -oC:\apache-maven | Out-Null
[IO.Directory]::Move('C:\apache-maven\apache-maven-3.8.3', $mavenPath)
Remove-Item 'C:\apache-maven' -Recurse -Force
del $zipPath
[Environment]::SetEnvironmentVariable("M2_HOME", $mavenPath, "Machine")
[Environment]::SetEnvironmentVariable("MAVEN_HOME", $mavenPath, "Machine")
Add-Path "$mavenPath\bin"
Add-SessionPath "$mavenPath\bin"
mvn --version
Write-Host "Apache Maven 3.8.1 installed" -ForegroundColor Green