RED-8632 - Generate javadoc automatically
This commit is contained in:
parent
7e144e30bf
commit
9dfb0f49c6
@ -21,3 +21,18 @@ deploy:
|
|||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
- if: $CI_COMMIT_BRANCH =~ /^release/
|
- if: $CI_COMMIT_BRANCH =~ /^release/
|
||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
|
|
||||||
|
generateJavaDoc:
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- dind
|
||||||
|
script:
|
||||||
|
- echo "Generating Javadoc..."
|
||||||
|
- gradle generateJavaDoc -PjavadocDestinationDir="javadoc"
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- redaction-service-v1/redaction-service-server-v1/javadoc/*
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
|
- if: $CI_COMMIT_BRANCH =~ /^release/
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
@ -113,3 +113,42 @@ tasks.named<BootBuildImage>("bootBuildImage") {
|
|||||||
tags.set(listOf(dockerTag))
|
tags.set(listOf(dockerTag))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun parseDroolsImports(droolsFilePath: String): List<String> {
|
||||||
|
|
||||||
|
val imports = mutableListOf<String>()
|
||||||
|
val importPattern = Regex("^import\\s+(com\\.iqser\\.red\\.service\\.redaction\\.v1\\.[\\w.]+);")
|
||||||
|
val desiredPrefix = "com.iqser.red.service.redaction.v1"
|
||||||
|
|
||||||
|
File(droolsFilePath).forEachLine { line ->
|
||||||
|
importPattern.find(line)?.let { matchResult ->
|
||||||
|
val importPath = matchResult.groupValues[1].trim()
|
||||||
|
if (importPath.startsWith(desiredPrefix)) {
|
||||||
|
val formattedPath = importPath.replace('.', '/')
|
||||||
|
imports.add("$formattedPath.java")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return imports
|
||||||
|
}
|
||||||
|
|
||||||
|
val droolsImports = parseDroolsImports("redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl")
|
||||||
|
|
||||||
|
tasks.register("generateJavaDoc", Javadoc::class) {
|
||||||
|
|
||||||
|
dependsOn("compileJava")
|
||||||
|
dependsOn("delombok")
|
||||||
|
classpath = project.sourceSets["main"].runtimeClasspath
|
||||||
|
source = fileTree("${buildDir}/generated/sources/delombok/java/main") {
|
||||||
|
include(droolsImports)
|
||||||
|
}
|
||||||
|
destinationDir = file(project.findProperty("javadocDestinationDir")?.toString() ?: "")
|
||||||
|
|
||||||
|
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||||
|
(options as StandardJavadocDocletOptions).apply {
|
||||||
|
header = "Redaction Service ${project.version}"
|
||||||
|
footer = "Redaction Service ${project.version}"
|
||||||
|
title = "API Documentation for Redaction Service ${project.version}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ import static org.wildfly.common.Assert.assertTrue;
|
|||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -25,8 +26,18 @@ public class DroolsUpToDateTest {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void assertAllRuleFilesAreUpToDate() {
|
public void assertAllRuleFilesAreUpToDate() {
|
||||||
|
|
||||||
Path droolsPath = new ClassPathResource("drools").getFile().toPath();
|
Path testResourcesDroolsPath = new ClassPathResource("drools").getFile().toPath();
|
||||||
Files.walk(droolsPath)
|
processPath(testResourcesDroolsPath);
|
||||||
|
|
||||||
|
Path mainResourcesDroolsPath = Paths.get("src/main/resources/drools/all_rules_documine.drl");
|
||||||
|
processPath(mainResourcesDroolsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private void processPath(Path path) {
|
||||||
|
|
||||||
|
Files.walk(path)
|
||||||
.filter(DroolsUpToDateTest::isEntityRuleFile)
|
.filter(DroolsUpToDateTest::isEntityRuleFile)
|
||||||
.forEach(this::validateFile);
|
.forEach(this::validateFile);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user