【问题标题】:How to generate javadoc with puml diagrams?如何使用 puml 图生成 javadoc?
【发布时间】:2021-12-08 15:59:34
【问题描述】:

我正在尝试使用 Gradle 8.0(7.2) 集成的序列图生成我的 Javadoc。

我的 build.gradle :

apply plugin: "java"
apply plugin: "application"


mainClassName = 'com.twu.calculator.CalculatorApp'
group = 'calculator'
version = '1.0-SNAPSHOT'
description = "Calculator Console App"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'junit:junit:4.12'
    testImplementation 'com.github.stefanbirkner:system-rules:1.16.1'
}

task renderPlantUml(type: RenderPlantUmlTask) {

}

javadoc {
    source = sourceSets.main.allJava
    options.overview = "src/main/javadoc/overview.html" // relative to source root
    options.addStringOption("sourcepath","${projectDir}/src/main/javadoc")
}

javadoc.dependsOn renderPlantUml

// To execute the app
task runApp (type: JavaExec, dependsOn: classes){
    /* Can pass all the properties: */
    systemProperties System.getProperties()
    standardInput = System.in
    description = "Running the Calculator"
    main = "com.twu.calculator.CalculatorApp"
    classpath = sourceSets.main.runtimeClasspath
}

目前,预期的输出仅在我运行gradle javadoc的第二次完成,即以下步骤的顺序:

gradle renderPlantUml
gradle javadoc

这会导致overview.html 找不到如下图所示的图表。

overview.html

然后我需要重复上述命令,以便预期的输出是正确的。参考下图。

Expected output

我需要在我的build.gradle? 中更改什么

【问题讨论】:

    标签: gradle build javadoc sequence-diagram


    【解决方案1】:

    您需要配置 Javadoc 任务以复制要包含的文件,例如图像。

    javadoc {
        doLast {
            copy {
                from('src/main/java')
                into("$buildDir/docs/javadoc/")
                include("**/doc-files/**/*")
            }
        }
    }
    

    将您的图像放在您的班级所在的同一个包中,该包位于名为 doc-files/ 的文件夹中

    然后将它们包含在您的 Javadoc 中:

    /**
     * <img src="doc-files/path/to/image.jpg">
     */
    

    https://github.com/gradle/gradle/issues/4046

    【讨论】:

      猜你喜欢
      • 2018-02-10
      • 2020-07-15
      • 2012-12-16
      • 2013-06-07
      • 2012-04-15
      • 2023-03-30
      • 2016-07-01
      • 2010-11-22
      • 1970-01-01
      相关资源
      最近更新 更多