Skip to content

Commit cec054a

Browse files
committed
Add package content validation script
1 parent 42d9a0b commit cec054a

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Checks that expected files are present & have contents after the publish process to the local cache
2+
param(
3+
[Parameter(Mandatory=$true)][string] $ArtifactId,
4+
[Parameter(Mandatory=$true)][string] $Version,
5+
[Parameter()][string] $GroupId = "com.microsoft.graph",
6+
[Parameter()][string] $MavenLocalCachePath = "~" + [System.IO.Path]::DirectorySeparatorChar + ".m2" + [System.IO.Path]::DirectorySeparatorChar + "repository"
7+
)
8+
9+
$groupIdPath = $GroupId -replace "\.", [System.IO.Path]::DirectorySeparatorChar
10+
$packagePath = Join-Path -Path $groupIdPath -ChildPath $ArtifactId
11+
$packageFullPath = Join-Path -Path $MavenLocalCachePath -ChildPath $packagePath -AdditionalChildPath $Version
12+
13+
Write-Output "---------------------------------------------------"
14+
Write-Output "Validating package contents at $packageFullPath"
15+
16+
if(-not (Test-Path -Path $packageFullPath)) {
17+
Write-Output "Package not found in local cache."
18+
exit 1
19+
}
20+
21+
Write-Output "Package exists in local cache."
22+
23+
$expectedFiles = @(
24+
"-javadoc.jar",
25+
"-javadoc.jar.asc",
26+
"-sources.jar",
27+
"-sources.jar.asc",
28+
".module",
29+
".module.asc",
30+
".pom",
31+
".pom.asc",
32+
".jar",
33+
".jar.asc"
34+
)
35+
36+
foreach($file in $expectedFiles) {
37+
$file = $ArtifactId + "-" + $Version + $file
38+
$filePath = Join-Path -Path $packageFullPath -ChildPath $file
39+
if(-not (Test-Path -Path $filePath)) {
40+
Write-Output "Expected file $file not found in package."
41+
exit 1
42+
}
43+
$fileSize = (Get-Item -Path $filePath).length
44+
if($fileSize -eq 0) {
45+
Write-Output "File $file is empty."
46+
exit 1
47+
}
48+
}
49+
50+
$mavenMetadataFiles = Get-ChildItem -Path $packageFullPath -Filter "maven-metadata*.xml"
51+
if($mavenMetadataFiles.Count -eq 0) {
52+
Write-Output "No maven-metadata*.xml files found in package."
53+
exit 1
54+
}
55+
56+
Write-Output "Package $ArtifactId is valid."
57+
Write-Output "---------------------------------------------------"
58+
exit 0

0 commit comments

Comments
 (0)