This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new eb53c5d Group dependencies by scope in Reproducible Central report;
add smoke test (fixes #191) (#193)
eb53c5d is described below
commit eb53c5d432a90b3d3a5f79273ea635cb55528e88
Author: Srikanth S <[email protected]>
AuthorDate: Fri Dec 12 08:17:17 2025 +0530
Group dependencies by scope in Reproducible Central report; add smoke test
(fixes #191) (#193)
---
.../buildinfo/ReproducibleCentralReport.java | 57 +++++++++++++++++++---
.../ReproducibleCentralReportSmokeTest.java | 49 +++++++++++++++++++
2 files changed, 100 insertions(+), 6 deletions(-)
diff --git
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReport.java
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReport.java
index 56fba98..cb5e0e6 100644
---
a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReport.java
+++
b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReport.java
@@ -19,7 +19,10 @@
package org.apache.maven.plugins.artifact.buildinfo;
import java.util.Locale;
+import java.util.Map;
import java.util.TreeMap;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.doxia.sink.Sink;
@@ -77,13 +80,55 @@ public class ReproducibleCentralReport extends
AbstractMavenReport {
sink.text("project's dependencies:");
sink.paragraph_();
- sink.list();
- new TreeMap<String, Artifact>(project.getArtifactMap()).forEach((key,
a) -> {
- sink.listItem();
- renderReproducibleCentralArtifact(sink, a);
- sink.listItem_();
+ // Group dependencies by scope to help prioritization (compile first,
then provided, runtime, test, system, import)
+ Map<String, List<Artifact>> byScope = new TreeMap<>();
+ project.getArtifacts().forEach(a -> {
+ String sc = a.getScope();
+ if (sc == null) {
+ sc = "compile"; // treat null as compile (Maven default)
+ }
+ byScope.computeIfAbsent(sc, k -> new ArrayList<>()).add(a);
});
- sink.list_();
+
+ // Define preferred scope order
+ String[] orderedScopes = new String[] {"compile", "provided",
"runtime", "test", "system", "import"};
+
+ // Render groups in order; any other scopes (or missing) will be
rendered afterwards sorted by name
+ for (String scope : orderedScopes) {
+ List<Artifact> list = byScope.remove(scope);
+ if (list != null && !list.isEmpty()) {
+ sink.sectionTitle2();
+ sink.text(scope + " dependencies:");
+ sink.sectionTitle2_();
+ sink.list();
+ list.stream()
+ .sorted((a1, a2) -> (a1.getGroupId() +
a1.getArtifactId()).compareTo(a2.getGroupId() + a2.getArtifactId()))
+ .forEach(a -> {
+ sink.listItem();
+ renderReproducibleCentralArtifact(sink, a);
+ sink.listItem_();
+ });
+ sink.list_();
+ }
+ }
+
+ // Any remaining scopes
+ if (!byScope.isEmpty()) {
+ byScope.forEach((scope, list) -> {
+ sink.sectionTitle2();
+ sink.text((scope == null ? "(no scope)" : scope) + "
dependencies:");
+ sink.sectionTitle2_();
+ sink.list();
+ list.stream()
+ .sorted((a1, a2) -> (a1.getGroupId() +
a1.getArtifactId()).compareTo(a2.getGroupId() + a2.getArtifactId()))
+ .forEach(a -> {
+ sink.listItem();
+ renderReproducibleCentralArtifact(sink, a);
+ sink.listItem_();
+ });
+ sink.list_();
+ });
+ }
sink.paragraph();
sink.text("(*) ");
diff --git
a/src/test/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReportSmokeTest.java
b/src/test/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReportSmokeTest.java
new file mode 100644
index 0000000..3c2b899
--- /dev/null
+++
b/src/test/java/org/apache/maven/plugins/artifact/buildinfo/ReproducibleCentralReportSmokeTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.artifact.buildinfo;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Simple smoke test that checks the generated Reproducible Central report
contains scope headings.
+ *
+ * Note: this test assumes the site has been generated and the report exists at
+ * target/site/reproducible-central.html. This mirrors existing project tests
that operate on
+ * generated-site/target outputs.
+ */
+public class ReproducibleCentralReportSmokeTest {
+ @Test
+ public void testScopeHeadingsPresent() throws Exception {
+ File report = new File("target/site/reproducible-central.html");
+ assertTrue("Reproducible Central report should exist: " +
report.getPath(), report.exists());
+
+ String content = new String(Files.readAllBytes(report.toPath()),
StandardCharsets.UTF_8);
+
+ assertTrue("Should contain compile heading",
content.contains("<h2>compile dependencies:</h2>"));
+ assertTrue("Should contain provided heading",
content.contains("<h2>provided dependencies:</h2>"));
+ assertTrue("Should contain runtime heading",
content.contains("<h2>runtime dependencies:</h2>"));
+ assertTrue("Should contain test heading", content.contains("<h2>test
dependencies:</h2>"));
+ }
+}