This repository has been archived by the owner on Feb 26, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JENKINS-4912] Created new action base class for maven aggregation.
- Loading branch information
Showing
4 changed files
with
82 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/main/java/hudson/plugins/pmd/PmdMavenResultAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package hudson.plugins.pmd; | ||
|
||
import hudson.maven.MavenAggregatedReport; | ||
import hudson.maven.MavenBuild; | ||
import hudson.maven.MavenModule; | ||
import hudson.maven.MavenModuleSet; | ||
import hudson.maven.MavenModuleSetBuild; | ||
import hudson.model.Action; | ||
import hudson.plugins.analysis.core.HealthDescriptor; | ||
import hudson.plugins.analysis.core.MavenResultAction; | ||
import hudson.plugins.analysis.core.ParserResult; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* A {@link PmdResultAction} for native Maven jobs. This action | ||
* additionally provides result aggregation for sub-modules and for the main | ||
* project. | ||
* | ||
* @author Ulli Hafner | ||
*/ | ||
public class PmdMavenResultAction extends MavenResultAction<PmdResult> { | ||
/** | ||
* Creates a new instance of {@link PmdMavenResultAction}. This instance | ||
* will have no result set in the beginning. The result will be set | ||
* successively after each of the modules are build. | ||
* | ||
* @param owner | ||
* the associated build of this action | ||
* @param healthDescriptor | ||
* health descriptor to use | ||
* @param defaultEncoding | ||
* the default encoding to be used when reading and parsing files | ||
*/ | ||
public PmdMavenResultAction(final MavenModuleSetBuild owner, final HealthDescriptor healthDescriptor, | ||
final String defaultEncoding) { | ||
super(new PmdResultAction(owner, healthDescriptor), defaultEncoding); | ||
} | ||
|
||
/** | ||
* Creates a new instance of {@link PmdMavenResultAction}. | ||
* | ||
* @param owner | ||
* the associated build of this action | ||
* @param healthDescriptor | ||
* health descriptor to use | ||
* @param defaultEncoding | ||
* the default encoding to be used when reading and parsing files | ||
* @param result | ||
* the result in this build | ||
*/ | ||
public PmdMavenResultAction(final MavenBuild owner, final HealthDescriptor healthDescriptor, | ||
final String defaultEncoding, final PmdResult result) { | ||
super(new PmdResultAction(owner, healthDescriptor, result), defaultEncoding); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) { | ||
return new PmdMavenResultAction(build, getHealthDescriptor(), getDisplayName()); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
public Action getProjectAction(final MavenModuleSet moduleSet) { | ||
return new PmdProjectAction(moduleSet); | ||
} | ||
|
||
@Override | ||
public Class<? extends MavenResultAction<PmdResult>> getIndividualActionType() { | ||
return PmdMavenResultAction.class; | ||
} | ||
|
||
@Override | ||
protected PmdResult createResult(final PmdResult existingResult, final ParserResult aggregatedAnnotations) { | ||
return new PmdResult(getOwner(), existingResult.getDefaultEncoding(), aggregatedAnnotations); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters