From d3f438682d579529ba72475e1549b9c0efc3b9cf Mon Sep 17 00:00:00 2001 From: Christoph Pirkl <4711730+kaklakariada@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:37:13 +0200 Subject: [PATCH] #9: Downgrade required Maven version (#10) --- dependencies.md | 4 +- doc/changes/changelog.md | 1 + doc/changes/changes_0.2.0.md | 22 +++++++++ pk_generated_parent.pom | 2 +- pom.xml | 14 +++--- .../com/exasol/swqa/maven/SummarizerMojo.java | 46 ++++++++++--------- 6 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 doc/changes/changes_0.2.0.md diff --git a/dependencies.md b/dependencies.md index 048ba97..f1f9cdb 100644 --- a/dependencies.md +++ b/dependencies.md @@ -48,9 +48,9 @@ | [Reproducible Build Maven Plugin][42] | [Apache 2.0][5] | | [Apache Maven Dependency Plugin][43] | [Apache-2.0][1] | -[0]: https://maven.apache.org/ref/3.8.8/maven-plugin-api/ +[0]: https://maven.apache.org/ref/3.8.7/maven-plugin-api/ [1]: https://www.apache.org/licenses/LICENSE-2.0.txt -[2]: https://maven.apache.org/ref/3.8.8/maven-core/ +[2]: https://maven.apache.org/ref/3.8.7/maven-core/ [3]: https://maven.apache.org/plugin-tools/maven-plugin-annotations [4]: https://github.com/google/guava [5]: http://www.apache.org/licenses/LICENSE-2.0.txt diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index 9e62d07..39f13d8 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,3 +1,4 @@ # Changes +* [0.2.0](changes_0.2.0.md) * [0.1.0](changes_0.1.0.md) diff --git a/doc/changes/changes_0.2.0.md b/doc/changes/changes_0.2.0.md new file mode 100644 index 0000000..a4885d3 --- /dev/null +++ b/doc/changes/changes_0.2.0.md @@ -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` diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index ee483f7..0f5e23a 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol quality-summarizer-maven-plugin-generated-parent - 0.1.0 + 0.2.0 pom UTF-8 diff --git a/pom.xml b/pom.xml index 44d8f4a..98d9eab 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ com.exasol quality-summarizer-maven-plugin - 0.1.0 + 0.2.0 Maven plugin that summarizes quality metrics from different source into a single file maven-plugin 17 - 3.8.8 + 3.8.7 3.15.0 @@ -39,7 +39,7 @@ org.junit.jupiter junit-jupiter-params - 5.11.0 + 5.11.3 test @@ -72,14 +72,14 @@ commons-io commons-io - 2.16.1 + 2.17.0 test com.google.guava guava - 33.2.1-jre + 33.3.1-jre provided @@ -156,7 +156,7 @@ a separate process. --> org.apache.maven.plugins maven-dependency-plugin - 3.7.1 + 3.8.0 copy-jacoco @@ -179,7 +179,7 @@ quality-summarizer-maven-plugin-generated-parent com.exasol - 0.1.0 + 0.2.0 pk_generated_parent.pom diff --git a/src/main/java/com/exasol/swqa/maven/SummarizerMojo.java b/src/main/java/com/exasol/swqa/maven/SummarizerMojo.java index d919ecc..e652028 100644 --- a/src/main/java/com/exasol/swqa/maven/SummarizerMojo.java +++ b/src/main/java/com/exasol/swqa/maven/SummarizerMojo.java @@ -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. *

- * The goal "summarize" and runs in the default phase "VERIFY". + * The goal "summarize" and runs in the default phase {@code VERIFY}. *

*/ // [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() { @@ -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."); } } @@ -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; @@ -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); } } @@ -150,4 +154,4 @@ private static String generateSummaryJSON(final float coverage) { } """.formatted(coverageAsUSLocaleString); } -} \ No newline at end of file +}