gradle - How to generate javadoc with puml diagrams?
问题描述
I am trying to generate my Javadoc with my sequence diagrams integrated using Gradle 8.0(7.2).
my 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
}
Right now the expected output is only accomplished on the second I run gradle javadoc
being the sequence of steps the following one :
gradle renderPlantUml
gradle javadoc
This results in overview.html not finding the diagrams as in the picture bellow .
Then I need to repeat the above commands so the expected output is the right one . See the picture below for reference .
What do I need to change in my build.gradle?
解决方案
您需要配置 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">
*/