Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Update-java-CIConfig #17631

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,47 @@ function Get-java-GithubIoDocIndex() {
# Generate yml/md toc files and build site.
GenerateDocfxTocContent -tocContent $tocContent -lang "Java"
}

# a "package.json configures target packages for all the monikers in a Repository, it also has a slightly different
# schema than the moniker-specific json config that is seen in python and js
function Update-java-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null){
$pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo)

if (-not (Test-Path $pkgJsonLoc)) {
Write-Error "Unable to locate package json at location $pkgJsonLoc, exiting."
exit(1)
}

$allJsonData = Get-Content $pkgJsonLoc | ConvertFrom-Json

$visibleInCI = @{}

for ($i=0; $i -lt $allJsonData[$monikerId].packages.Length; $i++) {
$pkgDef = $allJsonData[$monikerId].packages[$i]
$visibleInCI[$pkgDef.packageArtifactId] = $i
}

foreach ($releasingPkg in $pkgs) {
if ($visibleInCI.ContainsKey($releasingPkg.PackageId)) {
$packagesIndex = $visibleInCI[$releasingPkg.PackageId]
$existingPackageDef = $allJsonData[$monikerId].packages[$packagesIndex]
$existingPackageDef.packageVersion = $releasingPkg.PackageVersion
}
else {
$newItem = New-Object PSObject -Property @{
packageDownloadUrl = "https://repo1.maven.org/maven2"
packageGroupId = $releasingPkg.GroupId
packageArtifactId = $releasingPkg.PackageId
packageVersion = $releasingPkg.PackageVersion
inputPath = @()
excludePath = @()
}

$allJsonData[$monikerId].packages += $newItem
}
}

$jsonContent = $allJsonData | ConvertTo-Json -Depth 10 | % {$_ -replace "(?m) (?<=^(?: )*)", " " }

Set-Content -Path $pkgJsonLoc -Value $jsonContent
}