Skip to content

Commit 56d111b

Browse files
newtorkJonas-Isr
andauthored
chore: Enable JavaDoc Aggregate with Delombok (#969)
Co-authored-by: Jonas-Isr <[email protected]>
1 parent 2d4f0b6 commit 56d111b

File tree

7 files changed

+158
-6
lines changed

7 files changed

+158
-6
lines changed

.github/dependabot.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ updates:
3636
- dependency-name: 'com.github.ekryd.sortpom:sortpom-maven-plugin'
3737
# used by deprecated code only, not worth updating for now
3838
- dependency-name: 'org.apache.axis2:*'
39-
# newer versions cause issues with our release process
40-
- dependency-name: 'org.apache.maven.plugins:maven-javadoc-plugin'
4139
# Ignore problematic license versions
4240
- dependency-name: 'com.sap.cloud.security:java-security'
4341
versions: ['3.6.1', '3.6.2']

.github/workflows/javadoc.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: JavaDoc to Documentation Portal
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch/Commit/Tag for JavaDoc'
8+
required: true
9+
default: 'main'
10+
11+
env:
12+
JAVA_VERSION: 17
13+
DOCS_REPO: SAP/cloud-sdk
14+
PROJECTS: "!:rfc,!:dwc-cf,!:datamodel-metadata-generator,!:odata-generator,!:odata-generator-maven-plugin,!:odata-generator-utility,!:odata-v4-generator,!:odata-v4-generator-maven-plugin,!:s4hana-connectivity,!:soap,!:testutil,!:s4hana-core"
15+
16+
jobs:
17+
build:
18+
name: "JavaDoc to Documentation Portal"
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: "Prepare git"
23+
run: |
24+
git config --global user.email "[email protected]"
25+
git config --global user.name "SAP Cloud SDK Bot"
26+
27+
- name: "Checkout Repository"
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: "Switch branch"
33+
run: git checkout "${{ github.event.inputs.branch || 'main' }}"
34+
35+
- name: "Set up JDK 17"
36+
uses: actions/setup-java@v4
37+
with:
38+
java-version: '17'
39+
distribution: 'temurin'
40+
cache: 'maven'
41+
42+
- name: "Determine Versions"
43+
id: determine-version
44+
run: |
45+
echo "MAJOR_VERSION=$(jq -r '.version' latest.json | cut -d '.' -f 1)" >> $GITHUB_OUTPUT
46+
echo "CURRENT_VERSION=$(jq -r '.version' latest.json" >> $GITHUB_OUTPUT
47+
48+
- name: "Install project (skip tests)"
49+
run: mvn install -DskipTests --quiet
50+
51+
- name: "Process sources"
52+
run: mvn process-sources -Drelease --fail-at-end --projects "${PROJECTS}" --quiet
53+
54+
- name: "Copy delombok sources"
55+
run: find . -type d -path "*/target/delombok" -exec sh -c 'cp -r "$1"/* "$(dirname $(dirname "$1"))/src/main/java/"' _ {} \;
56+
57+
- name: "Generate aggregated Javadoc"
58+
run: mvn clean javadoc:aggregate -Drelease -Djava.failOnWarning=false --projects "${PROJECTS}" --quiet
59+
60+
- name: "Checkout Docs Repository"
61+
uses: actions/checkout@v4
62+
with:
63+
repository: ${{ env.DOCS_REPO }}
64+
path: .cloud-sdk-docs
65+
token: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
66+
67+
- name: "Replace JavaDoc"
68+
id: replace-javadoc
69+
run: |
70+
TARGET_DIR=./.cloud-sdk-docs/static/java-api/v${{ steps.determine-version.outputs.MAJOR_VERSION }}
71+
72+
ls -lA target
73+
rm -rf $TARGET_DIR
74+
mkdir -p $TARGET_DIR
75+
mv target/reports/apidocs/* $TARGET_DIR
76+
77+
cd ./.cloud-sdk-docs
78+
git add -A .
79+
80+
CHANGED_FILES="$(git status -s)"
81+
if [[ -z "$CHANGED_FILES" ]]; then
82+
echo "[DEBUG] No changes to API docs detected, skipping Pull Request creation."
83+
echo "CREATE_PR=false" >> $GITHUB_OUTPUT
84+
exit 0
85+
fi
86+
87+
echo "CREATE_PR=true" >> $GITHUB_OUTPUT
88+
BRANCH_NAME=java/release-docs-${{ steps.determine-version.outputs.CURRENT_VERSION }}
89+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
90+
91+
git switch --create $BRANCH_NAME
92+
git commit -m "chore: Update JavaDocs for release ${{ steps.determine-version.outputs.CURRENT_VERSION }}"
93+
COMMIT_SHA=$(git log -1 --pretty=format:"%H")
94+
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT
95+
96+
git push origin $BRANCH_NAME
97+
98+
- name: "Create JavaDoc PR"
99+
id: create-javadoc-pr
100+
if: ${{ steps.replace-javadoc.outputs.CREATE_PR == 'true' }}
101+
working-directory: ./.cloud-sdk-docs
102+
run: |
103+
PR_TITLE="Java: Update JavaDocs for release ${{ needs.bump-version.outputs.release-version }}"
104+
PR_BODY="Replace the contents of v${{ steps.determine-version.outputs.MAJOR_VERSION }} API docs with the latest release of the SDK."
105+
106+
PR_URL=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --repo "${{ env.DOCS_REPO }}")
107+
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
108+
echo "PR: $PR_URL" >> $GITHUB_STEP_SUMMARY
109+
env:
110+
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}

.github/workflows/perform-release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
code-branch: ${{ steps.determine-branch-names.outputs.CODE_BRANCH_NAME }}
2525
docs-branch: ${{ steps.determine-branch-names.outputs.DOCS_BRANCH_NAME }}
2626
release-notes-branch: ${{ steps.determine-branch-names.outputs.RELEASE_NOTES_BRANCH_NAME }}
27+
release-javadoc-branch: ${{ steps.determine-branch-names.outputs.RELEASE_JAVADOC_BRANCH_NAME }}
2728
release-tag: ${{ steps.determine-branch-names.outputs.RELEASE_TAG }}
2829
release-commit: ${{ steps.determine-branch-names.outputs.RELEASE_COMMIT }}
2930
permissions: write-all # contents and push are needed to see the draft release
@@ -37,12 +38,14 @@ jobs:
3738
RELEASE_TAG=rel/$RELEASE_VERSION
3839
RELEASE_COMMIT=$(gh release view $RELEASE_TAG --repo ${{github.repository}} --json targetCommitish --jq '.targetCommitish')
3940
RELEASE_NOTES_BRANCH_NAME=java/release-notes-$RELEASE_VERSION
41+
RELEASE_JAVADOC_BRANCH_NAME=java/release-docs-$RELEASE_VERSION
4042
4143
echo "CODE_BRANCH_NAME=$CODE_BRANCH_NAME" >> $GITHUB_OUTPUT
4244
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
4345
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT
4446
echo "RELEASE_COMMIT=$RELEASE_COMMIT" >> $GITHUB_OUTPUT
4547
echo "RELEASE_NOTES_BRANCH_NAME=$RELEASE_NOTES_BRANCH_NAME" >> $GITHUB_OUTPUT
48+
echo "RELEASE_JAVADOC_BRANCH_NAME=$RELEASE_JAVADOC_BRANCH_NAME" >> $GITHUB_OUTPUT
4649
4750
echo -e "[DEBUG] Current GITHUB_OUTPUT:\n$(cat $GITHUB_OUTPUT)"
4851
env:
@@ -82,6 +85,18 @@ jobs:
8285
\"Build Cloud SDK Documentation\": [\"dependabot\"]
8386
}
8487
88+
- name: "Check Whether JavaDoc PR Can Be Merged"
89+
if: ${{ inputs.skip-pr-merge != 'true' }}
90+
uses: ./.github/actions/pr-is-mergeable
91+
with:
92+
pr-ref: ${{ steps.determine-branch-names.outputs.RELEASE_JAVADOC_BRANCH_NAME }}
93+
repo: ${{ env.DOCS_REPO }}
94+
token: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
95+
excluded-check-runs: |
96+
{
97+
\"Build Cloud SDK Documentation\": [\"dependabot\"]
98+
}
99+
85100
release:
86101
name: "Release"
87102
needs: [ prerequisites ]
@@ -136,5 +151,11 @@ jobs:
136151
- name: "Merge Release Notes PR"
137152
if: ${{ inputs.skip-pr-merge != 'true' }}
138153
run: gh pr merge --squash "${{ needs.prerequisites.outputs.release-notes-branch }}" --delete-branch --repo "${{ env.DOCS_REPO }}"
154+
env:
155+
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
156+
157+
- name: "Merge JavaDoc PR"
158+
if: ${{ inputs.skip-pr-merge != 'true' }}
159+
run: gh pr merge --squash "${{ needs.prerequisites.outputs.release-javadoc-branch }}" --delete-branch --repo "${{ env.DOCS_REPO }}"
139160
env:
140161
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}

.github/workflows/prepare-release.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,26 @@ jobs:
154154
env:
155155
GH_TOKEN: ${{ github.token }}
156156

157+
create-javadoc-aggregated-pr:
158+
needs: [ create-release ]
159+
name: "Create Aggregated JavaDoc PR on Documentation Portal"
160+
runs-on: ubuntu-latest
161+
permissions:
162+
actions: write # needed to trigger the ci-build workflow
163+
statuses: write # needed to update the commit status
164+
steps:
165+
- name: "Checkout repository"
166+
uses: actions/checkout@v5
167+
with:
168+
ref: ${{ needs.create-release.outputs.release-name }}
169+
- name: "Trigger workflow (ignore failures)"
170+
uses: ./.github/actions/trigger-workflow
171+
continue-on-error: true
172+
with:
173+
workflow: javadoc.yaml
174+
workflow-ref: main
175+
parameters: -f branch=${{ needs.create-release.outputs.release-name }}
176+
157177
create-release-notes-pr:
158178
name: "Create Release Notes PR"
159179
needs: [ bump-version, run-ci ]
@@ -263,6 +283,7 @@ jobs:
263283
PR_URL=$(gh pr create --title "Release ${{ needs.bump-version.outputs.release-version }}" --body "## TODOs
264284
- [ ] Review the changes in [the release commit]($COMMIT_URL)
265285
- [ ] Review **and approve** the [Release Notes PR](${{ needs.create-release-notes-pr.outputs.pr-url }})
286+
- [ ] Review **and approve** the [JavaDoc PR](https://github.com/SAP/cloud-sdk/pulls?q=is%3Aopen+is%3Apr+author%3Abot-sdk-js+Update+JavaDocs)
266287
- [ ] Review the [Draft Release](${{ needs.create-release.outputs.release-url }})
267288
- [ ] Review **and approve** this PR
268289
- [ ] Once all tests of this PR are green, trigger the [Perform Release Workflow](${{ github.event.repository.html_url }}/actions/workflows/perform-release.yml)

dependency-bundles/bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
<plugin>
346346
<groupId>org.apache.maven.plugins</groupId>
347347
<artifactId>maven-javadoc-plugin</artifactId>
348-
<version>3.11.2</version>
348+
<version>3.12.0</version>
349349
<executions>
350350
<execution>
351351
<id>javadoc-jar</id>

dependency-bundles/modules-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
<plugin>
273273
<groupId>org.apache.maven.plugins</groupId>
274274
<artifactId>maven-javadoc-plugin</artifactId>
275-
<version>3.11.2</version>
275+
<version>3.12.0</version>
276276
<executions>
277277
<execution>
278278
<id>javadoc-jar</id>

pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
<plugin>
516516
<groupId>org.apache.maven.plugins</groupId>
517517
<artifactId>maven-javadoc-plugin</artifactId>
518-
<version>3.11.2</version>
518+
<version>3.12.0</version>
519519
</plugin>
520520
<plugin>
521521
<groupId>com.sap.cloud.sdk.datamodel</groupId>
@@ -1015,7 +1015,6 @@
10151015
<packages>com.sap.cloud.sdk.s4hana*</packages>
10161016
</group>
10171017
</groups>
1018-
<sourcepath>${project.basedir}/target/delombok</sourcepath>
10191018
<overview>${project.rootdir}/javadoc.overview.html</overview>
10201019
</configuration>
10211020
<executions>
@@ -1024,6 +1023,9 @@
10241023
<goals>
10251024
<goal>jar</goal>
10261025
</goals>
1026+
<configuration>
1027+
<sourcepath>${project.basedir}/target/delombok</sourcepath>
1028+
</configuration>
10271029
</execution>
10281030
</executions>
10291031
</plugin>

0 commit comments

Comments
 (0)