forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use powershell script to flatten ESRP release folder (Azure#35093)
* Use powershell script to flatten ESRP release folder * Skip maven-metadata.xml.* files when flattening ESRP package folders
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#Requires -Version 7 | ||
param( | ||
[Parameter(Mandatory=$true)][string]$Path | ||
) | ||
|
||
Set-StrictMode -Version 2.0 | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$files = Get-ChildItem -Path $Path -Recurse -File -Force -ErrorAction Stop | ||
|
||
$paths = @{} | ||
|
||
foreach($file in $files) { | ||
$name = $file.Name | ||
|
||
# Skip maven-metadata.xml files. These are generated for each package and are not needed by ESRP. | ||
if($name -match "^maven-metadata\.xml(\..*)?$") { | ||
continue | ||
} | ||
|
||
if($paths.Keys -contains $name) { | ||
Write-Error "Duplicate file name: $name`n $($paths[$name]) and $($file.FullName)" | ||
Write-Error "Unable to flatten: $Path" | ||
exit 1 | ||
} | ||
|
||
$paths[$name] = $file.FullName | ||
} | ||
|
||
# Move the files to the root of the directory. | ||
foreach($name in $paths.Keys) { | ||
$oldPath = $paths[$name] | ||
$newPath = Join-Path -Path $Path -ChildPath $name | ||
Move-Item -Path $oldPath -Destination $newPath -Force -ErrorAction Stop | ||
} | ||
|
||
$dirs = Get-ChildItem -Path $Path -Directory -Force -ErrorAction Stop | ||
|
||
# Remove all child directories. | ||
foreach($dir in $dirs) { | ||
Remove-Item $dir.FullName -Force -Recurse -ErrorAction Stop | ||
} | ||
|
||
exit 0 |