Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions eng/pipelines/templates/jobs/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ jobs:
-Artifacts ('${{ replace(convertToJson(parameters.ReleaseArtifacts), '''', '`''') }}' | ConvertFrom-Json | Where-Object -Not skipPublishPackage )
-InformationAction Continue

- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/scripts/Save-Package-Namespaces-Property.ps1
arguments: >
-ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)
-ArtifactsList ('$(ArtifactsJson)' | ConvertFrom-Json)
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Update package properties with namespaces

- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
parameters:
ArtifactPath: $(Build.ArtifactStagingDirectory)
Expand Down
10 changes: 10 additions & 0 deletions eng/pipelines/templates/stages/archetype-sdk-client-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ extends:
-Artifacts ('$(ArtifactsJsonEscaped)' | ConvertFrom-Json | Where-Object -Not skipPublishPackage)
-InformationAction Continue

- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/scripts/Save-Package-Namespaces-Property.ps1
arguments: >
-ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)
-ArtifactsList ('$(ArtifactsJson)' | ConvertFrom-Json)
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Update package properties with namespaces

- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
parameters:
ArtifactPath: $(Build.ArtifactStagingDirectory)
Expand Down
103 changes: 103 additions & 0 deletions eng/scripts/Save-Package-Namespaces-Property.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<#
.SYNOPSIS
Given an artifact staging directory, loop through all of the PackageInfo files
in the PackageInfo subdirectory and compute the namespaces if they don't already
exist. Yes, they're called packages in Java but namespaces are being used to keep
code that processes them common amongst the languages.

.DESCRIPTION
Given an artifact staging directory, loop through all of the PackageInfo files
in the PackageInfo subdirectory. For each PackageInfo file, find its corresponding
javadoc jar file and use that to compute the namespace information.

.PARAMETER ArtifactStagingDirectory
The root directory of the staged artifacts. The PackageInfo files will be in the
PackageInfo subdirectory. The artifacts root directories are GroupId based, meaning
any artifact with that GroupId will be in a subdirectory. For example: Most Spring
libraries are com.azure.spring and their javadoc jars will be under that subdirectory
but azure-spring-data-cosmos' GroupId is com.azure and its javadoc jar will be under
com.azure.

.PARAMETER ArtifactsList
The list of artifacts to gather namespaces for, this is only done for libraries that are
producing docs.
-ArtifactsList ('$(ArtifactsJson)' | ConvertFrom-Json)
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory = $True)]
[string] $ArtifactStagingDirectory,
[Parameter(Mandatory=$true)]
[array] $ArtifactsList
)

$ArtifactsList = $ArtifactsList | Where-Object -Not "skipPublishDocMs"

. (Join-Path $PSScriptRoot ".." common scripts common.ps1)

if (-not $ArtifactsList) {
Write-Host "ArtifactsList is empty, nothing to process. This can happen if skipPublishDocMs is set to true for all libraries being built."
exit 0
}

Write-Host "ArtifactStagingDirectory=$ArtifactStagingDirectory"
if (-not (Test-Path -Path $ArtifactStagingDirectory)) {
LogError "ArtifactStagingDirectory '$ArtifactStagingDirectory' does not exist."
exit 1
}

Write-Host ""
Write-Host "ArtifactsList:"
$ArtifactsList | Format-Table -Property GroupId, Name | Out-String | Write-Host

$packageInfoDirectory = Join-Path $ArtifactStagingDirectory "PackageInfo"

$foundError = $false
# At this point the packageInfo files should have been already been created.
# The only thing being done here is adding or updating namespaces for libraries
# that will be producing docs. This ArtifactsList is
foreach($artifact in $ArtifactsList) {
# Get the version from the packageInfo file
$packageInfoFile = Join-Path $packageInfoDirectory "$($artifact.Name).json"
Write-Host "processing $($packageInfoFile.FullName)"
$packageInfo = ConvertFrom-Json (Get-Content $packageInfoFile -Raw)
$version = $packageInfo.Version
# If the dev version is set, use that. This will be set for nightly builds
if ($packageInfo.DevVersion) {
$version = $packageInfo.DevVersion
}
# From the $packageInfo piece together the path to the javadoc jar file
$javadocJar = Join-Path $ArtifactStagingDirectory $packageInfo.Group $packageInfo.Name "$($packageInfo.Name)-$($version)-javadoc.jar"
if (!(Test-Path $javadocJar -PathType Leaf)) {
LogError "Javadoc Jar file, $javadocJar, was not found. Please ensure that a Javadoc jar is being created for the library."
$foundError = $true
continue
}
$namespaces = Fetch-Namespaces-From-Javadoc $packageInfo.Name $packageInfo.Group $version $javadocJar
if ($namespaces.Count -gt 0) {
Write-Host "Adding/Updating Namespaces property with the following namespaces:"
$namespaces | Write-Host
if ($packageInfo.PSobject.Properties.Name -contains "Namespaces") {
Write-Host "Contains Namespaces property, updating"
$packageInfo.Namespaces = $namespaces
}
else {
Write-Host "Adding Namespaces property"
$packageInfo = $packageInfo | Add-Member -MemberType NoteProperty -Name Namespaces -Value $namespaces -PassThru
}
$packageInfoJson = ConvertTo-Json -InputObject $packageInfo -Depth 100
Write-Host "The updated packageInfo for $packageInfoFile is:"
Write-Host "$packageInfoJson"
Set-Content `
-Path $packageInfoFile `
-Value $packageInfoJson
} else {
LogError "Unable to determine namespaces for $($packageInfo.Group):$($packageInfo.Name). Please ensure that skipPublishDocMs isn't incorrectly set to true or that the library isn't producing an empty java doc jar."
$foundError = $true
}
}

if ($foundError) {
exit 1
}
exit 0
40 changes: 26 additions & 14 deletions eng/scripts/docs/Docs-ToC.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,39 @@ function Get-Toc-Children($package, $docRepoLocation) {
}

# Given a library, groupId and version, return the list of namespaces
function Fetch-Namespaces-From-Javadoc($package, $groupId, $version) {
function Fetch-Namespaces-From-Javadoc($package, $groupId, $version, $javadocJarFile = $null) {

$namespaces = @()
# Create a temporary directory to drop the jar into
$tempDirectory = Join-Path ([System.IO.Path]::GetTempPath()) "${groupId}-${package}-${version}"
New-Item $tempDirectory -ItemType Directory | Out-Null
$artifact = "${groupId}:${package}:${version}:jar:javadoc"
try {
# Download the Jar file
Write-Host "mvn dependency:copy -Dartifact=""$artifact"" -DoutputDirectory=""$tempDirectory"""
$mvnResults = mvn `
dependency:copy `
-Dartifact="$artifact" `
-DoutputDirectory="$tempDirectory"

if ($LASTEXITCODE -ne 0) {
LogWarning "Could not download javadoc artifact: $artifact"
$mvnResults | Write-Host
# If the $javadocJarFile is passed in, copy it to the $tempDirectory, otherwise download it
# from the dev feed or maven
if ($javadocJarFile) {
if (Test-Path $javadocJar -PathType Leaf) {
Copy-Item $javadocJarFile -Destination $tempDirectory
} else {
LogWarning "javadocJar parameter's jar file, $javadocJar, does not exist."
}
} else {
# Download the Jar file
Write-Host "mvn dependency:copy -Dartifact=""$artifact"" -DoutputDirectory=""$tempDirectory"""
$mvnResults = mvn `
dependency:copy `
-Dartifact="$artifact" `
-DoutputDirectory="$tempDirectory"
if ($LASTEXITCODE -ne 0) {
LogWarning "Could not download javadoc artifact: $artifact"
$mvnResults | Write-Host
}
}
$javadocLocation = "$tempDirectory/$package-$version-javadoc.jar"
# If the Jar file doesn't exit the error has already been reported above and
# processing will return an empty namespaces list
if (Test-Path $javadocLocation -PathType Leaf) {
# Unpack the Jar file
$javadocLocation = "$tempDirectory/$package-$version-javadoc.jar"
$unpackDirectory = Join-Path $tempDirectory "unpackedJavadoc"
New-Item $unpackDirectory -ItemType Directory | Out-Null
Add-Type -AssemblyName System.IO.Compression.FileSystem
Expand Down Expand Up @@ -205,12 +217,12 @@ function Fetch-Namespaces-From-Javadoc($package, $groupId, $version) {
}
}
else {
LogWarning "Unable to determine namespaces from $artifact."
LogWarning "Unable to determine namespaces from $artifact. Please ensure that the a javadoc jar is being built for the artifact and that it's not empty (ex. START/END: Empty Java Doc & Sources isn't in the POM file)."
}
}
}
catch {
LogError "Exception while trying to download: $artifact"
LogError "Exception while trying to retrieve namespaces from: $artifact"
LogError $_
LogError $_.ScriptStackTrace
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/spring/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ extends:
- name: spring-cloud-azure-appconfiguration-config-web
groupId: com.azure.spring
safeName: springcloudazureappconfigurationconfigweb
skipPublishDocGithubIo: false
skipPublishDocMs: false
skipPublishDocGithubIo: true
skipPublishDocMs: true
skipUpdatePackageJson: true
skipVerifyChangelog: true
releaseInBatch: ${{ parameters.release_springcloudazureappconfigurationconfigweb }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>3.3.2</version> <!-- {x-version-update;springboot3_org.springframework.boot:spring-boot-configuration-processor;external_dependency} -->
<version>3.3.3</version> <!-- {x-version-update;springboot3_org.springframework.boot:spring-boot-configuration-processor;external_dependency} -->
<optional>true</optional>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,15 @@
</manifest>
</archive>
</configuration>
</plugin>
<!-- START: Empty Java Doc and Sources -->
<!-- The following code will generate an empty javadoc with just a README.md. This is
necessary
to pass the required checks on Maven. The way this works is by setting the classesDirectory
to a directory that only contains the README.md, which we need to copy. If the classesDirectory
is set to the root, where the README.md lives, it still won't have javadocs but the jar file
will contain a bunch of files that shouldn't be there. The faux sources directory is deleted
and recreated with the README.md being copied every time to guarantee that, when building locally,
it'll have the latest copy of the README.md file.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version> <!-- {x-version-update;springboot3_org.apache.maven.plugins:maven-jar-plugin;external_dependency} -->
<!-- START: Empty Java Doc and Sources -->
<!-- The following code will generate an empty javadoc with just a README.md. This is necessary
to pass the required checks on Maven. The way this works is by setting the classesDirectory
to a directory that only contains the README.md, which we need to copy. If the classesDirectory
is set to the root, where the README.md lives, it still won't have javadocs but the jar file
will contain a bunch of files that shouldn't be there. The faux sources directory is deleted
and recreated with the README.md being copied every time to guarantee that, when building locally,
it'll have the latest copy of the README.md file.
-->
<executions>
<execution>
<id>empty-javadoc-jar-with-readme</id>
Expand Down Expand Up @@ -223,8 +217,8 @@
</goals>
</execution>
</executions>
</plugin>
<!-- END: Empty Java Doc and Sources -->
</plugin>
</plugins>
</build>
</project>