Skip to content

Commit

Permalink
#9: Downgrade required Maven version (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada authored Oct 22, 2024
1 parent 675837a commit d3f4386
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 31 deletions.
4 changes: 2 additions & 2 deletions dependencies.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions doc/changes/changelog.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions doc/changes/changes_0.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Quality Summarizer Maven Plugin 0.2.0, released 2024-??-??

Code name: Downgrade Maven Version

## Summary

This version downgrades the required Maven version from 3.8.8 to 3.8.7, allowing this plugin to work on GitHub action runners `windows-latest`.

## Bugfixes

* #9: Downgrade required Maven version

## Dependency Updates

### Test Dependency Updates

* Updated `commons-io:commons-io:2.16.1` to `2.17.0`
* Updated `org.junit.jupiter:junit-jupiter-params:5.11.0` to `5.11.3`

### Plugin Dependency Updates

* Updated `org.apache.maven.plugins:maven-dependency-plugin:3.7.1` to `3.8.0`
2 changes: 1 addition & 1 deletion pk_generated_parent.pom

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<groupId>com.exasol</groupId>
<!-- Do not remove even if this is redundant. The integration test requires it. -->
<artifactId>quality-summarizer-maven-plugin</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
<description>Maven plugin that summarizes quality metrics from different source into a single file</description>
<packaging>maven-plugin</packaging>
<properties>
<java.version>17</java.version>
<maven.core.version>3.8.8</maven.core.version>
<maven.core.version>3.8.7</maven.core.version>
<maven.plugin.plugin.version>3.15.0</maven.plugin.plugin.version>
</properties>
<prerequisites>
Expand Down Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.11.0</version>
<version>5.11.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -72,14 +72,14 @@
<!-- Fix CVE-2021-29425 in dependency of maven-plugin-testing-harness -->
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
<version>2.17.0</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- Fix CWE-552 & CWE-379 in dependency of maven-core -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
<version>33.3.1-jre</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -156,7 +156,7 @@
a separate process. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.0</version>
<executions>
<execution>
<id>copy-jacoco</id>
Expand All @@ -179,7 +179,7 @@
<parent>
<artifactId>quality-summarizer-maven-plugin-generated-parent</artifactId>
<groupId>com.exasol</groupId>
<version>0.1.0</version>
<version>0.2.0</version>
<relativePath>pk_generated_parent.pom</relativePath>
</parent>
</project>
46 changes: 25 additions & 21 deletions src/main/java/com/exasol/swqa/maven/SummarizerMojo.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
package com.exasol.swqa.maven;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;

import javax.inject.Inject;
import javax.xml.XMLConstants;
import javax.xml.parsers.*;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.*;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;

/**
* The SummarizerMojo class is a Maven plugin goal that performs quality metric summarization.
* <p>
* The goal "summarize" and runs in the default phase "VERIFY".
* The goal "summarize" and runs in the default phase {@code VERIFY}.
* </p>
*/
// [impl -> dsn~maven-plugin~1]
// [impl -> dsn~os-compatibility~1]
// [impl -> dsn~executed-during-verify-phase~1]
@Mojo(name = "summarize", defaultPhase = LifecyclePhase.VERIFY)
@SuppressWarnings("unused")
public class SummarizerMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
@SuppressWarnings("unused")
private MavenProject project;

/**
* Create a new instance. This is called by Maven and injects the project.
*
* @param project current maven project
*/
@Inject
public SummarizerMojo(final MavenProject project) {
this.project = project;
}

@Override
// [impl -> qs~failing-safely-when-summarization-breaks~1]
public void execute() {
Expand All @@ -45,7 +49,7 @@ public void execute() {
// We intentionally don't provide a stack trace here. This is expected fail-safe behavior, and we should not
// spam the log when failing safely.
getLog().warn("The following issue occurred during quality metric summarization: '" + exception.getMessage()
+ "' Continuing build since this step is optional: ");
+ "' Continuing build since this step is optional.");
}
}

Expand Down Expand Up @@ -91,7 +95,7 @@ private float calculateBranchCoverage(final Element counterNode) {
final int missedBranches = Integer.parseInt(counterNode.getAttribute("missed"));
final int coveredBranches = Integer.parseInt(counterNode.getAttribute("covered"));
final int allBranches = missedBranches + coveredBranches;
float branchCoveragePercentage = (coveredBranches * 100.0f) / allBranches;
final float branchCoveragePercentage = (coveredBranches * 100.0f) / allBranches;
getLog().info("Branch coverage is " + branchCoveragePercentage + "%. " + coveredBranches + " of " + allBranches
+ " covered.");
return branchCoveragePercentage;
Expand Down Expand Up @@ -134,7 +138,7 @@ private void writeSummaryFile(final Path mavenTargetPath, final float coverage)
final String summary = generateSummaryJSON(coverage);
try {
Files.writeString(summaryFilePath, summary);
} catch (IOException exception) {
} catch (final IOException exception) {
throw new MojoFailureException("Unable to write quality summary file: " + summaryFilePath, exception);
}
}
Expand All @@ -150,4 +154,4 @@ private static String generateSummaryJSON(final float coverage) {
}
""".formatted(coverageAsUSLocaleString);
}
}
}

0 comments on commit d3f4386

Please sign in to comment.