Skip to content

Commit 25924ab

Browse files
Add source-built Java API review tooling and ARH integration (#51226)
* Add standalone Java APIView processor and artifact bundle generation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Fix API review bundle preservation and builder diagnostics Preserve prior bundles across Maven cleanup failures, normalize explicit protocol values, and isolate missing-method checks per builder. Add focused regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Finish compressed APIView JSON output Close the gzip stream to complete the compressed data and trailer. Add a round-trip regression against uncompressed JSON output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Detect prohibited fully qualified API types Preserve qualified type scope when checking exported signatures and generic arguments. Cover qualified, imported, allowed and private types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Add processor license headers and streamline review builds Enforce source license headers with Spotless and align its formatter with the SDK parent. Skip formatting, snippet rewriting and unrelated validation during artifact generation while preserving source JAR production. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Remove processor-specific skip wiring Remove the added Spotless and CodeSnippet skip properties and configuration from the standalone processor POM. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Enable processor Checkstyle and fix formatting violations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Prevent builder diagnostics from aborting API review generation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Stop diagnostic JSON parsing at object boundaries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Add source-built Java API review plugin and ARH wrappers Synchronize processor fixes with azure-sdk-tools, retain SDK lint integration, and build the executable plugin from pinned tooling sources for both ARH generation jobs. Replace the legacy bundle script and do not check in a JAR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Validate Java API review plugin with SDK lint checks Run Checkstyle, Spotless, and Codesnippet during verification with scoped Maven-tool exceptions. Fix spelling false positives and move the tool CI definition out of SDK package discovery. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Consolidate API review wrapper documentation in plugin README Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Remove plugin release pipeline from SDK integration Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Validate Java API review modules through shared tools CI Register both artifacts and reactor modules, retain CI version metadata with release disabled, and fix direct Javadoc resolution of shared processor sources. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Fix API review integration test in clean Analyze builds Locate the standalone JAR directly instead of depending on the POM copy skipped by shared Analyze settings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Fix Search spelling config and documentation extension contract Import the Search package dictionary and allow reviewed CSV/JSON documentation assets without requiring every allowed extension to exist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Fix APIView package, exported-type, and builder trait diagnostics Use fully qualified type lookup keys, inspect arrays and wildcard bounds recursively, and normalize builder protocol enums with HTTP as the default. Add analyser and rule regressions; leave naming diagnostics unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Move APIView processor to com.azure.tools Maven group Keep shared CI artifact discovery and version metadata aligned with the processor coordinates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Fix APIView method naming diagnostic patterns Match builder suffixes and prohibited method prefixes as whole names while keeping tokenCredential exact. Add analyser regressions for violations and allowed controls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Address Java API review integration feedback Replace Groovy verification with Java integration tests, select JDK 17, simplify package discovery and staging roots, reuse the shared Pester installer, clarify skip logs, and normalize plugin XML formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b * Simplify API review plugin package path discovery Derive the standard SDK package path from the Maven module directory without Git metadata or a repository-root parameter. Retain the explicit path override for other layouts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b
1 parent 5584517 commit 25924ab

118 files changed

Lines changed: 11842 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
parameters:
2+
- name: languageRepoResource
3+
type: string
4+
- name: toolsRef
5+
type: string
6+
- name: languageToolsRef
7+
type: string
8+
- name: poolName
9+
type: string
10+
default: azsdk-pool
11+
- name: imageOverride
12+
type: string
13+
default: ubuntu-24.04
14+
15+
jobs:
16+
- template: /eng/common/pipelines/templates/jobs/apireview-hub-build-tools-base.yml
17+
parameters:
18+
languageRepoResource: ${{ parameters.languageRepoResource }}
19+
toolsRef: ${{ parameters.toolsRef }}
20+
languageToolsRef: ${{ parameters.languageToolsRef }}
21+
poolName: ${{ parameters.poolName }}
22+
imageOverride: ${{ parameters.imageOverride }}
23+
stepList:
24+
- bash: git -C "$(LanguageToolsSourceDirectory)" sparse-checkout add sdk/tools/api-review-maven-plugin sdk/tools/apiview-java-processor .vscode
25+
displayName: Include Java API review tool sources
26+
- task: JavaToolInstaller@0
27+
displayName: Use Java 17
28+
inputs:
29+
versionSpec: '17'
30+
jdkArchitectureOption: x64
31+
jdkSourceOption: PreInstalled
32+
- template: /eng/common/pipelines/templates/steps/maven-authenticate.yml
33+
- task: PowerShell@2
34+
displayName: Build and stage Java API review tools
35+
inputs:
36+
targetType: filePath
37+
filePath: $(LanguageToolsSourceDirectory)/eng/scripts/Stage-ApiReviewTools.ps1
38+
arguments: >-
39+
-BinOutputDirectory "$(BinOutputDirectory)"
40+
pwsh: true
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
parameters:
2+
- name: kind
3+
type: string
4+
values:
5+
- base
6+
- target
7+
- name: requestMode
8+
type: string
9+
values:
10+
- create
11+
- update
12+
- name: repositoryOwner
13+
type: string
14+
default: Azure
15+
- name: ref
16+
type: string
17+
- name: packageName
18+
type: string
19+
- name: operationId
20+
type: string
21+
- name: poolName
22+
type: string
23+
default: azsdk-pool
24+
- name: imageOverride
25+
type: string
26+
default: ubuntu-24.04
27+
28+
jobs:
29+
- template: /eng/common/pipelines/templates/jobs/apireview-hub-generate-artifact-base.yml
30+
parameters:
31+
${{ if eq(parameters.kind, 'base') }}:
32+
jobName: GenerateBase
33+
${{ if eq(parameters.kind, 'target') }}:
34+
jobName: GenerateTarget
35+
kind: ${{ parameters.kind }}
36+
requestMode: ${{ parameters.requestMode }}
37+
language: java
38+
repositoryFullName: ${{ format('{0}/{1}', parameters.repositoryOwner, 'azure-sdk-for-java') }}
39+
ref: ${{ parameters.ref }}
40+
packageName: ${{ parameters.packageName }}
41+
operationId: ${{ parameters.operationId }}
42+
poolName: ${{ parameters.poolName }}
43+
imageOverride: ${{ parameters.imageOverride }}
44+
stepList:
45+
- task: JavaToolInstaller@0
46+
displayName: Use Java 17
47+
inputs:
48+
versionSpec: '17'
49+
jdkArchitectureOption: x64
50+
jdkSourceOption: PreInstalled
51+
- template: /eng/common/pipelines/templates/steps/maven-authenticate.yml
52+
- task: PowerShell@2
53+
displayName: Generate ${{ parameters.kind }} Java API review bundle
54+
inputs:
55+
targetType: filePath
56+
filePath: $(BinDirectory)/Generate-ApiReviewArtifact.ps1
57+
arguments: >-
58+
-RepositoryRoot "$(Build.SourcesDirectory)"
59+
-PackageName "${{ parameters.packageName }}"
60+
-ToolJar "$(BinDirectory)/api-review-maven-plugin.jar"
61+
-OutputDirectory "$(ArtifactOutputDirectory)"
62+
pwsh: true
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
#Requires -Version 7.0
4+
5+
<#
6+
.SYNOPSIS
7+
Generates a Java API review bundle using a staged executable JAR.
8+
9+
.PARAMETER SourcesJar
10+
Optional prebuilt sources JAR for local validation. Otherwise builds the selected SDK package.
11+
#>
12+
[CmdletBinding(SupportsShouldProcess)]
13+
param(
14+
[Parameter(Mandatory)][string]$RepositoryRoot,
15+
[Parameter(Mandatory)][ValidatePattern('^[A-Za-z0-9][A-Za-z0-9_.-]*$')][string]$PackageName,
16+
[Parameter(Mandatory)][string]$ToolJar,
17+
[Parameter(Mandatory)][string]$OutputDirectory,
18+
[string]$SourcesJar
19+
)
20+
21+
Set-StrictMode -Version 4
22+
$ErrorActionPreference = 'Stop'
23+
$PSNativeCommandUseErrorActionPreference = $false
24+
25+
$root = (Resolve-Path -LiteralPath $RepositoryRoot).Path
26+
$tool = (Resolve-Path -LiteralPath $ToolJar).Path
27+
if (-not (Test-Path -LiteralPath $tool -PathType Leaf)) {
28+
throw "Expected an executable Java API review JAR: $tool"
29+
}
30+
$sdkRoot = Join-Path $root 'sdk'
31+
$packages = @(Get-ChildItem -Path (Join-Path $sdkRoot '*' $PackageName 'pom.xml') -File)
32+
if ($packages.Count -ne 1) {
33+
throw "Expected one package directory for $PackageName; found $($packages.Count)."
34+
}
35+
$package = $packages[0].Directory.FullName
36+
$pom = [xml](Get-Content -LiteralPath $packages[0].FullName -Raw)
37+
$artifact = $pom.SelectSingleNode("/*[local-name()='project']/*[local-name()='artifactId']")
38+
$version = $pom.SelectSingleNode("/*[local-name()='project']/*[local-name()='version']")
39+
if (-not $artifact -or $artifact.InnerText -ne $PackageName -or -not $version -or
40+
[string]::IsNullOrWhiteSpace($version.InnerText) -or $version.InnerText.Contains('${')) {
41+
throw 'The package POM must declare the expected artifact ID and a literal project version.'
42+
}
43+
$packageVersion = $version.InnerText.Trim()
44+
$relativePath = [IO.Path]::GetRelativePath($root, $package).Replace('\', '/')
45+
$output = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputDirectory)
46+
if ($output.TrimEnd('\', '/') -eq $package.TrimEnd('\', '/') -or
47+
$output.TrimEnd('\', '/') -eq $root.TrimEnd('\', '/')) {
48+
throw 'The output directory must not be the package or repository root.'
49+
}
50+
if ($SourcesJar) {
51+
$SourcesJar = (Resolve-Path -LiteralPath $SourcesJar).Path
52+
}
53+
if (-not $PSCmdlet.ShouldProcess($output, 'Generate Java API review bundle')) {
54+
return
55+
}
56+
57+
$previous = @{}
58+
$published = [Collections.Generic.List[string]]::new()
59+
foreach ($name in @('api.md', 'api.metadata.yml')) {
60+
$path = Join-Path $output $name
61+
if (Test-Path -LiteralPath $path -PathType Leaf) {
62+
$previous[$path] = [IO.File]::ReadAllBytes($path)
63+
}
64+
}
65+
$temporary = Join-Path ([IO.Path]::GetTempPath()) "java-api-review-$([guid]::NewGuid().ToString('N'))"
66+
try {
67+
if (-not $SourcesJar) {
68+
$arguments = @(
69+
'--batch-mode', '--no-transfer-progress',
70+
'clean', 'package', '-f', (Join-Path $root 'pom.xml'), '-pl', $relativePath, '-am',
71+
'-Dmaven.javadoc.skip=true', '-Dgpg.skip=true', '-Dmaven.test.skip=true', '-DskipTestCompile=true',
72+
'-Djacoco.skip=true', '-Drevapi.skip=true', '-Dcheckstyle.skip=true', '-Dspotbugs.skip=true',
73+
'-Dspotless.skip=true', '-Dcodesnippet.skip=true', '-Danimal.sniffer.skip=true'
74+
)
75+
& mvn @arguments
76+
if ($LASTEXITCODE -ne 0) {
77+
throw "SDK package build failed with exit code $LASTEXITCODE."
78+
}
79+
$archives = @(Get-ChildItem -LiteralPath (Join-Path $package 'target') -Filter '*-sources.jar' -File)
80+
if ($archives.Count -ne 1) {
81+
throw "Expected one sources JAR; found $($archives.Count)."
82+
}
83+
$SourcesJar = $archives[0].FullName
84+
}
85+
if (-not (Test-Path -LiteralPath $SourcesJar -PathType Leaf) -or
86+
[IO.Path]::GetFileName($SourcesJar) -ne "$PackageName-$packageVersion-sources.jar") {
87+
throw 'The sources JAR filename must match the checked-out package artifact ID and version.'
88+
}
89+
New-Item -ItemType Directory -Path $temporary -Force | Out-Null
90+
& java -jar $tool --sources-jar $SourcesJar --package-relative-path $relativePath --output-directory $temporary
91+
if ($LASTEXITCODE -ne 0) {
92+
throw "Java API review generation failed with exit code $LASTEXITCODE."
93+
}
94+
$metadata = Join-Path $temporary 'api.metadata.yml'
95+
$expectedVersion = "packageVersion: '$($packageVersion.Replace("'", "''"))'"
96+
if (-not (Test-Path -LiteralPath $metadata -PathType Leaf) -or
97+
$expectedVersion -notin (Get-Content -LiteralPath $metadata)) {
98+
throw 'Generated package version does not match the checked-out package POM.'
99+
}
100+
foreach ($name in @('api.md', 'api.metadata.yml')) {
101+
if (-not (Test-Path -LiteralPath (Join-Path $temporary $name) -PathType Leaf)) {
102+
throw "The API review tool did not produce $name."
103+
}
104+
}
105+
New-Item -ItemType Directory -Path $output -Force | Out-Null
106+
foreach ($name in @('api.md', 'api.metadata.yml')) {
107+
$destination = Join-Path $output $name
108+
[IO.File]::Move((Join-Path $temporary $name), $destination, $true)
109+
$published.Add($destination)
110+
}
111+
Write-Output "Generated Java API review bundle: $output"
112+
}
113+
catch {
114+
if ($previous.Count -gt 0) {
115+
New-Item -ItemType Directory -Path $output -Force | Out-Null
116+
foreach ($path in $previous.Keys) {
117+
[IO.File]::WriteAllBytes($path, $previous[$path])
118+
}
119+
}
120+
foreach ($path in $published) {
121+
if (-not $previous.ContainsKey($path)) {
122+
Remove-Item -LiteralPath $path -Force
123+
}
124+
}
125+
throw
126+
}
127+
finally {
128+
if (Test-Path -LiteralPath $temporary) {
129+
Remove-Item -LiteralPath $temporary -Recurse -Force
130+
}
131+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
#Requires -Version 7.0
4+
5+
<#
6+
.SYNOPSIS
7+
Builds and stages the Java API review JAR and generator script into an ARH tools bundle.
8+
#>
9+
[CmdletBinding(SupportsShouldProcess)]
10+
param(
11+
[Parameter(Mandatory)][string]$BinOutputDirectory
12+
)
13+
14+
Set-StrictMode -Version 4
15+
$ErrorActionPreference = 'Stop'
16+
$PSNativeCommandUseErrorActionPreference = $false
17+
$root = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..' '..')).Path
18+
$plugin = Join-Path $root 'sdk' 'tools' 'api-review-maven-plugin'
19+
$pomPath = Join-Path $plugin 'pom.xml'
20+
$generator = Join-Path $root 'eng' 'scripts' 'Generate-ApiReviewArtifact.ps1'
21+
foreach ($file in @($pomPath, $generator)) {
22+
if (-not (Test-Path -LiteralPath $file -PathType Leaf)) {
23+
throw "Required Java API review source was not found: $file"
24+
}
25+
}
26+
if (-not $PSCmdlet.ShouldProcess($BinOutputDirectory, 'Build and stage Java API review tools')) {
27+
return
28+
}
29+
& mvn --batch-mode --no-transfer-progress -f $pomPath clean package '-DskipTests' '-Dmaven.javadoc.skip=true'
30+
if ($LASTEXITCODE -ne 0) {
31+
throw "Java API review tool build failed with exit code $LASTEXITCODE."
32+
}
33+
$pom = [xml](Get-Content -LiteralPath $pomPath -Raw)
34+
$version = $pom.SelectSingleNode("/*[local-name()='project']/*[local-name()='version']").InnerText.Trim()
35+
$files = @(
36+
(Join-Path $plugin 'target' "api-review-maven-plugin-$version.jar"),
37+
$generator
38+
)
39+
foreach ($file in $files) {
40+
if (-not (Test-Path -LiteralPath $file -PathType Leaf)) {
41+
throw "Required Java API review tool was not found: $file"
42+
}
43+
}
44+
New-Item -ItemType Directory -Path $BinOutputDirectory -Force | Out-Null
45+
Copy-Item -LiteralPath $files[0] -Destination (Join-Path $BinOutputDirectory 'api-review-maven-plugin.jar') -Force
46+
Copy-Item -LiteralPath $generator -Destination $BinOutputDirectory -Force

0 commit comments

Comments
 (0)