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

Add relative path for file nodes #8

Merged
merged 13 commits into from
Apr 9, 2023
13 changes: 0 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,6 @@ def params = [
if (failFast && currentBuild.result == 'UNSTABLE') {
error 'Static analysis quality gates not passed; halting early'
}
/*
* If the current build was successful, we send the commits to Launchable so that
* the result can be consumed by a Launchable build in the future. We do not
* attempt to record commits for non-incrementalified plugins because such
* plugins' PR builds could not be consumed by anything else anyway, and all
* plugins currently in the BOM are incrementalified. We do not attempt to record
* commits on Windows because our Windows agents do not have Python installed.
*/
if (incrementals && platform != 'windows' && currentBuild.currentResult == 'SUCCESS') {
launchable.install()
launchable('verify')
launchable('record commit')
}
} else {
echo "Skipping static analysis results for ${stageIdentifier}"
}
Expand Down
147 changes: 145 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</parent>

<artifactId>coverage-model</artifactId>
<version>0.22.0-SNAPSHOT</version>
<version>${revision}${changelist}</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -45,10 +45,12 @@

<properties>
<scmTag>HEAD</scmTag>
<revision>0.19.1</revision>
<revision>0.22.0</revision>
<changelist>-SNAPSHOT</changelist>

<module.name>edu.hm.hafner.coverage</module.name>

<incrementals-plugin.version>1.6</incrementals-plugin.version>
</properties>

<build>
Expand All @@ -63,6 +65,19 @@
<entryPointClassPackage>edu.hm.hafner.coverage.assertions</entryPointClassPackage>
</configuration>
</plugin>
<plugin>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>incrementals-maven-plugin</artifactId>
<version>${incrementals-plugin.version}</version>
<configuration>
<includes>
<include>org.jenkins-ci.*</include>
<include>io.jenkins.*</include>
</includes>
<generateBackupPoms>false</generateBackupPoms>
<updateNonincremental>false</updateNonincremental>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand All @@ -89,6 +104,134 @@
</plugins>
</build>

<profiles>
<profile>
<id>might-produce-incrementals</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<updatePomFile>true</updatePomFile>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
<configuration>
<flattenMode>oss</flattenMode>
<outputDirectory>${project.build.directory}</outputDirectory>
<flattenedPomFilename>${project.artifactId}-${project.version}.pom</flattenedPomFilename>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>display-info</id>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.5.0,)</version>
<message>3.5.0+ required to use Incrementals.</message>
</requireMavenVersion>
<rule implementation="io.jenkins.tools.incrementals.enforcer.RequireExtensionVersion">
<version>[1.0-beta-4,)</version>
</rule>
</rules>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>incrementals-enforcer-rules</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<completionGoals>incrementals:reincrementalify</completionGoals>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>produce-incrementals</id>
<activation>
<property>
<name>set.changelist</name>
<value>true</value>
</property>
</activation>
<distributionManagement>
<repository>
<id>incrementals</id>
<url>https://repo.jenkins-ci.org/incrementals/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<!-- Copied from jenkins-release: -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>benchmark</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
<includes>
<include>**/*Benchmark.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down
38 changes: 37 additions & 1 deletion src/main/java/edu/hm/hafner/coverage/CoverageParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import edu.hm.hafner.util.FilteredLog;
import edu.hm.hafner.util.SecureXmlParserFactory.ParsingException;
import edu.hm.hafner.util.TreeStringBuilder;

/**
* Parses a file and returns the code coverage information in a tree of {@link Node} instances.
Expand All @@ -18,6 +19,7 @@
*/
public abstract class CoverageParser implements Serializable {
private static final long serialVersionUID = 3941742254762282096L;
private transient TreeStringBuilder treeStringBuilder = new TreeStringBuilder();

/**
* Parses a report provided by the given reader.
Expand All @@ -31,7 +33,41 @@ public abstract class CoverageParser implements Serializable {
* @throws ParsingException
* if the XML content cannot be read
*/
public abstract ModuleNode parse(Reader reader, FilteredLog log);
public ModuleNode parse(final Reader reader, final FilteredLog log) {
var moduleNode = parseReport(reader, log);
getTreeStringBuilder().dedup();
return moduleNode;
}

/**
* Called after de-serialization to restore transient fields.
*
* @return this
*/
@SuppressWarnings("PMD.NullAssignment")
protected Object readResolve() {
treeStringBuilder = new TreeStringBuilder();

return this;
}

public final TreeStringBuilder getTreeStringBuilder() {
return treeStringBuilder;
}

/**
* Parses a report provided by the given reader.
*
* @param reader
* the reader with the coverage information
* @param log
* the logger to write messages to
*
* @return the root of the created tree
* @throws ParsingException
* if the XML content cannot be read
*/
protected abstract ModuleNode parseReport(Reader reader, FilteredLog log);

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'log' is never used.

protected static Optional<String> getOptionalValueOf(final StartElement element, final QName attribute) {
Attribute value = element.getAttributeByName(attribute);
Expand Down
Loading