Skip to content

Commit fe7e43e

Browse files
authored
Docs onboarding v2 (Azure#36383)
* Add v2 docs onboarding for Java * Add onboarding logic for onboarding v2 * Set skipPublishDocMs for packages that are skipped in Language-Settings.ps1 and should not publish docs. * Ignore errors removing path that doesn't exist (ensure that test runs on local machine are clean, it's OK if files aren't present to clean up. * Revert "Set skipPublishDocMs for packages that are skipped in Language-Settings.ps1 and should not publish docs." This reverts commit d383cad.
1 parent b6e5ed1 commit fe7e43e

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

eng/scripts/Language-Settings.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $GithubUri = "https://github.com/Azure/azure-sdk-for-java"
99
$PackageRepositoryUri = "https://repo1.maven.org/maven2"
1010

1111
. "$PSScriptRoot/docs/Docs-ToC.ps1"
12+
. "$PSScriptRoot/docs/Docs-Onboarding.ps1"
1213

1314
function Get-java-PackageInfoFromRepo ($pkgPath, $serviceDirectory)
1415
{
@@ -315,6 +316,12 @@ function SourcePackageHasComFolder($artifactNamePrefix, $packageDirectory) {
315316

316317
$sourcesJarPath = (Get-ChildItem -File -Path $packageDirectory -Filter "*-sources.jar")[0]
317318
$sourcesExtractPath = Join-Path $packageDirectory "sources"
319+
320+
# Ensure that the sources folder is empty before extracting the jar
321+
# otherwise there could be file collisions from a previous extraction run on
322+
# the same system.
323+
Remove-Item $sourcesExtractPath/* -Force -Recurse -ErrorAction Ignore
324+
318325
Add-Type -AssemblyName System.IO.Compression.FileSystem
319326
[System.IO.Compression.ZipFile]::ExtractToDirectory($sourcesJarPath, $sourcesExtractPath)
320327

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#$SetDocsPackageOnboarding = "Set-${Language}-DocsPackageOnboarding"
2+
function Set-java-DocsPackageOnboarding($moniker, $metadata, $docRepoLocation, $packageSourceOverride) {
3+
4+
# Do not write onboarding information for legacy moniker
5+
# TODO: remove this once legacy moniker is properly configured
6+
if ($moniker -eq 'legacy') {
7+
return
8+
}
9+
10+
$packageJsonPath = Join-Path $docRepoLocation "package.json"
11+
$onboardingInfo = Get-Content $packageJsonPath | ConvertFrom-Json
12+
13+
$monikerOutputPath = "docs-ref-autogen"
14+
if ($moniker -ne 'latest') {
15+
$monikerOutputPath = "$moniker/docs-ref-autogen"
16+
}
17+
$monikerIndex = -1
18+
for($i = 0; $i -lt $onboardingInfo.Count; $i++) {
19+
if ($onboardingInfo[$i].output_path -eq $monikerOutputPath) {
20+
$monikerIndex = $i
21+
break
22+
}
23+
}
24+
25+
if ($monikerIndex -eq -1) {
26+
Write-Error "No appropriate index for moniker $moniker"
27+
}
28+
29+
$onboardedPackages = @()
30+
foreach ($package in $metadata) {
31+
$packageInfo = [ordered]@{
32+
packageArtifactId = $package.Name
33+
packageGroupId = $package.Group
34+
packageVersion = $package.Version
35+
36+
# packageDownloadUrl is required by docs build and other values are
37+
# rejected. This is a temporary workaround until the docs build
38+
# supports more package stores.
39+
packageDownloadUrl = 'https://repo1.maven.org/maven2'
40+
}
41+
42+
# Add items from 'DocsCiConfigProperties' into onboarding info. If a
43+
# property already exists, it will be overwritten.
44+
if ($package.ContainsKey('DocsCiConfigProperties')) {
45+
foreach ($key in $package['DocsCiConfigProperties'].Keys) {
46+
$packageInfo[$key] = $package['DocsCiConfigProperties'][$key]
47+
}
48+
}
49+
50+
$onboardedPackages += $packageInfo
51+
}
52+
53+
$onboardingInfo[$monikerIndex].packages = $onboardedPackages
54+
55+
Set-Content -Path $packageJsonPath -Value (ConvertTo-Json -InputObject $onboardingInfo -Depth 100)
56+
}
57+
58+
#$GetDocsPackagesAlreadyOnboarded = "Get-${Language}-DocsPackagesAlreadyOnboarded"
59+
function Get-java-DocsPackagesAlreadyOnboarded($docRepoLocation, $moniker) {
60+
return Get-java-OnboardedDocsMsPackagesForMoniker $docRepoLocation $moniker
61+
}
62+
63+
# $GetPackageIdentity = "Get-${Language}-PackageIdentity"
64+
function Get-java-PackageIdentity($package) {
65+
return "$($package['Group']):$($package['Name'])"
66+
}

eng/scripts/docs/Docs-ToC.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function Get-java-OnboardedDocsMsPackagesForMoniker ($DocRepoLocation, $moniker)
1919
elseif("latest" -eq $moniker) {
2020
$onboardingSpec = $onboardingSpec | Where-Object { $_.output_path -eq "docs-ref-autogen" }
2121
}
22+
23+
# TODO: Add support for "legacy" moniker
24+
2225
$onboardedPackages = @{}
2326
foreach ($spec in $onboardingSpec.packages) {
2427
$packageName = $spec.packageArtifactId
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Import-Module Pester
2+
3+
BeforeAll {
4+
. $PSScriptRoot/../Docs-Onboarding.ps1
5+
}
6+
7+
Describe 'Get-java-PackageIdentity' {
8+
It 'should return the package identity' {
9+
$package = [ordered]@{
10+
Name = 'packageName'
11+
Group = 'packageGroup'
12+
}
13+
14+
$packageIdentity = Get-java-PackageIdentity $package
15+
$packageIdentity | Should -Be 'packageGroup:packageName'
16+
}
17+
}

0 commit comments

Comments
 (0)