Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPLUGIN-510] group history per common requirements #274

Merged
merged 1 commit into from
Mar 24, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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<')
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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());
}
}