-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add package content validation script
- Loading branch information
Showing
1 changed file
with
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Checks that expected files are present & have contents after the publish process to the local cache | ||
param( | ||
[Parameter(Mandatory=$true)][string] $ArtifactId, | ||
[Parameter(Mandatory=$true)][string] $Version, | ||
[Parameter()][string] $GroupId = "com.microsoft.graph", | ||
[Parameter()][string] $MavenLocalCachePath = "~" + [System.IO.Path]::DirectorySeparatorChar + ".m2" + [System.IO.Path]::DirectorySeparatorChar + "repository" | ||
) | ||
|
||
$groupIdPath = $GroupId -replace "\.", [System.IO.Path]::DirectorySeparatorChar | ||
$packagePath = Join-Path -Path $groupIdPath -ChildPath $ArtifactId | ||
$packageFullPath = Join-Path -Path $MavenLocalCachePath -ChildPath $packagePath -AdditionalChildPath $Version | ||
|
||
Write-Output "---------------------------------------------------" | ||
Write-Output "Validating package contents at $packageFullPath" | ||
|
||
if(-not (Test-Path -Path $packageFullPath)) { | ||
Write-Output "Package not found in local cache." | ||
exit 1 | ||
} | ||
|
||
Write-Output "Package exists in local cache." | ||
|
||
$expectedFiles = @( | ||
"-javadoc.jar", | ||
"-javadoc.jar.asc", | ||
"-sources.jar", | ||
"-sources.jar.asc", | ||
".module", | ||
".module.asc", | ||
".pom", | ||
".pom.asc", | ||
".jar", | ||
".jar.asc" | ||
) | ||
|
||
foreach($file in $expectedFiles) { | ||
$file = $ArtifactId + "-" + $Version + $file | ||
$filePath = Join-Path -Path $packageFullPath -ChildPath $file | ||
if(-not (Test-Path -Path $filePath)) { | ||
Write-Output "Expected file $file not found in package." | ||
exit 1 | ||
} | ||
$fileSize = (Get-Item -Path $filePath).length | ||
if($fileSize -eq 0) { | ||
Write-Output "File $file is empty." | ||
exit 1 | ||
} | ||
} | ||
|
||
$mavenMetadataFiles = Get-ChildItem -Path $packageFullPath -Filter "maven-metadata*.xml" | ||
if($mavenMetadataFiles.Count -eq 0) { | ||
Write-Output "No maven-metadata*.xml files found in package." | ||
exit 1 | ||
} | ||
|
||
Write-Output "Package $ArtifactId is valid." | ||
Write-Output "---------------------------------------------------" | ||
exit 0 |