I need to generate a JavaDoc from my GitHub repository and publish it to a webpage like GitHub Page.
I found this solution on StackOverflow: Publish automatically JavaDoc: with GitHub Actions
name: Deploy Javadoc
on:
push:
branches:
- master
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Deploy JavaDoc 🚀
uses: MathieuSoysal/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: javadoc
java-version: 17
target-folder: javadoc
But this solution works only for Maven, and not for Gradle.
Someone know if is possible to adapt this for a Gradle project ?
Yes is possible, with this code on your GitHub Actions :
name: Deploy Javadoc
on:
push:
branches:
- master
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Deploy JavaDoc 🚀
uses: MathieuSoysal/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: javadoc
java-version: 17
target-folder: javadoc
project: gradle
Credit: https://github.com/MathieuSoysal/Javadoc-publisher.yml https://github.com/marketplace/actions/deploy-javadoc
This code publish JavaDoc automatically when you publish to "master" branch, your JavaDoc is pushed on javadoc branch, and deployed with GitHub Page.
don't forget to enable GitHub page on your GitHub repo settings
To create a GitHub Actions you need to simply, add this yaml file on /.github/workflows/your-file.yaml
inside your GitHub repository.