-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathLanguage-Settings.ps1
564 lines (510 loc) · 23.7 KB
/
Language-Settings.ps1
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
$Language = "java"
$LanguageDisplayName = "Java"
$PackageRepository = "Maven"
$packagePattern = "*.pom"
$MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/main/_data/releases/latest/java-packages.csv"
$CampaignTag = Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "../repo-docs/ga_tag.html")
$GithubUri = "https://github.com/Azure/azure-sdk-for-java"
$PackageRepositoryUri = "https://repo1.maven.org/maven2"
. "$PSScriptRoot/docs/Docs-ToC.ps1"
. "$PSScriptRoot/docs/Docs-Onboarding.ps1"
# When getting all of the package properties, if Get-AllPackageInfoFromRepo exists
# then it's called instead of Get-PkgPropsForEntireService.
function Get-AllPackageInfoFromRepo([string]$serviceDirectory = $null) {
$SdkType = $Env:SdkType
if ($SdkType) {
Write-Host "SdkType env var was set to '$SdkType'"
} else {
$SdkType = "client"
Write-Host "SdkType env var was not set, default to 'client'"
}
Write-Host "Processing SdkType=$SdkType"
$allPackageProps = @()
$sdkRoot = Join-Path $RepoRoot "sdk"
$ymlFiles = @()
if ($serviceDirectory) {
$searchPath = Join-Path $sdkRoot $serviceDirectory
Write-Host "searchPath=$searchPath"
[array]$ymlFiles = Get-ChildItem -Path $searchPath "ci*.yml" | Where-Object { $_.PSIsContainer -eq $false}
} else {
# The reason for the exclude folders are POM only releases (nothing is built) or
# the service directory sits outside of the engineering system
# 1. boms - BOMs are POM only releases. Also, their versions aren't version controlled.
# 2. parents - parents are POM only releases which are version controlled
# 3. resourcemanagerhybrid - intermediate version of resourcemanager that was
# a one time release which sits outside of the engineering system
$excludeFolders = "boms", "resourcemanagerhybrid", "parents"
[array]$ymlFiles = Get-ChildItem -Path $sdkRoot -Include "ci*.yml" -Recurse -Depth 3 | Where-Object { $_.PSIsContainer -eq $false -and $_.DirectoryName -notmatch ($excludeFolders -join "|") }
}
foreach ($ymlFile in $ymlFiles)
{
# For each yml file do the following:
# 1. Load the yml file.
# 2. Get the Artifacts and AdditionalModules for the yml file.
# 3. Get the path to the yml
# 4. From the path in #1, recursively get a list of all pom.xml with depth 1. This
# will take care of the cases where the pom.xml is sitting next to the ci.yml, in
# the case where the ci.yml is in the sdk/<ServiceDirectory>/<LibraryDirectory>,
# as well as the case where the ci.yml is in the sdk/<ServiceDirectory>
# 5. For each pom file, check and see if its group:artifact matches a name/groupId in
# the ci.yml's Artifacts list.
# 6a. If #5 has a match, create the PackageProp and add it to the list
# 6b. If #5 doesn't have a match, then skip it. This is the case where it's either
# an AdditionalModule or something from another track.
Write-Host "Processing $ymlFile"
$ymlFileContent = LoadFrom-Yaml $ymlFile
$YmlFileSdkType = GetValueSafelyFrom-Yaml $ymlFileContent @("extends", "parameters", "SDKType")
$ymlDir = Split-Path -Path $ymlFile -Parent
# the default, if not set in the yml file, is client
if (-not $YmlFileSdkType) {
$YmlFileSdkType = "client"
}
if ($YmlFileSdkType -ne $SdkType) {
Write-Host "SdkType in yml file is '$YmlFileSdkType' which is not '$SdkType', skipping..."
continue
}
# ServiceDirectory
$serviceDirFromYml = GetValueSafelyFrom-Yaml $ymlFileContent @("extends", "parameters", "ServiceDirectory")
if (-not $serviceDirFromYml) {
# Log the error and skip this yml file here if there's no ServiceDirectory entry
LogWarning "$ymlFile does not have a ServiceDirectory entry, skipping..."
continue
}
else {
# If the serviceDirectory parameter was passed in, ensure that the ServiceDirectory
# entry in the ci*.yml file matches the one passed in.
if ($serviceDirectory) {
if ($serviceDirectory -ne $serviceDirFromYml) {
LogWarning "$ymlFile's ServiceDirectory entry does not match the serviceDirectory parameter: '$serviceDirectory'"
}
}
# Check whether or not the yml's serviceDirectory matches the actual path of
# the yml file relative to the sdkRoot
# Note: Need to strip off the directory seperator character which is based upon the OS
$computedServiceDirectory = $ymlDir.Replace($sdkRoot + [System.IO.Path]::DirectorySeparatorChar, "")
# .Replace and -replace have different behaviors. .Replace will not replace a backslash meaning
# that "foo\bar".Replace("\\","/") would result in foo\bar instead of foo/bar which is why
# -replace needs to be used
$computedServiceDirectory = $computedServiceDirectory -replace "\\", "/"
if ($serviceDirFromYml -ne $computedServiceDirectory) {
LogWarning "$ymlFile error: ServiceDirectory in the yml file, '$serviceDirFromYml' doesn't match the path relative from the sdkRoot '$computedServiceDirectory'"
}
}
# At this point the SdkType is correct.
# 1. Create a hash set from the list of artifact for this service directory, for
# the SdkType. This is done to ensure that only PackageInfo files are created
# for the correct set of Artifacts
# 2. Save off AdditionalModules to add to the AdditionalValidationPackages entry
$ArtifactsHashSet = New-Object 'System.Collections.Generic.HashSet[String]'
$artifacts = GetValueSafelyFrom-Yaml $ymlFileContent @("extends", "parameters", "Artifacts")
$additionalModules = GetValueSafelyFrom-Yaml $ymlFileContent @("extends", "parameters", "AdditionalModules")
foreach ($artifact in $artifacts)
{
$hashKey = "$($artifact.groupId):$($artifact.name)"
if (-not $ArtifactsHashSet.Add($hashKey)) {
LogWarning "ymlFile: $ymlFile contains a duplicate artifact $hashKey"
}
}
# Grab all the pom files in the yml file's directory and subdirectory depth of 1
# because they're either going to be in the same directory as the yml files or 1
# level lower. The repository can have sdk/SD1/ci.yml and sdk/SD1/Lib1/ci.yml files
# each processing more different Artifacts and this is the reason that the ArtifactsHash
# is necessary to verify.
# Note: depth of 0 is the current directory, depth of 1 is current and the first level
# of subdirectories. In the case where we have a ci.yml file for a single library the
# library's pom file will sit next to yml file. In the case where the ci*.yml file is in
# the root of the service directory, the pom files should be the immediate subdirectories.
[array]$pomFiles = Get-ChildItem -Path $ymlDir -Recurse -Depth 1 -File -Filter "pom.xml"
foreach ($pomFile in $pomFiles) {
$xmlPomFile = New-Object xml
$xmlPomFile.Load($pomFile)
if ($xmlPomFile.project.psobject.properties.name -notcontains "artifactId" -or !$xmlPomFile.project.artifactId) {
Write-Host "$pomFile doesn't have a defined artifactId so skipping this pom."
continue
}
if ($xmlPomFile.project.psobject.properties.name -notcontains "version" -or !$xmlPomFile.project.version) {
Write-Host "$pomFile doesn't have a defined version so skipping this pom."
continue
}
if ($xmlPomFile.project.psobject.properties.name -notcontains "groupid" -or !$xmlPomFile.project.groupId) {
Write-Host "$pomFile doesn't have a defined groupId so skipping this pom."
continue
}
# The case where ArtifactsHashSet won't contain the key from the pom.xml file is when
# the pom file being processed is one of the intermediate poms in the hierarchy. An
# example would be sdk/core/pom.xml which just contains the module listings
$keyFromPom = "$($xmlPomFile.project.groupId):$($xmlPomFile.project.artifactId)"
if (-not $ArtifactsHashSet.Contains($keyFromPom))
{
Write-Host "$ymlFile does not contain $($xmlPomFile.project.groupId):$($xmlPomFile.project.artifactId), skipping"
continue
}
# At this point everything is valid
# 1. Create the packageProps
# 2. Set the SdkType
# 3. Set isNewSdk
# 4. Set the artifactName
# 5. Set AdditionalValidationPackages to the AdditionalModules from the yml file
$groupId = $xmlPomFile.project.groupId
$artifactId = $xmlPomFile.project.artifactId
$version = $xmlPomFile.project.version
$pomFileDir = Split-Path -Path $pomFile -Parent
$pkgProp = [PackageProps]::new($artifactId, $version.ToString(), $pomFileDir, $serviceDirFromYml, $groupId)
if ($artifactId -match "mgmt" -or $artifactId -match "resourcemanager")
{
$pkgProp.SdkType = "mgmt"
}
elseif ($artifactId -match "spring")
{
$pkgProp.SdkType = "spring"
}
else
{
$pkgProp.SdkType = "client"
}
$pkgProp.IsNewSdk = $False
if ($groupId) {
$pkgProp.IsNewSdk = $groupId.StartsWith("com.azure") -or $groupId.StartsWith("io.clientcore")
}
$pkgProp.ArtifactName = $artifactId
if ($additionalModules) {
# $additionalModules' type is System.Object[] where the objects are are
# hashtables containing two values, the name and the groupId. Create a
# list of the AdditionalModules and set the PackageProp.AdditionalValidationPackages
# to that list
$additionalModulesList = @()
foreach ($additionalModule in $additionalModules) {
$additionalModulesList += "$($additionalModule['groupId']):$($additionalModule['name'])"
}
$pkgProp.AdditionalValidationPackages = $additionalModulesList
}
$allPackageProps += $pkgProp
}
}
return $allPackageProps
}
# Returns the maven (really sonatype) publish status of a package id and version.
function IsMavenPackageVersionPublished($pkgId, $pkgVersion, $groupId)
{
$uri = "https://oss.sonatype.org/content/repositories/releases/$($groupId.Replace('.', '/'))/$pkgId/$pkgVersion/$pkgId-$pkgVersion.pom"
$attempt = 1
while ($attempt -le 3)
{
try
{
if ($attempt -gt 1) {
Start-Sleep -Seconds ([Math]::Pow(2, $attempt))
}
Write-Host "Checking published package at $uri"
$response = Invoke-WebRequest -Method "GET" -uri $uri -SkipHttpErrorCheck
if ($response.BaseResponse.IsSuccessStatusCode)
{
return $true
}
$statusCode = $response.StatusCode
if ($statusCode -eq 404)
{
return $false
}
Write-Host "Http request for maven package $groupId`:$pkgId`:$pkgVersion failed attempt $attempt with statuscode $statusCode"
}
catch
{
Write-Host "Http request for maven package $groupId`:$pkgId`:$pkgVersion failed attempt $attempt with exception $($_.Exception.Message)"
}
$attempt += 1
}
throw "Http request for maven package $groupId`:$pkgId`:$pkgVersion failed after 3 attempts"
}
# Parse out package publishing information given a maven POM file
function Get-java-PackageInfoFromPackageFile ($pkg, $workingDirectory)
{
[xml]$contentXML = Get-Content $pkg
$pkgId = $contentXML.project.artifactId
$docsReadMeName = $pkgId -replace "^azure-" , ""
$pkgVersion = $contentXML.project.version
$groupId = if ($null -eq $contentXML.project.groupId) { $contentXML.project.parent.groupId } else { $contentXML.project.groupId }
$releaseNotes = ""
$readmeContent = ""
# if it's a snapshot. return $null (as we don't want to create tags for this, but we also don't want to fail)
if ($pkgVersion.Contains("SNAPSHOT")) {
return $null
}
$changeLogLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-changelog.md")[0]
if ($changeLogLoc) {
$releaseNotes = Get-ChangeLogEntryAsString -ChangeLogLocation $changeLogLoc -VersionString $pkgVersion
}
$readmeContentLoc = @(Get-ChildItem -Path $pkg.DirectoryName -Recurse -Include "$($pkg.Basename)-readme.md")[0]
if ($readmeContentLoc) {
$readmeContent = Get-Content -Raw $readmeContentLoc
}
return New-Object PSObject -Property @{
PackageId = $pkgId
GroupId = $groupId
PackageVersion = $pkgVersion
ReleaseTag = "$($pkgId)_$($pkgVersion)"
Deployable = $forceCreate -or !(IsMavenPackageVersionPublished -pkgId $pkgId -pkgVersion $pkgVersion -groupId $groupId.Replace(".", "/"))
ReleaseNotes = $releaseNotes
ReadmeContent = $readmeContent
DocsReadMeName = $docsReadMeName
}
}
# Defined in common.ps1 as:
# $GetDocsMsDevLanguageSpecificPackageInfoFn = "Get-${Language}-DocsMsDevLanguageSpecificPackageInfo"
function Get-java-DocsMsDevLanguageSpecificPackageInfo($packageInfo, $packageSourceOverride) {
# If the default namespace isn't in the package info then it needs to be added
# Can't check if (!$packageInfo.Namespaces) in strict mode because Namespaces won't exist
# at all.
if (!($packageInfo | Get-Member Namespaces)) {
$version = $packageInfo.Version
# If the dev version is set, use that
if ($packageInfo.DevVersion) {
$version = $packageInfo.DevVersion
}
$namespaces = Fetch-Namespaces-From-Javadoc $packageInfo.Name $packageInfo.Group $version
# If there are namespaces found from the javadoc.jar then add them to the packageInfo which
# will later update the metadata json file in the docs repository. If there aren't any namespaces
# then don't add the namespaces member with an empty list. The reason being is that the
# UpdateDocsMsMetadataForPackage function will merge the packageInfo json and the metadata json
# files by taking any properties in the metadata json file that aren't in the packageInfo and add
# them from the metadata. This allows us to set the namespaces for things that can't be figured out
# through the javadoc, like track 1 libraries whose javadoc.jar files don't contain anything, in
# the metadata json files.
if ($namespaces.Count -gt 0) {
Write-Host "Get-java-DocsMsDevLanguageSpecificPackageInfo:adding namespaces property with the following namespaces:"
$namespaces | Write-Host
$packageInfo | Add-Member -Type NoteProperty -Name "Namespaces" -Value $namespaces
} else {
Write-Host "Get-java-DocsMsDevLanguageSpecificPackageInfo: no namespaces to add"
}
}
return $packageInfo
}
# Stage and Upload Docs to blob Storage
function Publish-java-GithubIODocs ($DocLocation, $PublicArtifactLocation)
{
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith("-javadoc.jar")}
foreach ($Item in $PublishedDocs)
{
$UnjarredDocumentationPath = ""
try
{
$PkgName = $Item.BaseName
# The jar's unpacking command doesn't allow specifying a target directory
# and will unjar all of the files in whatever the current directory is.
# Create a subdirectory to unjar into, set the location, unjar and then
# set the location back to its original location.
$UnjarredDocumentationPath = Join-Path -Path $DocLocation -ChildPath $PkgName
New-Item -ItemType directory -Path "$UnjarredDocumentationPath"
$CurrentLocation = Get-Location
Set-Location $UnjarredDocumentationPath
jar -xf "$($Item.FullName)"
Set-Location $CurrentLocation
# If javadocs are produced for a library with source, there will always be an
# index.html. If this file doesn't exist in the UnjarredDocumentationPath then
# this is a sourceless library which means there are no javadocs and nothing
# should be uploaded to blob storage.
$IndexHtml = Join-Path -Path $UnjarredDocumentationPath -ChildPath "index.html"
if (!(Test-Path -path $IndexHtml))
{
Write-Host "$($PkgName) does not have an index.html file, skipping."
continue
}
# Get the POM file for the artifact we're processing
$PomFile = $Item.FullName.Substring(0,$Item.FullName.LastIndexOf(("-javadoc.jar"))) + ".pom"
Write-Host "PomFile $($PomFile)"
# Pull the version from the POM
[xml]$PomXml = Get-Content $PomFile
$Version = $PomXml.project.version
$ArtifactId = $PomXml.project.artifactId
# inject the ga tag just before we upload the index to storage.
$indexContent = Get-Content -Path $IndexHtml -Raw
$tagContent = Get-Content -Path $CampaignTag -Raw
$indexContent = $indexContent.Replace("</head>", $tagContent + "</head>")
Set-Content -Path $IndexHtml -Value $indexContent -NoNewline
Write-Host "Start Upload for $($PkgName)/$($Version)"
Write-Host "DocDir $($UnjarredDocumentationPath)"
Write-Host "PkgName $($ArtifactId)"
Write-Host "DocVersion $($Version)"
$releaseTag = RetrieveReleaseTag $PublicArtifactLocation
Upload-Blobs -DocDir $UnjarredDocumentationPath -PkgName $ArtifactId -DocVersion $Version -ReleaseTag $releaseTag
}
Finally
{
if (![string]::IsNullOrEmpty($UnjarredDocumentationPath))
{
if (Test-Path -Path $UnjarredDocumentationPath)
{
Write-Host "Cleaning up $UnjarredDocumentationPath"
Remove-Item -Recurse -Force $UnjarredDocumentationPath
}
}
}
}
}
function Get-java-GithubIoDocIndex()
{
# Update the main.js and docfx.json language content
UpdateDocIndexFiles -appTitleLang "Java"
# Fetch out all package metadata from csv file.
$metadata = Get-CSVMetadata -MetadataUri $MetadataUri
# Leave the track 2 packages if multiple packages fetched out.
$clientPackages = $metadata | Where-Object { $_.GroupId -eq 'com.azure' }
$nonClientPackages = $metadata | Where-Object { $_.GroupId -ne 'com.azure' -and !$clientPackages.Package.Contains($_.Package) }
$uniquePackages = $clientPackages + $nonClientPackages
# Get the artifacts name from blob storage
$artifacts = Get-BlobStorage-Artifacts `
-blobDirectoryRegex "^java/(.*)/$" `
-blobArtifactsReplacement '$1' `
-storageAccountName 'azuresdkdocs' `
-storageContainerName '$web' `
-storagePrefix 'java/'
# Build up the artifact to service name mapping for GithubIo toc.
$tocContent = Get-TocMapping -metadata $uniquePackages -artifacts $artifacts
# Generate yml/md toc files and build site.
GenerateDocfxTocContent -tocContent $tocContent -lang "Java" -campaignId "UA-62780441-42"
}
# function is used to filter packages to submit to API view tool
function Find-java-Artifacts-For-Apireview($artifactDir, $pkgName)
{
# skip spark packages
if ($pkgName.Contains("-spark")) {
return $null
}
# skip azure-cosmos-test package because it needs to be releaesd
if ($pkgName.Contains("azure-cosmos-test")) {
return $null
}
# Find all source jar files in given artifact directory
# Filter for package in "com.azure*" groupid.
$artifactPath = Join-Path $artifactDir "com.azure*" $pkgName
Write-Host "Checking for source jar in artifact path $($artifactPath)"
$files = @(Get-ChildItem -Recurse "${artifactPath}" | Where-Object -FilterScript {$_.Name.EndsWith("sources.jar")})
if (!$files)
{
Write-Host "$($artifactPath) does not have any package"
return $null
}
elseif($files.Count -ne 1)
{
Write-Host "$($artifactPath) should contain only one (1) published source jar package"
Write-Host "No of Packages $($files.Count)"
return $null
}
$packages = @{
$files[0].Name = $files[0].FullName
}
return $packages
}
function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseDate, $ReplaceLatestEntryTitle=$true, $BuildType = "client", $GroupId = "com.azure", $PackageProperties)
{
if ($PackageProperties)
{
$GroupId = $PackageProperties.Group
if ($PackageProperties.SdkType -eq "client")
{
if ($PackageProperties.IsNewSDK) {
$BuildType = "client"
}
else {
$BuildType = "data"
}
}
}
if($null -eq $ReleaseDate)
{
$ReleaseDate = Get-Date -Format "yyyy-MM-dd"
}
$fullLibraryName = $GroupId + ":" + $PackageName
python "$EngDir/versioning/set_versions.py" --build-type $BuildType --new-version $Version --ai $PackageName --gi $GroupId
# -ll option says "only update README and CHANGELOG entries for libraries that are on the list"
python "$EngDir/versioning/update_versions.py" --update-type library --build-type $BuildType --ll $fullLibraryName
& "$EngCommonScriptsDir/Update-ChangeLog.ps1" -Version $Version -ServiceDirectory $ServiceDirectory -PackageName $PackageName `
-Unreleased $False -ReplaceLatestEntryTitle $ReplaceLatestEntryTitle -ReleaseDate $ReleaseDate
}
function GetExistingPackageVersions ($PackageName, $GroupId=$null)
{
try {
$Uri = 'https://search.maven.org/solrsearch/select?q=g:"' + $GroupId + '"+AND+a:"' + $PackageName +'"&core=gav&rows=20&wt=json'
$response = (Invoke-RestMethod -Method GET -Uri $Uri).response
if($response.numFound -ne 0)
{
$existingVersion = $response.docs.v
if ($existingVersion.Count -gt 0)
{
[Array]::Reverse($existingVersion)
return $existingVersion
}
}
return $null
}
catch {
LogError "Failed to retrieve package versions for ${PackageName}. $($_.Exception.Message)"
return $null
}
}
# Defined in common.ps1
# $GetDocsMsMetadataForPackageFn = "Get-${Language}-DocsMsMetadataForPackage"
function Get-java-DocsMsMetadataForPackage($PackageInfo) {
$readmeName = $PackageInfo.Name.ToLower()
Write-Host "Docs.ms Readme name: $($readmeName)"
# Readme names (which are used in the URL) should not include redundant terms
# when viewed in URL form. For example:
# https://review.docs.microsoft.com/en-us/java/api/overview/azure/storage-blob-readme
# Note how the end of the URL doesn't look like:
# ".../azure/azure-storage-blobs-readme"
# This logic eliminates a preceeding "azure-" in the readme filename.
# "azure-storage-blobs" -> "storage-blobs"
if ($readmeName.StartsWith('azure-')) {
$readmeName = $readmeName.Substring(6)
}
New-Object PSObject -Property @{
DocsMsReadMeName = $readmeName
LatestReadMeLocation = 'docs-ref-services/latest'
PreviewReadMeLocation = 'docs-ref-services/preview'
LegacyReadMeLocation = 'docs-ref-services/legacy'
Suffix = ''
}
}
function Get-java-EmitterName() {
return "@azure-tools/typespec-java"
}
function Get-java-EmitterAdditionalOptions([string]$projectDirectory) {
return "--option @azure-tools/typespec-java.emitter-output-dir=$projectDirectory/"
}
function Get-java-DirectoriesForGeneration() {
$sdkDirectories = Get-ChildItem -Path "$RepoRoot/sdk" -Directory | Get-ChildItem -Directory
return $sdkDirectories | Where-Object {
(Test-Path -Path "$_/tsp-location.yaml") -or
(Test-Path -Path "$_/swagger/Update-Codegeneration.ps1")
}
}
function Update-java-GeneratedSdks([string]$PackageDirectoriesFile) {
$packageDirectories = Get-Content $PackageDirectoriesFile | ConvertFrom-Json
foreach ($directory in $packageDirectories) {
Push-Location $RepoRoot
try {
$tspLocationFile = Get-Item -Path "sdk/$directory/tsp-location.yaml" -ErrorAction SilentlyContinue
$updateScript = Get-Item -Path "sdk/$directory/swagger/Update-CodeGeneration.ps1" -ErrorAction SilentlyContinue
if ($tspLocationFile) {
Write-Host "Found tsp-location.yaml in $directory, using typespec to generate projects"
./eng/common/scripts/TypeSpec-Project-Sync.ps1 "sdk/$directory"
./eng/common/scripts/TypeSpec-Project-Generate.ps1 "sdk/$directory"
} elseif ($updateScript) {
Write-Host "Using $updateScript to generate projects"
& $updateScript.FullName
} else {
Write-Host "No tsp-location.yaml or swagger/Update-Codegeneration.ps1 found in $directory, skipping"
}
}
finally {
Pop-Location
}
}
}
function Get-java-ApiviewStatusCheckRequirement($packageInfo) {
if ($packageInfo.IsNewSdk -and ($packageInfo.SdkType -eq "client" -or $packageInfo.SdkType -eq "spring")) {
return $true
}
return $false
}