Created
June 22, 2017 04:11
-
-
Save CJHarmath/6360ef8ed714aae6ef170555e104b6e2 to your computer and use it in GitHub Desktop.
Setup-Forge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param( | |
[switch] | |
$Update | |
) | |
if ($update.IsPresent -and $Update){ | |
Write-Warning "running in update mode will not delete existing folders which might lead to issues" | |
} | |
else { | |
Write-Warning "Running in the default clean install mode. Slower but the safest option!" | |
} | |
try { | |
$localFolders = ".eclipse",".gradle",".p2",".tooling" | |
$homeDir = $env:userprofile | |
$localFolders | % { | |
if ($env:userprofile) { | |
$folder = join-path $env:userprofile $_ | |
} | |
else { | |
$homeDir = join-path c:\users $env:username | |
$folder = join-path $homeDir $_ | |
} | |
if (!$Update -and (test-path $folder)) { | |
write-output "cleaning up local cache folder $folder..." | |
remove-item -force -recurse $folder | |
} | |
} | |
$targetFolders = "eclipse","forge" | |
write-output "copying folders to user home..." | |
$targetFolders | % { | |
$targetPath = join-path $homeDir "documents\$_" | |
if (!$update -and ( test-path $targetPath) ){ | |
write-output "removing existing folder $targePath" | |
remove-item -force -recurse $targetPath | |
} | |
$srcPath = join-path $PSScriptRoot $_ | |
write-output "copying from $srcPath to $targetPath ..." | |
copy-item -container -path $srcPath -Destination $targetPath -recurse -force | |
cd $targetPath | |
# creating a shortcut for eclipse | |
if ($_.ToLower() -eq "eclipse") { | |
Write-Output "creating shortcut for eclipse" | |
$WshShell = New-Object -comObject WScript.Shell | |
$shortCutPath = "$Home\Desktop\eclipse.lnk" | |
if (test-path $shortCutPath) { Remove-Item $shortCutPath -Force } | |
$Shortcut = $WshShell.CreateShortcut($shortCutPath) | |
$Shortcut.TargetPath = "$targetPath\eclipse.exe" | |
$ShortCut.IconLocation = "$targetPath\eclipse.exe, 0" | |
$ShortCut.Description = "Eclipse" | |
$Shortcut.Save() | |
} | |
} | |
} | |
catch { | |
write-error "something went wrong! dang!" | |
write-error $_ | |
exit 1 | |
} | |
Write-Output "copy done! running gradle setup!" | |
.\gradlew.bat setupDecompWorkspace eclipse | |
Write-Output "setup completed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes that