GitHub操作:如何使用Gradle项目生成JavaDoc并将其发布到网页

svgewumm  于 2022-12-13  发布在  Git
关注(0)|答案(1)|浏览(108)

我需要从我的GitHub存储库中生成一个JavaDoc并将其发布到像GitHub Page这样的网页上。
我在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/Javadoc-publisher.yml@v2.0.4
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          javadoc-branch: javadoc
          java-version: 17
          target-folder: javadoc

但此解决方案仅适用于Maven,不适用于Gradle。
有人知道是否有可能将其改编为Gradle项目吗?

t0ybt7op

t0ybt7op1#

JavaDoc publisher for Gradle

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/Javadoc-publisher.yml@v2.3.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          javadoc-branch: javadoc
          java-version: 17
          target-folder: javadoc
          project: gradle

Credit: https://github.com/MathieuSoysal/Javadoc-publisher.ymlhttps://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*

Create a GitHub Actions

To create a GitHub Actions you need to simply, add this yaml file on /.github/workflows/your-file.yaml inside your GitHub repository.

相关问题