Introduce GitConfig for customizable Javadoc paths and enhance Javadoc generation logic
Build and Push Docker Image / build-and-push (push) Successful in 28s
Build and Push Docker Image / build-and-push (push) Successful in 28s
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
package codes.thischwa.jdvs.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "git")
|
||||||
|
@Data
|
||||||
|
public class GitConfig {
|
||||||
|
private List<String> javadocPaths;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package codes.thischwa.jdvs.service;
|
package codes.thischwa.jdvs.service;
|
||||||
|
|
||||||
|
import codes.thischwa.jdvs.config.GitConfig;
|
||||||
import codes.thischwa.jdvs.config.JdvsConfig;
|
import codes.thischwa.jdvs.config.JdvsConfig;
|
||||||
import codes.thischwa.jdvs.config.JdvsConfig.RepoConfig;
|
import codes.thischwa.jdvs.config.JdvsConfig.RepoConfig;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -30,6 +31,7 @@ import org.xml.sax.InputSource;
|
|||||||
public class MavenSourceService {
|
public class MavenSourceService {
|
||||||
|
|
||||||
private final JdvsConfig jdvsConfig;
|
private final JdvsConfig jdvsConfig;
|
||||||
|
private final GitConfig gitConfig;
|
||||||
private final RestClient restClient = RestClient.create();
|
private final RestClient restClient = RestClient.create();
|
||||||
|
|
||||||
public Optional<String> fetchLatestVersion(String repoName) {
|
public Optional<String> fetchLatestVersion(String repoName) {
|
||||||
@@ -68,6 +70,7 @@ public class MavenSourceService {
|
|||||||
Path workDir = null;
|
Path workDir = null;
|
||||||
try {
|
try {
|
||||||
workDir = Files.createTempDirectory("jdvs-maven-" + repoName + "-");
|
workDir = Files.createTempDirectory("jdvs-maven-" + repoName + "-");
|
||||||
|
log.info("Created temporary working directory {}", workDir);
|
||||||
Path srcMainJava = workDir.resolve("src/main/java");
|
Path srcMainJava = workDir.resolve("src/main/java");
|
||||||
Files.createDirectories(srcMainJava);
|
Files.createDirectories(srcMainJava);
|
||||||
downloadAndExtract(jarUrl, workDir, srcMainJava);
|
downloadAndExtract(jarUrl, workDir, srcMainJava);
|
||||||
@@ -129,11 +132,16 @@ public class MavenSourceService {
|
|||||||
Path mavenLocalRepo = Path.of(jdvsConfig.getBaseDir(), "maven-repo").toAbsolutePath();
|
Path mavenLocalRepo = Path.of(jdvsConfig.getBaseDir(), "maven-repo").toAbsolutePath();
|
||||||
Files.createDirectories(mavenLocalRepo);
|
Files.createDirectories(mavenLocalRepo);
|
||||||
|
|
||||||
|
// create empty sonar-project.properties so properties-maven-plugin doesn't fail
|
||||||
|
Files.createFile(workDir.resolve("sonar-project.properties"));
|
||||||
|
|
||||||
List<String> cmd = new ArrayList<>(List.of(
|
List<String> cmd = new ArrayList<>(List.of(
|
||||||
"mvn", "-U", "--no-transfer-progress",
|
"mvn", "-U", "--no-transfer-progress",
|
||||||
"clean", "javadoc:javadoc",
|
"clean", "javadoc:javadoc",
|
||||||
"-Djacoco.skip=true",
|
"-Djacoco.skip=true",
|
||||||
"-DskipTests",
|
"-DskipTests",
|
||||||
|
"-Dsonar.skip=true",
|
||||||
|
"-Dmaven.javadoc.skip=false",
|
||||||
"-Dcheckstyle.skip=true",
|
"-Dcheckstyle.skip=true",
|
||||||
"-Dlombok.delombok.skip=true",
|
"-Dlombok.delombok.skip=true",
|
||||||
"-Dmaven.repo.local=" + mavenLocalRepo
|
"-Dmaven.repo.local=" + mavenLocalRepo
|
||||||
@@ -159,9 +167,12 @@ public class MavenSourceService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path apidocsDir = workDir.resolve("target/reports/apidocs");
|
Path apidocsDir = gitConfig.getJavadocPaths().stream()
|
||||||
if (!Files.exists(apidocsDir)) {
|
.map(workDir::resolve)
|
||||||
// Log actual target content to find where Maven put the output
|
.filter(Files::exists)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (apidocsDir == null) {
|
||||||
Path targetDir = workDir.resolve("target");
|
Path targetDir = workDir.resolve("target");
|
||||||
if (Files.exists(targetDir)) {
|
if (Files.exists(targetDir)) {
|
||||||
try (var s = Files.walk(targetDir, 4)) {
|
try (var s = Files.walk(targetDir, 4)) {
|
||||||
@@ -177,6 +188,7 @@ public class MavenSourceService {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
log.debug("Found apidocs directory at: {}", apidocsDir);
|
||||||
copyDirectory(apidocsDir, outputDir);
|
copyDirectory(apidocsDir, outputDir);
|
||||||
log.info("Javadoc successfully generated for {} in {}", repoName, outputDir);
|
log.info("Javadoc successfully generated for {} in {}", repoName, outputDir);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ jdvs:
|
|||||||
run-on-start: false
|
run-on-start: false
|
||||||
maven-central-url: https://repo1.maven.org/maven2
|
maven-central-url: https://repo1.maven.org/maven2
|
||||||
|
|
||||||
|
git:
|
||||||
|
javadoc-paths:
|
||||||
|
- target/reports/apidocs
|
||||||
|
- target/apidocs
|
||||||
|
- target/site/apidocs
|
||||||
|
|
||||||
## import of the individual configuration settings
|
## import of the individual configuration settings
|
||||||
spring:
|
spring:
|
||||||
config:
|
config:
|
||||||
|
|||||||
Reference in New Issue
Block a user