Skip to content

Conversation

MehulBatra
Copy link
Contributor

@MehulBatra MehulBatra commented Sep 18, 2025

Purpose

Linked issue: close #1712

Implement javadoc generation

Brief change log

  • Created build_javadocs.sh script to generate javadoc
  • Configured profile to include only API-relevant modules (fluss-client, fluss-flink) while excluding modules (fluss-protogen, fluss-jmh, fluss-test-*, fluss-metrics, common, server etc.)
  • Added version-aware output directory structure (website/static/javadoc/VERSION/)
  • Created automatic redirect page for latest version navigation

Tests

Manual testing of javadoc generation script with different scenarios
Verified generated HTML output structure and content
Validated redirect functionality and version-specific URL routing

Run:

API and Format

No API changes - This is purely a build/documentation improvement that doesn't affect runtime APIs.

Documentation

The generated javadoc itself serves as API reference documentation.

@MehulBatra MehulBatra requested a review from wuchong September 19, 2025 12:43
@wuchong
Copy link
Member

wuchong commented Sep 21, 2025

Thanks for the great work @MehulBatra !

Here are my thoughts about the javadoc design:

  1. I don't want to maintain the generated javadoc in the main repo and branches, this will quickly increase our main repo size. which is very heavy.
  2. We can maintain each generated javadocs at the apache/fluss-website in the branches javadoc-<version>.
  3. We need to maintain javadocs for each version, including the released (not include the com.alibaba.fluss versions) and unreleased (main branch).

Here are suggestions about how to implement:

  1. Create a new script build_javadocs.sh under website/ along with build_versioned_docs.sh
  • The script just generates javadocs for the current branch, the generated javadocs can be put in the folder website/genearted_javadocs/ (add this directory into .gitignore)
  1. Add a build_javadocs.yaml in apache/fluss-website https://github.com/apache/fluss-website/tree/main/.github/workflows
  • it's a daily scheduled github action
  • it checkout apache/fluss repo and for each release-* (exclude <= release-0.7 branches) and main branch
  • for each branch, it runs the build_javadocs.sh script and commit the files in website/genearted_javadocs/ to the branch javadoc-<version> of apache/fluss-website
  • maybe we can skip branches if the branch has no git log changes in 7 days, to reduce the build cost.
  • I think we can get the SHORT_VERSION from the branch name easily, so no need to use mvn command to parse
  1. Update website-deploy.yaml in apache/fluss-website, add a step Copy Javadocs before the Deploy website.
  • it copies javadocs files from branches javadoc-<version> to the directory ./build/javadoc/<version>
  • you can learn the code from build_versioned_docs.sh in apache/fluss which has similar code.
  1. Add javadoc links in our official docs.

@MehulBatra
Copy link
Contributor Author

Thanks for the feedback @wuchong , I agree on all the points will implement on these lines!

@MehulBatra
Copy link
Contributor Author

Github Action PR: apache/fluss-website#1

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements javadoc generation for Apache Fluss's public API modules. The changes add a Maven-based javadoc build system that generates comprehensive API documentation for client and Flink integration modules while excluding internal implementation details.

  • Added automated javadoc generation script with version-aware output structure
  • Configured Docusaurus navigation to include Javadocs link
  • Cleaned up minor formatting issues in root pom.xml

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
website/docusaurus.config.ts Added Javadocs navigation link to website header
website/build_javadocs.sh New script for generating javadocs with Maven, branch-aware versioning, and redirect page creation
pom.xml Minor formatting cleanup removing extra blank lines

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

{to: '/community/welcome', label: 'Community', position: 'left'},
{to: '/roadmap', label: 'Roadmap', position: 'left'},
{to: '/downloads', label: 'Downloads', position: 'left'},
{to: '/javadoc', label: 'Javadocs', position: 'left', target: '_blank'},
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space before 'target: '_blank'' - there should be only one space after the comma for consistent formatting.

Suggested change
{to: '/javadoc', label: 'Javadocs', position: 'left', target: '_blank'},
{to: '/javadoc', label: 'Javadocs', position: 'left', target: '_blank'},

Copilot uses AI. Check for mistakes.

Comment on lines +40 to +42
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout 2>/dev/null || mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ -z "$VERSION" ]]; then
echo "Error: Could not extract project version"
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The command fallback logic could fail silently if both mvnw and mvn commands fail but return empty output. Consider adding explicit error handling to detect when both commands fail.

Suggested change
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout 2>/dev/null || mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ -z "$VERSION" ]]; then
echo "Error: Could not extract project version"
# Try to get version with ./mvnw first
VERSION=""
if [[ -x "./mvnw" ]]; then
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout 2>/dev/null)
MVNW_STATUS=$?
else
MVNW_STATUS=127
fi
if [[ $MVNW_STATUS -ne 0 || -z "$VERSION" ]]; then
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout 2>/dev/null)
MVN_STATUS=$?
else
MVN_STATUS=0
fi
if [[ ($MVNW_STATUS -ne 0 && $MVN_STATUS -ne 0) || -z "$VERSION" ]]; then
echo "Error: Could not extract project version using either ./mvnw or mvn."

Copilot uses AI. Check for mistakes.

Comment on lines +134 to +137
if (./mvnw -f "$TEMP_POM" clean compile javadoc:aggregate -q 2>/dev/null || mvn -f "$TEMP_POM" clean compile javadoc:aggregate -q); then
echo "Javadoc generation completed successfully"
else
echo "Error: Javadoc generation failed"
Copy link
Preview

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Similar to the version extraction, this Maven command fallback could benefit from more explicit error handling. The current approach may not distinguish between command not found vs actual build failures.

Suggested change
if (./mvnw -f "$TEMP_POM" clean compile javadoc:aggregate -q 2>/dev/null || mvn -f "$TEMP_POM" clean compile javadoc:aggregate -q); then
echo "Javadoc generation completed successfully"
else
echo "Error: Javadoc generation failed"
# Explicit Maven command fallback with error handling
if [[ -x "./mvnw" ]]; then
echo "Using ./mvnw to build and generate Javadoc..."
./mvnw -f "$TEMP_POM" clean compile javadoc:aggregate -q
MVN_EXIT_CODE=$?
if [[ $MVN_EXIT_CODE -ne 0 ]]; then
echo "Error: Javadoc generation failed using ./mvnw (exit code $MVN_EXIT_CODE)"
exit 1
fi
elif command -v mvn >/dev/null 2>&1; then
echo "Using mvn to build and generate Javadoc..."
mvn -f "$TEMP_POM" clean compile javadoc:aggregate -q
MVN_EXIT_CODE=$?
if [[ $MVN_EXIT_CODE -ne 0 ]]; then
echo "Error: Javadoc generation failed using mvn (exit code $MVN_EXIT_CODE)"
exit 1
fi
else
echo "Error: Neither ./mvnw nor mvn found. Please install Maven or ensure ./mvnw is present."

Copilot uses AI. Check for mistakes.

@MehulBatra
Copy link
Contributor Author

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup Javadoc for fluss API discoverability
2 participants