Skip to content

Commit

Permalink
first commit. forked clover-plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssogabe committed May 15, 2011
0 parents commit c768bb5
Show file tree
Hide file tree
Showing 65 changed files with 2,710 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target
.classpath
.settings
.project
*.iml
*.ipr
*.iws
work
145 changes: 145 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@

<project xmlns="http://maven.apache.org/POM/4.0.0" 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>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.410</version>

This comment has been minimized.

Copy link
@abayer

abayer Jul 27, 2011

Member

Any chance this could get rolled back to 1.409 with a new release? With it set to 1.410, the plugin won't install on the 1.409.x LTS releases.

This comment has been minimized.

Copy link
@ssogabe

ssogabe Jul 28, 2011

Author Member

You are right. I'll roll back it to 1.409.

</parent>

<artifactId>cloverphp</artifactId>
<packaging>hpi</packaging>
<version>0.1-SNAPSHOT</version>
<name>Jenkins Clover PHP plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Clover+PHP+Plugin</url>

<developers>
<developer>
<id>ssogabe</id>
<name>Seiji Sogabe</name>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/ssogabe/clover-php-plugin.git</connection>
<developerConnection>scm:git:git@github.com:ssogabe/clover-php-plugin.git</developerConnection>
<url>http://github.com/ssogabe/clover-php-plugin</url>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<extensions>
<extension>
<groupId>jp.ddo.bacons</groupId>
<artifactId>check-rules</artifactId>
<version>0.2</version>
</extension>
</extensions>
</build>

<profiles>
<profile>
<id>report</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<locales>ja</locales>
<inputEncoding>${project.build.sourceEncoding}</inputEncoding>
<outputEncoding>${project.build.sourceEncoding}</outputEncoding>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.3</version>
<configuration>
<consoleOutput>false</consoleOutput>
<configLocation>default/checkstyle/checkstyle.xml</configLocation>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.4</version>
<configuration>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<targetJdk>${jdk.version}</targetJdk>
<rulesets>
<ruleset>default/pmd/pmd.xml</ruleset>
</rulesets>
<excludes>
<exclude>**/Messages.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<includeFilterFile>default/findbugs/include_filter.xml</includeFilterFile>
<findbugsXmlOutput>true</findbugsXmlOutput>
<xmlOutput>true</xmlOutput>
<debug>true</debug>
<effort>Max</effort>
<onlyAnalyze>org.jenkinsci.plugins.*</onlyAnalyze>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.0</version>
<configuration>
<dependencyLocationEnabled>false</dependencyLocationEnabled>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>

<repositories>
<repository>
<id>m.g.o-public</id>
<url>http://maven.glassfish.org/content/groups/public/</url>
</repository>
</repositories>

</project>
162 changes: 162 additions & 0 deletions src/main/java/org/jenkinsci/plugins/cloverphp/CloverBuildAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package org.jenkinsci.plugins.cloverphp;

import hudson.model.AbstractBuild;
import hudson.model.HealthReport;
import hudson.model.HealthReportingAction;
import hudson.model.Result;
import org.jenkinsci.plugins.cloverphp.results.ProjectCoverage;
import org.jenkinsci.plugins.cloverphp.targets.CoverageMetric;
import org.jenkinsci.plugins.cloverphp.targets.CoverageTarget;
import org.kohsuke.stapler.StaplerProxy;

import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jvnet.localizer.Localizable;

/**
* A health reporter for the individual build page.
*
*
* @author connollys
* @since 03-Jul-2007 08:43:08
*/
public class CloverBuildAction implements HealthReportingAction, StaplerProxy {

private final AbstractBuild owner;

private String buildBaseDir;

private CoverageTarget healthyTarget;

private CoverageTarget unhealthyTarget;

private transient WeakReference<ProjectCoverage> report;

public HealthReport getBuildHealth() {
if (healthyTarget == null || unhealthyTarget == null) {
return null;
}
ProjectCoverage projectCoverage = getResult();
Map<CoverageMetric, Integer> scores = healthyTarget.getRangeScores(unhealthyTarget, projectCoverage);
int minValue = 100;
CoverageMetric minKey = null;
for (Map.Entry<CoverageMetric, Integer> e : scores.entrySet()) {
if (e.getValue() < minValue) {
minKey = e.getKey();
minValue = e.getValue();
}
}
if (minKey == null) {
return null;
}

Localizable description = null;
switch (minKey) {
case METHOD:
description = Messages._CloverBuildAction_MethodCoverage(
projectCoverage.getMethodCoverage().getPercentage(),
projectCoverage.getMethodCoverage().toString());
break;
case STATEMENT:
description = Messages._CloverBuildAction_StatementCoverage(
projectCoverage.getStatementCoverage().getPercentage(),
projectCoverage.getStatementCoverage().toString());
break;
case ELEMENT:
description = Messages._CloverBuildAction_ElementCoverage(
projectCoverage.getElementCoverage().getPercentage(),
projectCoverage.getElementCoverage().toString());
break;
default:
return null;
}
return new HealthReport(minValue, description);
}

public String getIconFileName() {
return CloverProjectAction.ICON;
}

public String getDisplayName() {
return Messages.CloverBuildAction_DisplayName();
}

public String getUrlName() {
// TODO: more shorter
return "clover-php-report";
}

public Object getTarget() {
return getResult();
}

public CloverBuildAction getPreviousResult() {
return getPreviousResult(owner);
}

/** Gets the previous {@link CloverBuildAction} of the given build. */
/*package*/
static CloverBuildAction getPreviousResult(AbstractBuild start) {
AbstractBuild<?, ?> b = start;
while (true) {
b = b.getPreviousBuild();
if (b == null) {
return null;
}
if (b.getResult() == Result.FAILURE) {
continue;
}
CloverBuildAction r = b.getAction(CloverBuildAction.class);
if (r != null) {
return r;
}
}
}

CloverBuildAction(AbstractBuild owner, String workspacePath, ProjectCoverage r, CoverageTarget healthyTarget,
CoverageTarget unhealthyTarget) {
this.owner = owner;
this.report = new WeakReference<ProjectCoverage>(r);
this.buildBaseDir = workspacePath;
if (this.buildBaseDir == null) {
this.buildBaseDir = File.separator;
} else if (!this.buildBaseDir.endsWith(File.separator)) {
this.buildBaseDir += File.separator;
}
this.healthyTarget = healthyTarget;
this.unhealthyTarget = unhealthyTarget;
r.setOwner(owner);
}

/** Obtains the detailed {@link CoverageReport} instance. */
public synchronized ProjectCoverage getResult() {
if (report != null) {
ProjectCoverage r = report.get();
if (r != null) {
return r;
}
}

File reportFile = CloverPublisher.getCloverXmlReport(owner);
try {
ProjectCoverage r = CloverCoverageParser.parse(reportFile, buildBaseDir);
r.setOwner(owner);
report = new WeakReference<ProjectCoverage>(r);
return r;
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + reportFile, e);
return null;
}
}

private static final Logger LOGGER = Logger.getLogger(CloverBuildAction.class.getName());

public static CloverBuildAction load(AbstractBuild<?, ?> build, String workspacePath, ProjectCoverage result,
CoverageTarget healthyTarget, CoverageTarget unhealthyTarget) {
return new CloverBuildAction(build, workspacePath, result, healthyTarget, unhealthyTarget);
}
}
Loading

0 comments on commit c768bb5

Please sign in to comment.