Skip to content

Commit

Permalink
Merge pull request #36094 from mkouba/cli-build-report-items
Browse files Browse the repository at this point in the history
CLI build report: add info about produced build items
  • Loading branch information
gsmet authored Sep 22, 2023
2 parents d98090e + 8df6789 commit 1e3fbb9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
22 changes: 20 additions & 2 deletions devtools/cli/src/main/java/io/quarkus/cli/BuildReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class BuildReport {

static native TemplateInstance buildReport(String buildTarget, long duration, Set<String> threads,
List<BuildStepRecord> records);
List<BuildStepRecord> records, List<BuildItem> buildItems, int buildItemsCount);

private final BuildSystemRunner runner;

Expand All @@ -41,6 +41,8 @@ File generate() throws IOException {
long duration = root.get("duration").asLong();
Set<String> threads = new HashSet<>();
List<BuildStepRecord> records = new ArrayList<>();
List<BuildItem> items = new ArrayList<>();
int itemsCount = root.get("itemsCount").asInt();

for (JsonNode record : root.get("records")) {
String thread = record.get("thread").asText();
Expand All @@ -49,14 +51,18 @@ File generate() throws IOException {
record.get("duration").asLong(), thread));
}

for (JsonNode item : root.get("items")) {
items.add(new BuildItem(item.get("class").asText(), item.get("count").asInt()));
}

File output = runner.getProjectRoot().resolve(runner.getBuildTool().getBuildDirectory())
.resolve("build-report.html").toFile();
if (output.exists() && !output.canWrite()) {
throw new IllegalStateException("Build report file cannot be written to: " + output);
}
try {
Files.writeString(output.toPath(),
BuildReport.buildReport(buildTarget, duration, threads, records).render());
BuildReport.buildReport(buildTarget, duration, threads, records, items, itemsCount).render());
return output;
} catch (IOException e) {
throw new IllegalArgumentException(e);
Expand All @@ -79,4 +85,16 @@ public BuildStepRecord(String stepId, String started, long duration, String thre

}

public static class BuildItem {

public final String clazz;
public final int count;

public BuildItem(String clazz, int count) {
this.clazz = clazz;
this.count = count;
}

}

}
39 changes: 37 additions & 2 deletions devtools/cli/src/main/resources/templates/buildReport.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,19 @@
<div class="container">

<h1>Quarkus Build Report - {buildTarget}</h1>

<ul>
<li><a href="#build_steps">Build Steps</a></li>
<li><a href="#build_items">Build Items</a></li>
</ul>

<h2 id="build_steps">Build Steps</h2>

<p class="lead">
Executed <strong>{records.size}</strong> build steps on <strong>{threads.size}</strong> threads in
<strong>{duration}</strong> ms.
</p>

<h2>Build Steps</h2>

<table>
<thead>
<tr>
Expand Down Expand Up @@ -113,6 +118,36 @@ <h2>Build Steps</h2>
{/for}
</tbody>
</table>

<h2 id="build_items">Build Items</h2>

<p class="lead">
Produced <strong>{buildItemsCount}</strong> build items of <strong>{buildItems.size}</strong> types.
</p>

<table>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Build Item Class</th>
<th scope="col">Count</th>
</tr>
</thead>
<tbody>
{#for buildItem in buildItems}
<tr>
<td>{buildItem_count}</td>
<td>
{buildItem.clazz}
</td>
<td>
{buildItem.count}
</td>
{/for}
</tbody>
</table>


</div>

</body>
Expand Down

0 comments on commit 1e3fbb9

Please sign in to comment.