ch.hortis.sonar.mvn.Report Maven / Gradle / Ivy
/*
* This program is copyright (c) 2007 Hortis-GRC SA.
*
* This file is part of Sonar.
* Sonar is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Sonar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package ch.hortis.sonar.mvn;
import ch.hortis.sonar.mvn.mc.*;
import ch.hortis.sonar.mvn.reports.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Enumeration containing the report plugins supported by the Sonar maven plugin as well as their
* MeasuresCollector corresponding implementation
*/
public enum Report {
// CKJM( "ch.hortis.sonar", "ckjm-maven-plugin",
// "1.0", new CKCollector(), new CKHandler() ),
// JIRA( "ch.hortis.sonar", "jira-maven-plugin",
// "1.0", new JiraCollector(), new JiraHandler() ),
// JDepend( "org.codehaus.mojo", "jdepend-maven-plugin",
// "2.0-beta-1", new JDependsCollector(), new JDependHandler() ),
/*
IMPORTANT NOTE : it is important to define the JXR report before all the others.
It is used to load the project File, used by some collectors like Checkstyle or PMD.
*/
JXR ( PomUtils.APACHE_MOJO_GROUP_ID, "maven-jxr-plugin",
"2.0", new JXRCollector(), new JXRHandler()),
JavaNCSS( PomUtils.CODEHAUS_MOJO_GROUP_ID, "javancss-maven-plugin",
"2.0-beta-2", new JavaNCSSCollector(), new JavaNCSSHandler() ),
Checkstyle( PomUtils.APACHE_MOJO_GROUP_ID, "maven-checkstyle-plugin",
"2.1", new CheckstyleCollector(), new CheckstyleHandler( ) ),
Surefire( PomUtils.APACHE_MOJO_GROUP_ID, "maven-surefire-plugin",
"2.3", new SurefireCollector(), new SurefireHandler() ),
PMD( PomUtils.APACHE_MOJO_GROUP_ID, "maven-pmd-plugin",
"2.2", new PMDCollector(), new PMDHandler() ),
CPD( PomUtils.APACHE_MOJO_GROUP_ID, "maven-pmd-plugin",
"2.2", new CPDCollector(), new CPDHandler() ),
ChangeLog( PomUtils.APACHE_MOJO_GROUP_ID, "maven-changelog-plugin",
"2.0", new ChangeLogCollector(), new ChangeLogHandler() ),
Cobertura( PomUtils.CODEHAUS_MOJO_GROUP_ID, "cobertura-maven-plugin",
"2.0", new CoberturaCollector(), new CoberturaHandler() ),
Clover( PomUtils.APACHE_MOJO_GROUP_ID, "maven-clover-plugin",
"2.4", new CloverCollector(), new CloverHandler() );
private String groupId;
private String artifactId;
private String version;
private MeasuresCollector collector;
private ReportHandler reportHandler;
private Report( String groupId, String artifactId,
String version, MeasuresCollector collector, ReportHandler reportHandler ) {
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
this.collector = collector;
this.reportHandler = reportHandler;
if (this.reportHandler!=null) {
this.reportHandler.setReport( this );
}
}
public String getGroupId() {
return groupId;
}
public String getArtifactId() {
return artifactId;
}
public String getVersion() {
return version;
}
public String toString() {
return getGroupId() + ":" + getArtifactId() + ":" + getVersion();
}
public MeasuresCollector getMeasuresCollector() {
return collector;
}
public ReportHandler getReportHandler() {
return reportHandler;
}
public static List getReports() {
return Arrays.asList( Report.values() );
}
public static List getReportHandlers() {
ArrayList handlers = new ArrayList();
for (Report report : getReports()) {
if ( report.getReportHandler() != null )
handlers.add( report.getReportHandler() );
}
return handlers;
}
public static List getCollectors() {
ArrayList collectors = new ArrayList();
for (Report report : getReports()) {
if ( report.getMeasuresCollector() != null )
collectors.add( report.getMeasuresCollector() );
}
return collectors;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy