Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,32 @@ jobs:
- uses: actions/checkout@v2

# https://github.com/marketplace/actions/setup-java-jdk#publishing-using-apache-maven
- uses: actions/setup-java@v1
- uses: actions/setup-java@v4
with:
java-version: '8'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
java-version: '17'
distribution: zulu
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
gpg-passphrase: GPG_PASSPHRASE

- name: Build (and publish to Sonatype OSSRH when on master)
- name: Build (and publish to Maven Central when on master)
run: |
MAVEN_TASK="verify"
# only use -P release when on master branch
if [ ${GITHUB_REF#refs/heads/} == "master" ]; then MAVEN_PROFILE="deploy -P release"; fi
mvn -V -B clean install $MAVEN_PROFILE
if [ ${GITHUB_REF#refs/heads/} == "master" ]; then MAVEN_TASK="deploy -P release"; fi
mvn -V -B $MAVEN_TASK
env:
OSSRH_USERNAME: qqilihq
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v5
with:
file: ./target/site/jacoco/jacoco.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

# TODO parse surefire reports
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target/
.settings/
.classpath
.project
settings.xml
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ About
This [Maven][3] plugin solves the following issue which I described in [this][2] Stack Overflow question:

> I'm running a Maven build workflow which involves running a 3rd party tool for integration testing, which produces multiple XML files in JUnit style (however, those files are **not** created by JUnit and I have no control over the testing procedure).
>
>
> Is there a Maven plugin, which allows me to parse those files? Especially, I would like the build to fail, in case those XML files list a failure.
>
>
> My exact problem has been described [here][1] some years ago, and the proposed solutions were:
>
>
> 1. *"Write your own plugin to call your external test and report failures,
either by parsing the xml or some other approach"* -- potential solution, however I hope that some years later maybe there is something ready-to-use?
> 2. *"Adjust your external test tool so it returns "false" (1) when it has a
Expand All @@ -34,8 +34,8 @@ Add it to your `pom.xml` within the `<build>` section as follows and specify the
<build>
<plugins>
<plugin>
<groupId>de.philippkatz.maven.plugins</groupId>
<artifactId>test-parser-plugin</artifactId>
<groupId>de.philippkatz</groupId>
<artifactId>test-parser-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<resultsDirectory>${project.build.directory}/testflow-reports</resultsDirectory>
Expand Down Expand Up @@ -70,7 +70,7 @@ opening a new [issue][2].

- - -

Copyright (c) 2017 – 2020, Philipp Katz
Copyright (c) 2017 – 2025, Philipp Katz


[1]: http://maven.40175.n5.nabble.com/How-to-parse-JUnit-report-xml-that-causes-build-to-pass-fail-td5433750.html
Expand Down
16 changes: 16 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## unreleased

### Changed
* Change Maven group ID to `de.philippkatz` and artifact ID to `test-parser-maven-plugin`.

### Fixed
* Update `jacoco-maven-plugin` to `0.8.12` for Java 17 compatibility.

## 3.1.0 – 2018-08-23
50 changes: 17 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.philippkatz.maven.plugins</groupId>
<artifactId>test-parser-plugin</artifactId>
<groupId>de.philippkatz</groupId>
<artifactId>test-parser-maven-plugin</artifactId>
Comment thread
qqilihq marked this conversation as resolved.
<packaging>maven-plugin</packaging>
<version>3.1.1-SNAPSHOT</version>

Expand Down Expand Up @@ -32,26 +32,16 @@
<url>http://github.com/qqilihq/maven-test-parser-plugin/tree/master</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
<version>3.13.1</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
Expand All @@ -66,28 +56,20 @@
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<version>0.8.12</version>
<executions>
<execution>
<id>default-prepare-agent</id>
Expand Down Expand Up @@ -115,7 +97,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -128,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.7.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -141,7 +123,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -155,7 +137,9 @@
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.keyname}</passphraseServerId>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/de/philippkatz/maven/plugins/TestParserMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

/**
* Goal to parse JUnit-style XML results.
*
*
* @author Philipp Katz
*/
@Mojo(name = "testparser", requiresProject = false)
public class TestParserMojo extends AbstractMojo {

private static final String SKIPPED = "skipped";

/** Directory which contains the reports. */
Expand Down Expand Up @@ -71,8 +71,8 @@ public void execute() throws MojoExecutionException {
}
Map<String, String> summary = parser.getSummary(parsedReports);
getLog().info(String.format("Tests run: %s, Failures: %s, Errors: %s, Skipped: %s",
summary.get("totalTests"),
summary.get("totalFailures"),
summary.get("totalTests"),
summary.get("totalFailures"),
summary.get("totalErrors"),
summary.get("totalSkipped")));
if (!errors.isEmpty() && !failures.isEmpty()) {
Expand All @@ -88,10 +88,10 @@ public void execute() throws MojoExecutionException {

/**
* Walks over a tree of directories and recursively adds all these directories to a list of <code>File</code> objects.
*
*
* @param rootDirectory The root directory from where to start the search for sub directories.
* @return A <code>List</code> of the directory provided as root and all its sub directories.
* @throws MojoExecutionException
* @throws MojoExecutionException
*/
static List<File> collectReportDirectoriesRecursively(final File rootDirectory) throws MojoExecutionException {
if (rootDirectory == null) {
Expand All @@ -103,16 +103,16 @@ static List<File> collectReportDirectoriesRecursively(final File rootDirectory)
if (!rootDirectory.isDirectory()) {
throw new MojoExecutionException("Directory " + rootDirectory + " is no directory");
}

List<File> ret = new ArrayList<>();
ret.add(rootDirectory);

for (File child : rootDirectory.listFiles()) {
if (child.isDirectory()) {
ret.addAll(collectReportDirectoriesRecursively(child));
}
}

return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testTestParserMojoWithoutFailures() {
assertEquals(2, logResult.split("\n").length);
assertTrue(logResult.contains("Tests run: 9, Failures: 0, Errors: 0, Skipped: 0"));
}

@Test
public void testTestParserMojoWithSkipsShouldNotBeTreatedAsFailures() {
TestParserMojo mojo = new TestParserMojo();
Expand All @@ -66,7 +66,7 @@ public void testTestParserMojoWithSkipsShouldNotBeTreatedAsFailures() {

/**
* Tests whether recursive collection of result folders works correctly.
*
*
* @throws MojoExecutionException
* Fails the test if anything unexpected goes wrong.
*/
Expand Down
Loading