Skip to content

Commit

Permalink
[MPLUGIN-510] group history per common requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Mar 23, 2024
1 parent 6f9c3d9 commit 958bb30
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
Expand Up @@ -24,8 +24,8 @@ under the License.
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-report-plugin</artifactId><!-- intentionally reuse plugin's groupId:artifactId to build its releases history -->
<version>1.0-SNAPSHOT</version>
<artifactId>maven-assembly-plugin</artifactId><!-- intentionally reuse plugin's groupId:artifactId to build its releases history -->
<version>3.7.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>MPLUGIN-511</name>
Expand Down Expand Up @@ -84,6 +84,9 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-report-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<requirementsHistoryDetectionRange>[3,3.7.0]</requirementsHistoryDetectionRange>
</configuration>
</plugin>
</plugins>
</reporting>
Expand Down
Expand Up @@ -22,8 +22,6 @@ assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
assert pluginInfo.isFile()

assert pluginInfo.text.contains('3.11.0')
assert pluginInfo.text.contains('3.10.2')
assert pluginInfo.text.contains('3.9.0')
assert pluginInfo.text.contains('3.7.0')
assert pluginInfo.text.contains('from 3.4.0 to 3.6.0')
assert pluginInfo.text.contains('>3.2.5<')
assert pluginInfo.text.contains('>8<')
Expand Up @@ -211,11 +211,32 @@ private void renderRequirementsHistoriesSection() {
getI18nString("systemrequirements.history.jdk")
});

// group by same requirements
final List<List<RequirementsHistory>> requirementsVersions = new ArrayList<>();
requirementsHistories.forEach(requirementsHistory -> {
List<RequirementsHistory> current =
requirementsVersions.isEmpty() ? null : requirementsVersions.get(requirementsVersions.size() - 1);
if (current != null && current.get(0).hasSameRequirements(requirementsHistory)) {
current.add(requirementsHistory);
} else {
current = new ArrayList<>();
current.add(requirementsHistory);
requirementsVersions.add(current);
}
});

// render by common requirements
requirementsVersions.forEach(requirementsHistories -> {
sink.tableRow();
tableCell(requirementsHistory.getVersion());
tableCell(requirementsHistory.getMaven());
tableCell(requirementsHistory.getJdk());
RequirementsHistory current = requirementsHistories.get(0);
if (requirementsHistories.size() == 1) {
tableCell(current.getVersion());
} else {
RequirementsHistory from = requirementsHistories.get(requirementsHistories.size() - 1);
tableCell("from " + from.getVersion() + " to " + current.getVersion());
}
tableCell(current.getMaven());
tableCell(current.getJdk());
sink.tableRow_();
});
endTable();
Expand Down
Expand Up @@ -189,8 +189,14 @@ protected void executeReport(Locale locale) throws MavenReportException {
String v = null;
try {
List<Version> versions = discoverVersions(requirementsHistoryDetectionRange);
getLog().info("Detecting requirements history for " + requirementsHistoryDetectionRange + ": "
+ versions.size());
if (versions.isEmpty()) {
getLog().info("No plugin history found for range " + requirementsHistoryDetectionRange);
} else {
getLog().info("Detecting plugin requirements history for range "
+ requirementsHistoryDetectionRange + ": "
+ versions.size() + " releases, from " + versions.get(0) + " to "
+ versions.get(versions.size() - 1));
}

Collections.reverse(versions);
for (Version version : versions) {
Expand Down
Expand Up @@ -20,6 +20,7 @@

import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -173,4 +174,8 @@ private static String getPluginParameter(Plugin plugin, String parameter) {

return null;
}

public boolean hasSameRequirements(RequirementsHistory other) {
return Objects.equals(this.maven, other.getMaven()) && Objects.equals(this.jdk, other.getJdk());
}
}

0 comments on commit 958bb30

Please sign in to comment.