forked from microsoftgraph/msgraph-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidatePackageContents.ps1
More file actions
59 lines (51 loc) · 1.92 KB
/
validatePackageContents.ps1
File metadata and controls
59 lines (51 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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",
[Parameter()][bool] $ValidateMavenMetadata = $true
)
$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 -and $ValidateMavenMetadata -eq $true) {
Write-Output "No maven-metadata*.xml files found in package."
exit 1
}
Write-Output "Package $ArtifactId is valid."
Write-Output "---------------------------------------------------"
exit 0