Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion jig-cli/src/main/java/org/dddjava/jig/cli/CliRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.dddjava.jig.HandleResult;
import org.dddjava.jig.JigExecutor;
import org.dddjava.jig.JigResult;
import org.dddjava.jig.domain.model.sources.filesystem.SourceBasePaths;
import org.dddjava.jig.infrastructure.configuration.Configuration;
import org.slf4j.Logger;
Expand Down Expand Up @@ -33,12 +34,17 @@ void run() {
long startTime = System.currentTimeMillis();
SourceBasePaths sourceBasePaths = cliConfig.rawSourceLocations();

List<HandleResult> handleResultList = JigExecutor.standard(configuration, sourceBasePaths).listResult();
JigResult jigResult = JigExecutor.standard(configuration, sourceBasePaths);
List<HandleResult> handleResultList = jigResult.listResult();

String resultLog = handleResultList.stream()
.filter(HandleResult::success)
.map(handleResult -> handleResult.jigDocument() + " : " + handleResult.outputFilePathsText())
.collect(joining("\n"));
if (!resultLog.isBlank()) {
resultLog += "\n";
}
resultLog += "index : [ " + jigResult.indexFilePath() + " ]";
logger.info("-- Output Complete {} ms -------------------------------------------\n{}\n------------------------------------------------------------",
System.currentTimeMillis() - startTime,
resultLog);
Expand Down
3 changes: 2 additions & 1 deletion jig-core/src/main/java/org/dddjava/jig/JigResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public interface JigResult {

JigSummary summary();

java.nio.file.Path indexFilePath();

/**
* 集計
*/
Expand All @@ -25,4 +27,3 @@ public static JigSummary empty() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public JigResult generate(JigRepository jigRepository) {

generateIndex(handleResults);
generateAssets();
return new JigResultData(handleResults);
return new JigResultData(handleResults, IndexView.indexFilePath(outputDirectory));
}

private void prepareOutputDirectory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import org.dddjava.jig.HandleResult;
import org.dddjava.jig.JigResult;

import java.nio.file.Path;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;

record JigResultData(Collection<HandleResult> handleResults) implements JigResult {
record JigResultData(Collection<HandleResult> handleResults, Path indexFilePath) implements JigResult {

@Override
public List<HandleResult> listResult() {
Expand All @@ -20,4 +21,9 @@ public List<HandleResult> listResult() {
public JigSummary summary() {
throw new UnsupportedOperationException();
}

@Override
public Path indexFilePath() {
return indexFilePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.*;

public class IndexView {
static final String INDEX_FILE_NAME = "index.html";

private final Map<String, Object> contextMap;
private final TemplateEngine templateEngine;
Expand Down Expand Up @@ -53,7 +54,7 @@ private void write(Path outputDirectory) {
contextMap.put("jigVersion", resolveJigVersion());
contextMap.put("timestamp", ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS));

Path outputFilePath = outputDirectory.resolve("index.html");
Path outputFilePath = indexFilePath(outputDirectory);
try (OutputStream out = Files.newOutputStream(outputFilePath);
OutputStream outputStream = new BufferedOutputStream(out);
Writer writer = new java.io.OutputStreamWriter(outputStream, StandardCharsets.UTF_8)
Expand All @@ -64,6 +65,10 @@ private void write(Path outputDirectory) {
}
}

public static Path indexFilePath(Path outputDirectory) {
return outputDirectory.resolve(INDEX_FILE_NAME);
}

class DiagramComponent {
JigDocument jigDocument;
List<String> srcList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.dddjava.jig.HandleResult;
import org.dddjava.jig.JigExecutor;
import org.dddjava.jig.JigResult;
import org.dddjava.jig.domain.model.sources.filesystem.SourceBasePaths;
import org.dddjava.jig.infrastructure.configuration.Configuration;
import org.gradle.api.DefaultTask;
Expand Down Expand Up @@ -30,12 +31,17 @@ void outputReports() {
long startTime = System.currentTimeMillis();
SourceBasePaths sourceBasePaths = new GradleProject(project).rawSourceLocations();

List<HandleResult> handleResultList = JigExecutor.standard(configuration, sourceBasePaths).listResult();
JigResult jigResult = JigExecutor.standard(configuration, sourceBasePaths);
List<HandleResult> handleResultList = jigResult.listResult();

String resultLog = handleResultList.stream()
.filter(HandleResult::success)
.map(handleResult -> handleResult.jigDocument() + " : " + handleResult.outputFilePathsText())
.collect(joining("\n"));
if (!resultLog.isBlank()) {
resultLog += "\n";
}
resultLog += "index : [ " + jigResult.indexFilePath() + " ]";
getLogger().info("-- Output Complete {} ms -------------------------------------------\n{}\n------------------------------------------------------------",
System.currentTimeMillis() - startTime, resultLog);
}
Expand Down