Skip to content

Instantly share code, notes, and snippets.

@CJHarmath
Created June 22, 2017 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CJHarmath/6360ef8ed714aae6ef170555e104b6e2 to your computer and use it in GitHub Desktop.
Save CJHarmath/6360ef8ed714aae6ef170555e104b6e2 to your computer and use it in GitHub Desktop.
Setup-Forge
[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!"
@CJHarmath
Copy link
Author

This assumes that

  • the src folder has the eclipse and forge folders
  • the target folder is going to be under the user's documents folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment