]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3934 Extract sonar-jacoco-plugin into Sonar Java
authorEvgeny Mandrikov <mandrikov@gmail.com>
Tue, 6 Nov 2012 21:52:48 +0000 (22:52 +0100)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Wed, 7 Nov 2012 09:45:58 +0000 (10:45 +0100)
32 files changed:
plugins/sonar-jacoco-plugin/infinitest.args [deleted file]
plugins/sonar-jacoco-plugin/pom.xml [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/AbstractAnalyzer.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAgentDownloader.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandler.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoUtils.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java [deleted file]
plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/package-info.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/AbstractAnalyzerTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/Hello.class.toCopy [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/HelloWorld.class.toCopy [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom.xml [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom2.xml [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec [deleted file]
plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoSensorTest/jacoco.exec [deleted file]
pom.xml
sonar-application/pom.xml
sonar-server/pom.xml

diff --git a/plugins/sonar-jacoco-plugin/infinitest.args b/plugins/sonar-jacoco-plugin/infinitest.args
deleted file mode 100644 (file)
index ed9f41d..0000000
+++ /dev/null
@@ -1 +0,0 @@
--Djava.awt.headless=true
\ No newline at end of file
diff --git a/plugins/sonar-jacoco-plugin/pom.xml b/plugins/sonar-jacoco-plugin/pom.xml
deleted file mode 100644 (file)
index 985a5d5..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.codehaus.sonar</groupId>
-    <artifactId>sonar</artifactId>
-    <version>3.4-SNAPSHOT</version>
-    <relativePath>../..</relativePath>
-  </parent>
-
-  <groupId>org.codehaus.sonar.plugins</groupId>
-  <artifactId>sonar-jacoco-plugin</artifactId>
-  <packaging>sonar-plugin</packaging>
-
-  <name>Sonar :: Plugins :: JaCoCo</name>
-  <description>JaCoCo is an alternative to Clover and Cobertura to measure coverage by unit tests</description>
-  <url>http://docs.codehaus.org/display/SONAR/JaCoCo+Plugin</url>
-  <inceptionYear>2010</inceptionYear>
-  <organization>
-    <name>SonarSource</name>
-    <url>http://www.sonarsource.com</url>
-  </organization>
-  <licenses>
-    <license>
-      <name>GNU LGPL 3</name>
-      <url>http://www.gnu.org/licenses/lgpl.txt</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-
-  <developers>
-    <developer>
-      <id>godin</id>
-      <name>Evgeny Mandrikov</name>
-    </developer>
-  </developers>
-
-  <properties>
-    <jacoco.version>0.5.10.201208310627</jacoco.version>
-
-    <sonar.pluginName>JaCoCo</sonar.pluginName>
-    <sonar.pluginClass>org.sonar.plugins.jacoco.JaCoCoPlugin</sonar.pluginClass>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.jacoco</groupId>
-      <artifactId>org.jacoco.core</artifactId>
-      <version>${jacoco.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.jacoco</groupId>
-      <artifactId>org.jacoco.agent</artifactId>
-      <version>${jacoco.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-plugin-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.sonar-plugins.java</groupId>
-      <artifactId>sonar-java-plugin</artifactId>
-      <version>${sonarJava.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <!-- Would be provided by environment -->
-    <dependency>
-      <groupId>org.apache.ant</groupId>
-      <artifactId>ant</artifactId>
-      <version>1.7.0</version>
-      <scope>provided</scope>
-    </dependency>
-    <!-- unit tests -->
-    <dependency>
-      <groupId>org.codehaus.sonar</groupId>
-      <artifactId>sonar-testing-harness</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>2.0.7</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.sonar</groupId>
-        <artifactId>sonar-dev-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>trim</id>
-            <phase>process-resources</phase>
-            <goals>
-              <goal>trim</goal>
-            </goals>
-            <configuration>
-              <directory>${project.build.outputDirectory}</directory>
-              <includes>
-                <include>**/*.erb</include>
-              </includes>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-enforcer-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>enforce-plugin-size</id>
-            <goals>
-              <goal>enforce</goal>
-            </goals>
-            <phase>verify</phase>
-            <configuration>
-              <rules>
-                <requireFilesSize>
-                  <maxsize>400000</maxsize>
-                  <minsize>300000</minsize>
-                  <files>
-                    <file>${project.build.directory}/${project.build.finalName}.jar</file>
-                  </files>
-                </requireFilesSize>
-              </rules>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/AbstractAnalyzer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/AbstractAnalyzer.java
deleted file mode 100644 (file)
index ca4542f..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
-import org.apache.commons.lang.StringUtils;
-import org.jacoco.core.analysis.*;
-import org.jacoco.core.data.ExecutionDataReader;
-import org.jacoco.core.data.ExecutionDataStore;
-import org.jacoco.core.data.SessionInfoStore;
-import org.jacoco.core.runtime.WildcardMatcher;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoverageMeasuresBuilder;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ResourceUtils;
-import org.sonar.api.utils.SonarException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * @author Evgeny Mandrikov
- */
-public abstract class AbstractAnalyzer {
-
-  public final void analyse(Project project, SensorContext context) {
-    final File buildOutputDir = project.getFileSystem().getBuildOutputDir();
-    if (!buildOutputDir.exists()) {
-      JaCoCoUtils.LOG.info("Project coverage is set to 0% as build output directory does not exist: {}", buildOutputDir);
-      return;
-    }
-    String path = getReportPath(project);
-    File jacocoExecutionData = project.getFileSystem().resolvePath(path);
-
-    WildcardMatcher excludes = new WildcardMatcher(Strings.nullToEmpty(getExcludes(project)));
-    try {
-      readExecutionData(jacocoExecutionData, buildOutputDir, context, excludes);
-    } catch (IOException e) {
-      throw new SonarException(e);
-    }
-  }
-
-  public final void readExecutionData(File jacocoExecutionData, File buildOutputDir, SensorContext context, WildcardMatcher excludes) throws IOException {
-    SessionInfoStore sessionInfoStore = new SessionInfoStore();
-    ExecutionDataStore executionDataStore = new ExecutionDataStore();
-
-    if (jacocoExecutionData == null || !jacocoExecutionData.exists() || !jacocoExecutionData.isFile()) {
-      JaCoCoUtils.LOG.info("Project coverage is set to 0% as no JaCoCo execution data has been dumped: {}", jacocoExecutionData);
-    } else {
-      JaCoCoUtils.LOG.info("Analysing {}", jacocoExecutionData);
-      ExecutionDataReader reader = new ExecutionDataReader(new FileInputStream(jacocoExecutionData));
-      reader.setSessionInfoVisitor(sessionInfoStore);
-      reader.setExecutionDataVisitor(executionDataStore);
-      reader.read();
-    }
-
-    CoverageBuilder coverageBuilder = new CoverageBuilder();
-    Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
-    analyzeAll(analyzer, buildOutputDir);
-
-    int analyzedResources = 0;
-    for (ISourceFileCoverage coverage : coverageBuilder.getSourceFiles()) {
-      JavaFile resource = getResource(coverage, context);
-      if (resource != null) {
-        if (!isExcluded(coverage, excludes)) {
-          analyzeFile(resource, coverage, context);
-        }
-        analyzedResources++;
-      }
-    }
-    if (analyzedResources == 0) {
-      JaCoCoUtils.LOG.warn("Coverage information was not collected. Perhaps you forget to include debug information into compiled classes?");
-    }
-  }
-
-  private static boolean isExcluded(ISourceFileCoverage coverage, WildcardMatcher excludesMatcher) {
-    String name = coverage.getPackageName() + "/" + coverage.getName();
-    return excludesMatcher.matches(name);
-  }
-
-  @VisibleForTesting
-  static JavaFile getResource(ISourceFileCoverage coverage, SensorContext context) {
-    String packageName = StringUtils.replaceChars(coverage.getPackageName(), '/', '.');
-    String fileName = StringUtils.substringBeforeLast(coverage.getName(), ".");
-
-    JavaFile resource = new JavaFile(packageName, fileName);
-
-    JavaFile resourceInContext = context.getResource(resource);
-    if (null == resourceInContext) {
-      return null; // Do not save measures on resource which doesn't exist in the context
-    }
-    if (ResourceUtils.isUnitTestClass(resourceInContext)) {
-      return null; // Ignore unit tests
-    }
-
-    return resourceInContext;
-  }
-
-  /**
-   * Copied from {@link Analyzer#analyzeAll(File)} in order to add logging.
-   */
-  private void analyzeAll(Analyzer analyzer, File file) {
-    if (file.isDirectory()) {
-      for (File f : file.listFiles()) {
-        analyzeAll(analyzer, f);
-      }
-    } else if (file.getName().endsWith(".class")) {
-      try {
-        analyzer.analyzeAll(file);
-      } catch (Exception e) {
-        JaCoCoUtils.LOG.warn("Exception during analysis of file " + file.getAbsolutePath(), e);
-      }
-    }
-  }
-
-  private void analyzeFile(JavaFile resource, ISourceFileCoverage coverage, SensorContext context) {
-    CoverageMeasuresBuilder builder = CoverageMeasuresBuilder.create();
-    for (int lineId = coverage.getFirstLine(); lineId <= coverage.getLastLine(); lineId++) {
-      final int hits;
-      ILine line = coverage.getLine(lineId);
-      switch (line.getInstructionCounter().getStatus()) {
-        case ICounter.FULLY_COVERED:
-        case ICounter.PARTLY_COVERED:
-          hits = 1;
-          break;
-        case ICounter.NOT_COVERED:
-          hits = 0;
-          break;
-        case ICounter.EMPTY:
-          continue;
-        default:
-          JaCoCoUtils.LOG.warn("Unknown status for line {} in {}", lineId, resource);
-          continue;
-      }
-      builder.setHits(lineId, hits);
-
-      ICounter branchCounter = line.getBranchCounter();
-      int conditions = branchCounter.getTotalCount();
-      if (conditions > 0) {
-        int coveredConditions = branchCounter.getCoveredCount();
-        builder.setConditions(lineId, conditions, coveredConditions);
-      }
-    }
-
-    saveMeasures(context, resource, builder.createMeasures());
-  }
-
-  protected abstract void saveMeasures(SensorContext context, JavaFile resource, Collection<Measure> measures);
-
-  protected abstract String getReportPath(Project project);
-
-  protected abstract String getExcludes(Project project);
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAgentDownloader.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAgentDownloader.java
deleted file mode 100644 (file)
index 90571ed..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.apache.commons.io.FileUtils;
-import org.jacoco.agent.AgentJar;
-import org.jacoco.core.JaCoCo;
-import org.sonar.api.BatchExtension;
-import org.sonar.api.utils.SonarException;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class JaCoCoAgentDownloader implements BatchExtension {
-
-  /**
-   * Dirty hack, but it allows to extract agent only once during Sonar analyzes for multi-module project.
-   */
-  private static File agentJarFile;
-
-  public JaCoCoAgentDownloader() {
-  }
-
-  public synchronized File getAgentJarFile() {
-    if (agentJarFile == null) {
-      agentJarFile = extractAgent();
-    }
-    return agentJarFile;
-  }
-
-  private File extractAgent() {
-    try {
-      File agent = File.createTempFile("jacocoagent", ".jar");
-      AgentJar.extractTo(agent);
-      FileUtils.forceDeleteOnExit(agent); // TODO evil method
-      JaCoCoUtils.LOG.info("JaCoCo agent (version " + JaCoCo.VERSION + ") extracted: {}", agent);
-      return agent;
-    } catch (IOException e) {
-      throw new SonarException(e);
-    }
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java
deleted file mode 100644 (file)
index 881c513..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-
-import java.util.Collection;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class JaCoCoItSensor implements Sensor {
-  private JacocoConfiguration configuration;
-
-  public JaCoCoItSensor(JacocoConfiguration configuration) {
-    this.configuration = configuration;
-  }
-
-  public boolean shouldExecuteOnProject(Project project) {
-    return configuration.isEnabled(project) && StringUtils.isNotBlank(configuration.getItReportPath());
-  }
-
-  public void analyse(Project project, SensorContext context) {
-    new ITAnalyzer().analyse(project, context);
-  }
-
-  class ITAnalyzer extends AbstractAnalyzer {
-    @Override
-    protected String getReportPath(Project project) {
-      return configuration.getItReportPath();
-    }
-
-    @Override
-    protected String getExcludes(Project project) {
-      return configuration.getExcludes();
-    }
-
-    @Override
-    protected void saveMeasures(SensorContext context, JavaFile resource, Collection<Measure> measures) {
-      for (Measure measure : measures) {
-        Measure itMeasure = convertForIT(measure);
-        if (itMeasure != null) {
-          context.saveMeasure(resource, itMeasure);
-        }
-      }
-    }
-
-    private Measure convertForIT(Measure measure) {
-      Measure itMeasure = null;
-      if (CoreMetrics.LINES_TO_COVER.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_LINES_TO_COVER, measure.getValue());
-
-      } else if (CoreMetrics.UNCOVERED_LINES.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_UNCOVERED_LINES, measure.getValue());
-
-      } else if (CoreMetrics.COVERAGE_LINE_HITS_DATA.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, measure.getData());
-
-      } else if (CoreMetrics.CONDITIONS_TO_COVER.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_CONDITIONS_TO_COVER, measure.getValue());
-
-      } else if (CoreMetrics.UNCOVERED_CONDITIONS.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_UNCOVERED_CONDITIONS, measure.getValue());
-
-      } else if (CoreMetrics.COVERED_CONDITIONS_BY_LINE.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE, measure.getData());
-
-      } else if (CoreMetrics.CONDITIONS_BY_LINE.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.IT_CONDITIONS_BY_LINE, measure.getData());
-      }
-      return itMeasure;
-    }
-  }
-
-  @Override
-  public String toString() {
-    return getClass().getSimpleName();
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandler.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandler.java
deleted file mode 100644 (file)
index a674f24..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import java.io.File;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.batch.maven.MavenSurefireUtils;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.SonarException;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class JaCoCoMavenPluginHandler implements MavenPluginHandler {
-
-  private static final String ARG_LINE_PARAMETER = "argLine";
-  private static final String TEST_FAILURE_IGNORE_PARAMETER = "testFailureIgnore";
-
-  private final String groupId;
-  private final String artifactId;
-  private final String version;
-
-  private JacocoConfiguration configuration;
-
-  public JaCoCoMavenPluginHandler(JacocoConfiguration configuration) {
-    this.configuration = configuration;
-    groupId = MavenSurefireUtils.GROUP_ID;
-    artifactId = MavenSurefireUtils.ARTIFACT_ID;
-    version = MavenSurefireUtils.VERSION;
-  }
-
-  public String getGroupId() {
-    return groupId;
-  }
-
-  public String getArtifactId() {
-    return artifactId;
-  }
-
-  public String getVersion() {
-    return version;
-  }
-
-  public boolean isFixedVersion() {
-    return false;
-  }
-
-  public String[] getGoals() {
-    return new String[] { "test" };
-  }
-
-  public void configure(Project project, MavenPlugin plugin) {
-    // See SONARPLUGINS-600
-    String destfilePath = configuration.getReportPath();
-    File destfile = project.getFileSystem().resolvePath(destfilePath);
-    if (destfile.exists() && destfile.isFile()) {
-      JaCoCoUtils.LOG.info("Deleting {}", destfile);
-      if (!destfile.delete()) {
-        throw new SonarException("Unable to delete " + destfile);
-      }
-    }
-
-    String argument = configuration.getJvmArgument();
-
-    String argLine = plugin.getParameter(ARG_LINE_PARAMETER);
-    argLine = StringUtils.isBlank(argLine) ? argument : argument + " " + argLine;
-    JaCoCoUtils.LOG.info("JVM options: {}", argLine);
-    plugin.setParameter(ARG_LINE_PARAMETER, argLine);
-
-    plugin.setParameter(TEST_FAILURE_IGNORE_PARAMETER, "true");
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java
deleted file mode 100644 (file)
index 84c0c5f..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import com.google.common.io.Closeables;
-import org.apache.commons.lang.StringUtils;
-import org.jacoco.core.data.ExecutionDataReader;
-import org.jacoco.core.data.ExecutionDataStore;
-import org.jacoco.core.data.ExecutionDataWriter;
-import org.jacoco.core.data.SessionInfoStore;
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.utils.SonarException;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-
-public class JaCoCoOverallSensor implements Sensor {
-  public static final String JACOCO_OVERALL = "jacoco-overall.exec";
-
-  private final JacocoConfiguration configuration;
-
-  public JaCoCoOverallSensor(JacocoConfiguration configuration) {
-    this.configuration = configuration;
-  }
-
-  public boolean shouldExecuteOnProject(Project project) {
-    return configuration.isEnabled(project) && StringUtils.isNotBlank(configuration.getItReportPath());
-  }
-
-  public void analyse(Project project, SensorContext context) {
-    ProjectFileSystem fs = project.getFileSystem();
-
-    File reportUTs = fs.resolvePath(configuration.getReportPath());
-    File reportITs = fs.resolvePath(configuration.getItReportPath());
-    if ((!reportUTs.exists()) || (!reportITs.exists())) {
-      return;
-    }
-
-    File reportOverall = new File(fs.getSonarWorkingDirectory(), JACOCO_OVERALL);
-    reportOverall.getParentFile().mkdirs();
-
-    mergeReports(reportOverall, reportUTs, reportITs);
-
-    new OverallAnalyzer(reportOverall).analyse(project, context);
-  }
-
-  private void mergeReports(File reportOverall, File... reports) {
-    SessionInfoStore infoStore = new SessionInfoStore();
-    ExecutionDataStore dataStore = new ExecutionDataStore();
-
-    loadSourceFiles(infoStore, dataStore, reports);
-
-    BufferedOutputStream outputStream = null;
-    try {
-      outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall));
-      ExecutionDataWriter dataWriter = new ExecutionDataWriter(outputStream);
-
-      infoStore.accept(dataWriter);
-      dataStore.accept(dataWriter);
-    } catch (IOException e) {
-      throw new SonarException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e);
-    } finally {
-      Closeables.closeQuietly(outputStream);
-    }
-  }
-
-  private void loadSourceFiles(SessionInfoStore infoStore, ExecutionDataStore dataStore, File... reports) {
-    for (File report : reports) {
-      InputStream resourceStream = null;
-      try {
-        resourceStream = new BufferedInputStream(new FileInputStream(report));
-        ExecutionDataReader reader = new ExecutionDataReader(resourceStream);
-        reader.setSessionInfoVisitor(infoStore);
-        reader.setExecutionDataVisitor(dataStore);
-        reader.read();
-      } catch (IOException e) {
-        throw new SonarException(String.format("Unable to read %s", report.getAbsolutePath()), e);
-      } finally {
-        Closeables.closeQuietly(resourceStream);
-      }
-    }
-  }
-
-  class OverallAnalyzer extends AbstractAnalyzer {
-    private final File report;
-
-    OverallAnalyzer(File report) {
-      this.report = report;
-    }
-
-    @Override
-    protected String getReportPath(Project project) {
-      return report.getAbsolutePath();
-    }
-
-    @Override
-    protected String getExcludes(Project project) {
-      return configuration.getExcludes();
-    }
-
-    @Override
-    protected void saveMeasures(SensorContext context, JavaFile resource, Collection<Measure> measures) {
-      for (Measure measure : measures) {
-        Measure mergedMeasure = convertForOverall(measure);
-        if (mergedMeasure != null) {
-          context.saveMeasure(resource, mergedMeasure);
-        }
-      }
-    }
-
-    private Measure convertForOverall(Measure measure) {
-      Measure itMeasure = null;
-      if (CoreMetrics.LINES_TO_COVER.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_LINES_TO_COVER, measure.getValue());
-      } else if (CoreMetrics.UNCOVERED_LINES.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_UNCOVERED_LINES, measure.getValue());
-      } else if (CoreMetrics.COVERAGE_LINE_HITS_DATA.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA, measure.getData());
-      } else if (CoreMetrics.CONDITIONS_TO_COVER.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER, measure.getValue());
-      } else if (CoreMetrics.UNCOVERED_CONDITIONS.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, measure.getValue());
-      } else if (CoreMetrics.COVERED_CONDITIONS_BY_LINE.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE, measure.getData());
-      } else if (CoreMetrics.CONDITIONS_BY_LINE.equals(measure.getMetric())) {
-        itMeasure = new Measure(CoreMetrics.OVERALL_CONDITIONS_BY_LINE, measure.getData());
-      }
-      return itMeasure;
-    }
-  }
-
-  @Override
-  public String toString() {
-    return getClass().getSimpleName();
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
deleted file mode 100644 (file)
index 025d4dd..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.SonarPlugin;
-
-import java.util.List;
-
-public class JaCoCoPlugin extends SonarPlugin {
-
-  public List<?> getExtensions() {
-    return ImmutableList.of(
-        JacocoConfiguration.class,
-        JaCoCoAgentDownloader.class,
-        // Ant
-        JacocoAntInitializer.class,
-        // Maven
-        JacocoMavenInitializer.class,
-        JaCoCoMavenPluginHandler.class,
-        // Unit tests
-        JaCoCoSensor.class,
-        // Integration tests
-        JaCoCoItSensor.class,
-        JaCoCoOverallSensor.class);
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java
deleted file mode 100644 (file)
index d5d19c4..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.sonar.api.batch.CoverageExtension;
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-
-import java.util.Collection;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class JaCoCoSensor implements Sensor, CoverageExtension {
-
-  private JacocoConfiguration configuration;
-
-  public JaCoCoSensor(JacocoConfiguration configuration) {
-    this.configuration = configuration;
-  }
-
-  public void analyse(Project project, SensorContext context) {
-    new UnitTestsAnalyzer().analyse(project, context);
-  }
-
-  public boolean shouldExecuteOnProject(Project project) {
-    return configuration.isEnabled(project);
-  }
-
-  class UnitTestsAnalyzer extends AbstractAnalyzer {
-    @Override
-    protected String getReportPath(Project project) {
-      return configuration.getReportPath();
-    }
-
-    @Override
-    protected String getExcludes(Project project) {
-      return configuration.getExcludes();
-    }
-
-    @Override
-    protected void saveMeasures(SensorContext context, JavaFile resource, Collection<Measure> measures) {
-      for (Measure measure : measures) {
-        context.saveMeasure(resource, measure);
-      }
-    }
-  }
-
-  @Override
-  public String toString() {
-    return getClass().getSimpleName();
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoUtils.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoUtils.java
deleted file mode 100644 (file)
index 050a39a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Evgeny Mandrikov
- */
-public final class JaCoCoUtils {
-
-  /**
-   * Utility class constructor.
-   */
-  private JaCoCoUtils() {
-  }
-
-  public static final String PLUGIN_KEY = "jacoco";
-  public static final Logger LOG = LoggerFactory.getLogger(JaCoCoPlugin.class.getName());
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java
deleted file mode 100644 (file)
index 85fefde..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.apache.tools.ant.*;
-import org.sonar.api.batch.CoverageExtension;
-import org.sonar.api.batch.Initializer;
-import org.sonar.api.batch.SupportedEnvironment;
-import org.sonar.api.resources.Project;
-
-import java.util.Map;
-
-@SupportedEnvironment("ant")
-public class JacocoAntInitializer extends Initializer implements CoverageExtension {
-
-  private final TaskEnhancer[] taskEnhancers = new TaskEnhancer[] { new JavaLikeTaskEnhancer("java"), new JavaLikeTaskEnhancer("junit"), new TestngTaskEnhancer() };
-
-  private org.apache.tools.ant.Project antProject;
-  private JacocoConfiguration configuration;
-
-  public JacocoAntInitializer(org.apache.tools.ant.Project antProject, JacocoConfiguration configuration) {
-    this.antProject = antProject;
-    this.configuration = configuration;
-  }
-
-  @Override
-  public boolean shouldExecuteOnProject(org.sonar.api.resources.Project project) {
-    return configuration.isEnabled(project) && project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC);
-  }
-
-  @Override
-  public void execute(org.sonar.api.resources.Project project) {
-    Map<String, Target> hastable = antProject.getTargets();
-    String jvmArg = configuration.getJvmArgument();
-    String[] names = configuration.getAntTargets();
-    for (String name : names) {
-      Target target = hastable.get(name);
-      if (target == null) {
-        JaCoCoUtils.LOG.warn("Target '{}' not found", name);
-      } else {
-        // Enhance target
-        for (Task task : target.getTasks()) {
-          for (TaskEnhancer enhancer : taskEnhancers) {
-            if (enhancer.supportsTask(task)) {
-              enhancer.enhanceTask(task, jvmArg);
-            }
-          }
-        }
-        // Execute target
-        target.performTasks();
-      }
-    }
-  }
-
-  private static class TestngTaskEnhancer extends TaskEnhancer {
-    @Override
-    public boolean supportsTask(Task task) {
-      return "testng".equals(task.getTaskName());
-    }
-  }
-
-  /**
-   * Basic task enhancer that can handle all 'java like' tasks. That is, tasks
-   * that have a top level fork attribute and nested jvmargs elements
-   */
-  private static class JavaLikeTaskEnhancer extends TaskEnhancer {
-    private String taskName;
-
-    public JavaLikeTaskEnhancer(String taskName) {
-      this.taskName = taskName;
-    }
-
-    @Override
-    public boolean supportsTask(final Task task) {
-      return taskName.equals(task.getTaskName());
-    }
-
-    @Override
-    public void enhanceTask(final Task task, final String jvmArg) {
-      final RuntimeConfigurable configurableWrapper = task.getRuntimeConfigurableWrapper();
-
-      final String forkValue = (String) configurableWrapper.getAttributeMap().get("fork");
-
-      if (forkValue == null || !org.apache.tools.ant.Project.toBoolean(forkValue)) {
-        throw new BuildException("Coverage can only be applied on a forked VM");
-      }
-
-      super.enhanceTask(task, jvmArg);
-    }
-
-  }
-
-  private abstract static class TaskEnhancer {
-    /**
-     * @param task Task instance to enhance
-     * @return <code>true</code> if this enhancer is capable of enhancing the requested task
-     */
-    public abstract boolean supportsTask(Task task);
-
-    /**
-     * Attempt to enhance the supplied task with coverage information. This
-     * operation may fail if the task is being executed in the current VM
-     * 
-     * @param task Task instance to enhance (usually an {@link UnknownElement})
-     * @param jvmArg
-     * @throws BuildException Thrown if this enhancer can handle this type of task, but this instance can not be enhanced for some reason.
-     */
-    public void enhanceTask(Task task, String jvmArg) {
-      addJvmArg((UnknownElement) task, jvmArg);
-    }
-
-    public void addJvmArg(final UnknownElement task, final String jvmArg) {
-      final UnknownElement el = new UnknownElement("jvmarg");
-      el.setTaskName("jvmarg");
-      el.setQName("jvmarg");
-
-      final RuntimeConfigurable runtimeConfigurableWrapper = el.getRuntimeConfigurableWrapper();
-      runtimeConfigurableWrapper.setAttribute("value", jvmArg);
-
-      task.getRuntimeConfigurableWrapper().addChild(runtimeConfigurableWrapper);
-
-      task.addChild(el);
-    }
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java
deleted file mode 100644 (file)
index 7d13a75..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.apache.commons.lang.StringUtils;
-import org.jacoco.core.runtime.AgentOptions;
-import org.sonar.api.BatchExtension;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Project;
-import org.sonar.plugins.java.api.JavaSettings;
-
-@Properties({
-    @Property(
-        key = JacocoConfiguration.REPORT_PATH_PROPERTY,
-        name = "File with execution data",
-        defaultValue = JacocoConfiguration.REPORT_PATH_DEFAULT_VALUE,
-        description = "Path (absolute or relative) to the file with execution data.",
-        global = false,
-        module = true,
-        project = true
-    ),
-    @Property(
-        key = JacocoConfiguration.INCLUDES_PROPERTY,
-        name = "Includes",
-        description = "A list of class names that should be included in execution analysis." +
-            " The list entries are separated by a colon (:) and may use wildcard characters (* and ?)." +
-            " Except for performance optimization or technical corner cases this option is normally not required.",
-        global = true,
-        project = true,
-        module = true
-    ),
-    @Property(
-        key = JacocoConfiguration.EXCLUDES_PROPERTY,
-        name = "Excludes",
-        defaultValue = JacocoConfiguration.EXCLUDES_DEFAULT_VALUE,
-        description = "A list of class names that should be excluded from execution analysis." +
-            " The list entries are separated by a colon (:) and may use wildcard characters (* and ?)." +
-            " Except for performance optimization or technical corner cases this option is normally not required.",
-        global = true,
-        project = true,
-        module = true
-    ),
-    @Property(
-        key = JacocoConfiguration.EXCLCLASSLOADER_PROPERTY,
-        name = "Excluded class loaders",
-        description = "A list of class loader names that should be excluded from execution analysis." +
-            " The list entries are separated by a colon (:) and may use wildcard characters (* and ?)." +
-            " This option might be required in case of special frameworks that conflict with JaCoCo code" +
-            " instrumentation, in particular class loaders that do not have access to the Java runtime classes.",
-        global = true,
-        project = true,
-        module = true
-    ),
-    @Property(
-        key = JacocoConfiguration.IT_REPORT_PATH_PROPERTY,
-        name = "File with execution data for integration tests",
-        defaultValue = JacocoConfiguration.IT_REPORT_PATH_DEFAULT_VALUE,
-        description = "Path (absolute or relative) to the file with execution data.",
-        global = false,
-        module = true,
-        project = true
-    ),
-    @Property(
-        key = JacocoConfiguration.ANT_TARGETS_PROPERTY,
-        name = "Ant targets",
-        defaultValue = JacocoConfiguration.ANT_TARGETS_DEFAULT_VALUE,
-        description = "Comma separated list of Ant targets for execution of tests.",
-        global = true,
-        module = true,
-        project = true
-    )})
-public class JacocoConfiguration implements BatchExtension {
-
-  public static final String REPORT_PATH_PROPERTY = "sonar.jacoco.reportPath";
-  public static final String REPORT_PATH_DEFAULT_VALUE = "target/jacoco.exec";
-  public static final String IT_REPORT_PATH_PROPERTY = "sonar.jacoco.itReportPath";
-  public static final String IT_REPORT_PATH_DEFAULT_VALUE = "";
-  public static final String INCLUDES_PROPERTY = "sonar.jacoco.includes";
-  public static final String EXCLUDES_PROPERTY = "sonar.jacoco.excludes";
-
-  /**
-   * Hibernate uses Javassist to modify entity classes and without exclusion of such classes from JaCoCo exception might be thrown:
-   * <pre>
-   * Javassist Enhancement failed: org.sonar.api.profiles.Alert
-   * java.lang.VerifyError: (class: org/sonar/api/profiles/Alert_$$_javassist_3, method: <clinit> signature: ()V) Illegal local variable number
-   * </pre>
-   */
-  public static final String EXCLUDES_DEFAULT_VALUE = "*_javassist_*";
-  public static final String EXCLCLASSLOADER_PROPERTY = "sonar.jacoco.exclclassloader";
-  public static final String ANT_TARGETS_PROPERTY = "sonar.jacoco.antTargets";
-  public static final String ANT_TARGETS_DEFAULT_VALUE = "";
-
-  private Settings settings;
-  private JavaSettings javaSettings;
-  private JaCoCoAgentDownloader downloader;
-
-  public JacocoConfiguration(Settings settings, JaCoCoAgentDownloader downloader, JavaSettings javaSettings) {
-    this.settings = settings;
-    this.downloader = downloader;
-    this.javaSettings = javaSettings;
-  }
-
-  public boolean isEnabled(Project project) {
-    return Java.KEY.equals(project.getLanguageKey()) &&
-      project.getAnalysisType().isDynamic(true) &&
-      JaCoCoUtils.PLUGIN_KEY.equals(javaSettings.getEnabledCoveragePlugin());
-  }
-
-  public String getReportPath() {
-    return settings.getString(REPORT_PATH_PROPERTY);
-  }
-
-  public String getItReportPath() {
-    return settings.getString(IT_REPORT_PATH_PROPERTY);
-  }
-
-  public String getJvmArgument() {
-    AgentOptions options = new AgentOptions();
-    options.setDestfile(getReportPath());
-    String includes = settings.getString(INCLUDES_PROPERTY);
-    if (StringUtils.isNotBlank(includes)) {
-      options.setIncludes(includes);
-    }
-    String excludes = settings.getString(EXCLUDES_PROPERTY);
-    if (StringUtils.isNotBlank(excludes)) {
-      options.setExcludes(excludes);
-    }
-    String exclclassloader = settings.getString(EXCLCLASSLOADER_PROPERTY);
-    if (StringUtils.isNotBlank(exclclassloader)) {
-      options.setExclClassloader(exclclassloader);
-    }
-    return options.getVMArgument(downloader.getAgentJarFile());
-  }
-
-  public String[] getAntTargets() {
-    return settings.getStringArray(ANT_TARGETS_PROPERTY);
-  }
-
-  public String getExcludes() {
-    return settings.getString(EXCLUDES_PROPERTY);
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java
deleted file mode 100644 (file)
index c7c3205..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.sonar.api.batch.CoverageExtension;
-import org.sonar.api.batch.Initializer;
-import org.sonar.api.batch.SupportedEnvironment;
-import org.sonar.api.batch.maven.DependsUponMavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Project;
-
-@SupportedEnvironment("maven")
-public class JacocoMavenInitializer extends Initializer implements CoverageExtension, DependsUponMavenPlugin {
-
-  private JaCoCoMavenPluginHandler handler;
-  private JacocoConfiguration configuration;
-
-  public JacocoMavenInitializer(JaCoCoMavenPluginHandler handler, JacocoConfiguration configuration) {
-    this.handler = handler;
-    this.configuration = configuration;
-  }
-
-  @Override
-  public boolean shouldExecuteOnProject(Project project) {
-    return configuration.isEnabled(project)
-      && project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC)
-      && !project.getFileSystem().testFiles(Java.KEY).isEmpty();
-  }
-
-  @Override
-  public void execute(Project project) {
-    // nothing to do
-  }
-
-  public MavenPluginHandler getMavenPluginHandler(Project project) {
-    return handler;
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/package-info.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/package-info.java
deleted file mode 100644 (file)
index 67ea315..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.jacoco;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/AbstractAnalyzerTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/AbstractAnalyzerTest.java
deleted file mode 100644 (file)
index 2783b46..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.jacoco.core.analysis.ISourceFileCoverage;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Resource;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AbstractAnalyzerTest {
-  ISourceFileCoverage coverage = mock(ISourceFileCoverage.class);
-  SensorContext context = mock(SensorContext.class);
-
-  @Test
-  public void should_recognize_default_package() {
-    when(coverage.getPackageName()).thenReturn("");
-    when(coverage.getName()).thenReturn("Hello.java");
-    when(context.getResource(any(Resource.class))).thenAnswer(sameResource());
-
-    JavaFile resource = AbstractAnalyzer.getResource(coverage, context);
-
-    assertThat(resource).isEqualTo(new JavaFile("[default].Hello"));
-  }
-
-  @Test
-  public void should_recognize_non_default_package() {
-    when(coverage.getPackageName()).thenReturn("org/example");
-    when(coverage.getName()).thenReturn("Hello.java");
-    when(context.getResource(any(Resource.class))).thenAnswer(sameResource());
-
-    JavaFile resource = AbstractAnalyzer.getResource(coverage, context);
-
-    assertThat(resource).isEqualTo(new JavaFile("org.example.Hello"));
-  }
-
-  @Test
-  public void should_ignore_resource_not_found_in_context() {
-    when(coverage.getPackageName()).thenReturn("org/example");
-    when(coverage.getName()).thenReturn("HelloTest.java");
-    when(context.getResource(any(Resource.class))).thenReturn(null);
-
-    JavaFile resource = AbstractAnalyzer.getResource(coverage, context);
-
-    assertThat(resource).isNull();
-  }
-
-  @Test
-  public void should_ignore_unit_tests() {
-    when(coverage.getPackageName()).thenReturn("org/example");
-    when(coverage.getName()).thenReturn("HelloTest.java");
-    when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("HelloTest.java", true));
-
-    JavaFile resource = AbstractAnalyzer.getResource(coverage, context);
-
-    assertThat(resource).isNull();
-  }
-
-  static Answer<Resource> sameResource() {
-    return new Answer<Resource>() {
-      public Resource answer(InvocationOnMock invocation) {
-        return (Resource) invocation.getArguments()[0];
-      }
-    };
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java
deleted file mode 100644 (file)
index a36882c..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import com.google.common.io.Files;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Project.AnalysisType;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.test.TestUtils;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-public class JaCoCoItSensorTest {
-  private static File outputDir;
-  private static File jacocoExecutionData;
-
-  private JacocoConfiguration configuration;
-  private JaCoCoItSensor sensor;
-
-  @BeforeClass
-  public static void setUpOutputDir() throws IOException {
-    outputDir = TestUtils.getResource("/org/sonar/plugins/jacoco/JaCoCoSensorTest/");
-    jacocoExecutionData = new File(outputDir, "jacoco.exec");
-
-    Files.copy(TestUtils.getResource("Hello.class.toCopy"), new File(jacocoExecutionData.getParentFile(), "Hello.class"));
-  }
-
-  @Before
-  public void setUp() {
-    configuration = mock(JacocoConfiguration.class);
-    sensor = new JaCoCoItSensor(configuration);
-  }
-
-  @Test
-  public void testSensorDefinition() {
-    assertThat(sensor.toString()).isEqualTo("JaCoCoItSensor");
-  }
-
-  @Test
-  public void doNotExecuteWhenReportPathNotSpecified() {
-    Project project = mock(Project.class);
-    when(configuration.getItReportPath()).thenReturn("");
-
-    assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
-  }
-
-  @Test
-  public void shouldExecuteIfReportPathIsDefined() {
-    Project project = mock(Project.class);
-    when(project.getAnalysisType()).thenReturn(AnalysisType.DYNAMIC).thenReturn(AnalysisType.REUSE_REPORTS);
-    when(configuration.getItReportPath()).thenReturn("target/it-jacoco.exec");
-    when(configuration.isEnabled(project)).thenReturn(true);
-
-    assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
-  }
-
-  @Test
-  public void shouldNotExecuteIfReportPathIsNotDefined() {
-    Project project = mock(Project.class);
-    when(project.getAnalysisType()).thenReturn(AnalysisType.DYNAMIC).thenReturn(AnalysisType.REUSE_REPORTS);
-    when(configuration.getItReportPath()).thenReturn(null);
-    when(configuration.isEnabled(project)).thenReturn(true);
-
-    assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
-  }
-
-  @Test
-  public void testReadExecutionData() {
-    JavaFile resource = new JavaFile("org.sonar.plugins.jacoco.tests.Hello");
-    SensorContext context = mock(SensorContext.class);
-    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
-    Project project = mock(Project.class);
-    when(context.getResource(any(Resource.class))).thenReturn(resource);
-    when(pfs.getBuildOutputDir()).thenReturn(outputDir);
-    when(pfs.resolvePath(anyString())).thenReturn(jacocoExecutionData);
-    when(project.getFileSystem()).thenReturn(pfs);
-
-    sensor.analyse(project, context);
-
-    verify(context).getResource(resource);
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_LINES_TO_COVER, 7.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_LINES, 3.0)));
-    verify(context).saveMeasure(eq(resource),
-      argThat(new IsMeasure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER, 2.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS, 2.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_BY_LINE, "15=2")));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE, "15=0")));
-    verifyNoMoreInteractions(context);
-  }
-
-  @Test
-  public void doNotSaveMeasureOnResourceWhichDoesntExistInTheContext() {
-    SensorContext context = mock(SensorContext.class);
-    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
-    Project project = mock(Project.class);
-    when(context.getResource(any(Resource.class))).thenReturn(null);
-    when(pfs.getBuildOutputDir()).thenReturn(outputDir);
-    when(project.getFileSystem()).thenReturn(pfs);
-
-    sensor.analyse(project, context);
-
-    verify(context, never()).saveMeasure(any(Resource.class), any(Measure.class));
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java
deleted file mode 100644 (file)
index 7b51c2d..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenSurefireUtils;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Project;
-import org.sonar.api.test.MavenTestUtils;
-import org.sonar.plugins.java.api.JavaSettings;
-
-import java.io.File;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.mockito.Mockito.*;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class JaCoCoMavenPluginHandlerTest {
-
-  private JacocoConfiguration configuration;
-  private JaCoCoMavenPluginHandler handler;
-
-  @Before
-  public void setUp() throws Exception {
-    JaCoCoAgentDownloader downloader = mock(JaCoCoAgentDownloader.class);
-    when(downloader.getAgentJarFile()).thenReturn(new File("jacocoagent.jar"));
-    Settings settings = new Settings(new PropertyDefinitions(JacocoConfiguration.class));
-    configuration = spy(new JacocoConfiguration(settings, downloader, new JavaSettings(settings)));
-
-    handler = new JaCoCoMavenPluginHandler(configuration);
-  }
-
-  @Test
-  public void testMavenPluginDefinition() {
-    assertThat(handler.getGroupId(), is(MavenSurefireUtils.GROUP_ID));
-    assertThat(handler.getArtifactId(), is(MavenSurefireUtils.ARTIFACT_ID));
-    assertThat(handler.getVersion(), is(MavenSurefireUtils.VERSION));
-    assertThat(handler.getGoals(), is(new String[] { "test" }));
-    assertThat(handler.isFixedVersion(), is(false));
-  }
-
-  @Test
-  public void testConfigureMavenPlugin() {
-    Project project = MavenTestUtils.loadProjectFromPom(getClass(), "pom.xml");
-    MavenPlugin plugin = new MavenPlugin(handler.getGroupId(), handler.getArtifactId(), handler.getVersion());
-
-    handler.configure(project, plugin);
-
-    verify(configuration).getJvmArgument();
-    assertThat(plugin.getParameter("argLine"), is("-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,excludes=*_javassist_*"));
-    assertThat(plugin.getParameter("testFailureIgnore"), is("true"));
-  }
-
-  @Test
-  public void testReconfigureMavenPlugin() {
-    Project project = MavenTestUtils.loadProjectFromPom(getClass(), "pom2.xml");
-    MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId());
-
-    handler.configure(project, plugin);
-
-    verify(configuration).getJvmArgument();
-    assertThat(plugin.getParameter("argLine"), is("-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,excludes=*_javassist_* -esa"));
-    assertThat(plugin.getParameter("testFailureIgnore"), is("true"));
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java
deleted file mode 100644 (file)
index 0525c62..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import com.google.common.io.Files;
-import org.junit.Test;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.test.TestUtils;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-public class JaCoCoOverallSensorTest {
-  private final JacocoConfiguration configuration = mock(JacocoConfiguration.class);
-  private final SensorContext context = mock(SensorContext.class);
-  private final ProjectFileSystem pfs = mock(ProjectFileSystem.class);
-  private final Project project = mock(Project.class);
-  private final JaCoCoOverallSensor sensor = new JaCoCoOverallSensor(configuration);
-
-  @Test
-  public void should_execute_if_report_path_is_set() {
-    Project project = mock(Project.class);
-    when(configuration.getItReportPath()).thenReturn("target/it-jacoco.exec");
-    when(configuration.isEnabled(project)).thenReturn(true);
-
-    assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
-  }
-
-  @Test
-  public void do_not_execute_when_report_path_not_specified() {
-    Project project = mock(Project.class);
-    when(configuration.getItReportPath()).thenReturn("");
-
-    assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
-  }
-
-  @Test
-  public void should_save_measures() throws IOException {
-    File outputDir = TestUtils.getResource(JaCoCoOverallSensorTest.class, ".");
-    Files.copy(TestUtils.getResource("HelloWorld.class.toCopy"), new File(outputDir, "HelloWorld.class"));
-
-    JavaFile resource = new JavaFile("com.sonar.coverages.HelloWorld");
-
-    when(project.getFileSystem()).thenReturn(pfs);
-    when(context.getResource(any(Resource.class))).thenReturn(resource);
-    when(configuration.getReportPath()).thenReturn("ut.exec");
-    when(configuration.getItReportPath()).thenReturn("it.exec");
-    when(pfs.getBuildOutputDir()).thenReturn(outputDir);
-    when(pfs.resolvePath("ut.exec")).thenReturn(new File(outputDir, "ut.exec"));
-    when(pfs.resolvePath("it.exec")).thenReturn(new File(outputDir, "it.exec"));
-    when(pfs.getSonarWorkingDirectory()).thenReturn(new File("target/sonar"));
-    when(pfs.resolvePath(new File("target/sonar/jacoco-overall.exec").getAbsolutePath())).thenReturn(new File("target/sonar/jacoco-overall.exec"));
-
-    sensor.analyse(project, context);
-
-    verify(context).getResource(resource);
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_LINES_TO_COVER, 12.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_UNCOVERED_LINES, 2.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA, "3=1;6=1;7=1;10=1;11=1;14=1;15=1;17=1;18=1;20=1;23=0;24=0")));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_CONDITIONS_TO_COVER, 2.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_UNCOVERED_CONDITIONS, 0.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_CONDITIONS_BY_LINE, "14=2")));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE, (String) null)));
-    verifyNoMoreInteractions(context);
-  }
-
-  @Test
-  public void should_no_save_measures_when_it_report_is_not_found() throws IOException {
-    File outputDir = TestUtils.getResource(JaCoCoOverallSensorTest.class, ".");
-
-    when(project.getFileSystem()).thenReturn(pfs);
-    when(configuration.getReportPath()).thenReturn("ut.exec");
-    when(configuration.getItReportPath()).thenReturn("it.not.found.exec");
-    when(pfs.resolvePath("ut.exec")).thenReturn(new File(outputDir, "ut.exec"));
-    when(pfs.resolvePath("it.not.found.exec")).thenReturn(new File("it.not.found.exec"));
-
-    sensor.analyse(project, context);
-
-    verifyZeroInteractions(context);
-  }
-
-  @Test
-  public void should_no_save_measures_when_ut_report_is_not_found() throws IOException {
-    File outputDir = TestUtils.getResource(JaCoCoOverallSensorTest.class, ".");
-
-    when(project.getFileSystem()).thenReturn(pfs);
-    when(configuration.getReportPath()).thenReturn("ut.not.found.exec");
-    when(configuration.getItReportPath()).thenReturn("it.exec");
-    when(pfs.resolvePath("ut.not.found.exec")).thenReturn(new File("ut.not.found.exec"));
-    when(pfs.resolvePath("it.exec")).thenReturn(new File(outputDir, "it.exec"));
-
-    sensor.analyse(project, context);
-
-    verifyZeroInteractions(context);
-  }
-
-  @Test
-  public void testSensorDefinition() {
-    assertThat(sensor.toString()).isEqualTo("JaCoCoOverallSensor");
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java
deleted file mode 100644 (file)
index c54c361..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
-
-public class JaCoCoPluginTest {
-
-  @Test
-  public void testExtensions() {
-    assertThat(new JaCoCoPlugin().getExtensions().size(), greaterThan(0));
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java
deleted file mode 100644 (file)
index fcc6bac..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import com.google.common.io.Files;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.test.TestUtils;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class JaCoCoSensorTest {
-
-  private static File jacocoExecutionData;
-  private static File outputDir;
-
-  private JacocoConfiguration configuration;
-  private JaCoCoSensor sensor;
-
-  @BeforeClass
-  public static void setUpOutputDir() throws IOException {
-    outputDir = TestUtils.getResource("/org/sonar/plugins/jacoco/JaCoCoSensorTest/");
-    jacocoExecutionData = new File(outputDir, "jacoco.exec");
-
-    Files.copy(TestUtils.getResource("Hello.class.toCopy"), new File(jacocoExecutionData.getParentFile(), "Hello.class"));
-  }
-
-  @Before
-  public void setUp() {
-    configuration = mock(JacocoConfiguration.class);
-    sensor = new JaCoCoSensor(configuration);
-  }
-
-  @Test
-  public void testSensorDefinition() {
-    assertThat(sensor.toString(), is("JaCoCoSensor"));
-  }
-
-  @Test
-  public void shouldExecuteIfEnabled() {
-    Project project = mock(Project.class);
-
-    when(configuration.isEnabled(project)).thenReturn(true);
-    assertThat(sensor.shouldExecuteOnProject(project), is(true));
-
-    when(configuration.isEnabled(project)).thenReturn(false);
-    assertThat(sensor.shouldExecuteOnProject(project), is(false));
-  }
-
-  @Test
-  public void testReadExecutionData() {
-    JavaFile resource = new JavaFile("org.sonar.plugins.jacoco.tests.Hello");
-    SensorContext context = mock(SensorContext.class);
-    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
-    Project project = mock(Project.class);
-    when(context.getResource(any(Resource.class))).thenReturn(resource);
-    when(pfs.getBuildOutputDir()).thenReturn(outputDir);
-    when(pfs.resolvePath(anyString())).thenReturn(jacocoExecutionData);
-    when(project.getFileSystem()).thenReturn(pfs);
-
-    sensor.analyse(project, context);
-
-    verify(context).getResource(resource);
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 7.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 3.0)));
-    verify(context).saveMeasure(eq(resource),
-      argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 2.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 2.0)));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.CONDITIONS_BY_LINE, "15=2" +
-      "")));
-    verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.COVERED_CONDITIONS_BY_LINE, "15=0")));
-    verifyNoMoreInteractions(context);
-  }
-
-  @Test
-  public void doNotSaveMeasureOnResourceWhichDoesntExistInTheContext() {
-    SensorContext context = mock(SensorContext.class);
-    ProjectFileSystem pfs = mock(ProjectFileSystem.class);
-    Project project = mock(Project.class);
-    when(context.getResource(any(Resource.class))).thenReturn(null);
-    when(pfs.getBuildOutputDir()).thenReturn(outputDir);
-    when(project.getFileSystem()).thenReturn(pfs);
-
-    sensor.analyse(project, context);
-
-    verify(context, never()).saveMeasure(any(Resource.class), any(Measure.class));
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java
deleted file mode 100644 (file)
index f548d79..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Project;
-import org.sonar.plugins.java.api.JavaSettings;
-
-import java.io.File;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class JacocoConfigurationTest {
-
-  private Settings settings;
-  private JacocoConfiguration jacocoSettings;
-  private JavaSettings javaSettings;
-
-  @Before
-  public void setUp() {
-    JaCoCoAgentDownloader downloader = mock(JaCoCoAgentDownloader.class);
-    when(downloader.getAgentJarFile()).thenReturn(new File("jacocoagent.jar"));
-    javaSettings = mock(JavaSettings.class);
-    settings = new Settings(new PropertyDefinitions(JacocoConfiguration.class));
-    jacocoSettings = new JacocoConfiguration(settings, downloader, javaSettings);
-  }
-
-  @Test
-  public void should_be_enabled() {
-    Project project = mock(Project.class);
-    when(project.getLanguageKey()).thenReturn(Java.KEY);
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
-    when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
-
-    assertThat(jacocoSettings.isEnabled(project)).isTrue();
-  }
-
-  @Test
-  public void should_be_enabled_if_reuse_report() {
-    Project project = mock(Project.class);
-    when(project.getLanguageKey()).thenReturn(Java.KEY);
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
-    when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
-
-    assertThat(jacocoSettings.isEnabled(project)).isTrue();
-  }
-
-  @Test
-  public void should_be_enabled_if_static_analysis_only() {
-    Project project = mock(Project.class);
-    when(project.getLanguageKey()).thenReturn(Java.KEY);
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
-    when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
-
-    assertThat(jacocoSettings.isEnabled(project)).isFalse();
-  }
-
-  @Test
-  public void plugin_should_be_disabled() {
-    Project project = mock(Project.class);
-    when(project.getLanguageKey()).thenReturn(Java.KEY);
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
-    when(javaSettings.getEnabledCoveragePlugin()).thenReturn("cobertura");
-
-    assertThat(jacocoSettings.isEnabled(project)).isFalse();
-  }
-
-  @Test
-  public void should_be_disabled_if_not_java() {
-    Project project = mock(Project.class);
-    when(project.getLanguageKey()).thenReturn("flex");
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
-    when(javaSettings.getEnabledCoveragePlugin()).thenReturn(JaCoCoUtils.PLUGIN_KEY);
-
-    assertThat(jacocoSettings.isEnabled(project)).isFalse();
-  }
-
-  @Test
-  public void defaults() {
-    assertThat(jacocoSettings.getReportPath()).isEqualTo("target/jacoco.exec");
-    assertThat(jacocoSettings.getJvmArgument()).isEqualTo("-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,excludes=*_javassist_*");
-
-    assertThat(jacocoSettings.getItReportPath()).isNull();
-
-    assertThat(jacocoSettings.getAntTargets()).isEqualTo(new String[]{});
-  }
-
-  @Test
-  public void shouldReturnAntTargets() {
-    settings.setProperty(JacocoConfiguration.ANT_TARGETS_PROPERTY, "test");
-    assertThat(jacocoSettings.getAntTargets()).isEqualTo(new String[]{"test"});
-
-    settings.setProperty(JacocoConfiguration.ANT_TARGETS_PROPERTY, "test1,test2");
-    assertThat(jacocoSettings.getAntTargets()).isEqualTo(new String[]{"test1", "test2"});
-  }
-
-  @Test
-  public void shouldReturnItReportPath() {
-    settings.setProperty(JacocoConfiguration.IT_REPORT_PATH_PROPERTY, "target/it-jacoco.exec");
-
-    assertThat(jacocoSettings.getItReportPath()).isEqualTo("target/it-jacoco.exec");
-  }
-
-  @Test
-  public void shouldSetDestfile() {
-    settings.setProperty(JacocoConfiguration.REPORT_PATH_PROPERTY, "jacoco.exec");
-
-    assertThat(jacocoSettings.getReportPath()).isEqualTo("jacoco.exec");
-    assertThat(jacocoSettings.getJvmArgument()).isEqualTo("-javaagent:jacocoagent.jar=destfile=jacoco.exec,excludes=*_javassist_*");
-  }
-
-  @Test
-  public void shouldSetIncludesAndExcludes() {
-    settings.setProperty(JacocoConfiguration.INCLUDES_PROPERTY, "org.sonar.*");
-    settings.setProperty(JacocoConfiguration.EXCLUDES_PROPERTY, "org.sonar.api.*");
-    settings.setProperty(JacocoConfiguration.EXCLCLASSLOADER_PROPERTY, "sun.reflect.DelegatingClassLoader");
-
-    assertThat(jacocoSettings.getJvmArgument()).isEqualTo(
-      "-javaagent:jacocoagent.jar=destfile=target/jacoco.exec,includes=org.sonar.*,excludes=org.sonar.api.*,exclclassloader=sun.reflect.DelegatingClassLoader"
-    );
-  }
-
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java
deleted file mode 100644 (file)
index e82fc70..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.plugins.jacoco;
-
-import org.hamcrest.core.Is;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.resources.InputFile;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-
-import java.util.Collections;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
-
-public class JacocoMavenInitializerTest {
-  private JaCoCoMavenPluginHandler mavenPluginHandler;
-  private JacocoMavenInitializer initializer;
-  private JacocoConfiguration jacocoSettings;
-
-  @Before
-  public void setUp() {
-    mavenPluginHandler = mock(JaCoCoMavenPluginHandler.class);
-    jacocoSettings = mock(JacocoConfiguration.class);
-    when(jacocoSettings.isEnabled(any(Project.class))).thenReturn(true);
-    initializer = new JacocoMavenInitializer(mavenPluginHandler, jacocoSettings);
-  }
-
-  @Test
-  public void shouldDoNothing() {
-    Project project = mockProject();
-    initializer.execute(project);
-    verifyNoMoreInteractions(project);
-    verifyNoMoreInteractions(mavenPluginHandler);
-  }
-
-  @Test
-  public void shouldExecuteMaven() {
-    Project project = mockProject();
-    InputFile inputFile = mock(InputFile.class);
-    when(project.getFileSystem().testFiles(Java.KEY)).thenReturn(Collections.singletonList(inputFile));
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
-
-    assertThat(initializer.shouldExecuteOnProject(project)).isTrue();
-    assertThat(initializer.getMavenPluginHandler(project)).isInstanceOf(JaCoCoMavenPluginHandler.class);
-  }
-
-  @Test
-  public void shouldNotExecuteMavenWhenReuseReports() {
-    Project project = mockProject();
-    InputFile inputFile = mock(InputFile.class);
-    when(project.getFileSystem().testFiles(Java.KEY)).thenReturn(Collections.singletonList(inputFile));
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
-
-    assertThat(initializer.shouldExecuteOnProject(project)).isFalse();
-  }
-
-  @Test
-  public void shouldNotExecuteMavenWhenNoTests() {
-    Project project = mockProject();
-    when(project.getFileSystem().hasTestFiles(argThat(Is.is(Java.INSTANCE)))).thenReturn(false);
-    when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
-
-    assertThat(initializer.shouldExecuteOnProject(project)).isFalse();
-  }
-
-  private Project mockProject() {
-    Project project = mock(Project.class);
-    ProjectFileSystem projectFileSystem = mock(ProjectFileSystem.class);
-    when(project.getFileSystem()).thenReturn(projectFileSystem);
-    return project;
-  }
-}
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/Hello.class.toCopy b/plugins/sonar-jacoco-plugin/src/test/resources/Hello.class.toCopy
deleted file mode 100644 (file)
index e004f4f..0000000
Binary files a/plugins/sonar-jacoco-plugin/src/test/resources/Hello.class.toCopy and /dev/null differ
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/HelloWorld.class.toCopy b/plugins/sonar-jacoco-plugin/src/test/resources/HelloWorld.class.toCopy
deleted file mode 100644 (file)
index 5965c3d..0000000
Binary files a/plugins/sonar-jacoco-plugin/src/test/resources/HelloWorld.class.toCopy and /dev/null differ
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom.xml b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom.xml
deleted file mode 100644 (file)
index 0cc5322..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<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/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>foo</groupId>
-  <artifactId>bar</artifactId>
-  <version>0.2-SNAPSHOT</version>
-  <packaging>jar</packaging>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <target>1.5</target>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
\ No newline at end of file
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom2.xml b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom2.xml
deleted file mode 100644 (file)
index 127ec72..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<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/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>foo</groupId>
-  <artifactId>bar</artifactId>
-  <version>0.2-SNAPSHOT</version>
-  <packaging>jar</packaging>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <target>1.5</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <argLine>-esa</argLine>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
\ No newline at end of file
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec
deleted file mode 100644 (file)
index 3a75745..0000000
Binary files a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec and /dev/null differ
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec
deleted file mode 100644 (file)
index bf1248b..0000000
Binary files a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec and /dev/null differ
diff --git a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoSensorTest/jacoco.exec b/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoSensorTest/jacoco.exec
deleted file mode 100644 (file)
index c7cadcc..0000000
Binary files a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoSensorTest/jacoco.exec and /dev/null differ
diff --git a/pom.xml b/pom.xml
index e2b0c28e1e586c6765e7204a66ee025df85d0671..a3ffaff5f480ef86777350ebd244ee5ad4e04497 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,6 @@
     <module>plugins/sonar-design-plugin</module>
     <module>plugins/sonar-l10n-en-plugin</module>
     <module>plugins/sonar-email-notifications-plugin</module>
-    <module>plugins/sonar-jacoco-plugin</module>
   </modules>
 
   <organization>
         <artifactId>sonar-cobertura-plugin</artifactId>
         <version>${sonarJava.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.codehaus.sonar-plugins.java</groupId>
+        <artifactId>sonar-jacoco-plugin</artifactId>
+        <version>${sonarJava.version}</version>
+      </dependency>
       <dependency>
         <groupId>asm</groupId>
         <artifactId>asm-all</artifactId>
index ac950cdabfdde7b0be1bb3b16c7db8a586546ee0..fba2c5856596d9237f7d751abdb873e6fcdd7624 100644 (file)
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.sonar.plugins</groupId>
+      <groupId>org.codehaus.sonar-plugins.java</groupId>
       <artifactId>sonar-jacoco-plugin</artifactId>
-      <version>${project.version}</version>
       <scope>runtime</scope>
     </dependency>
     <dependency>
index bf96e6d43df91e9c58515ac24b1c34d2830aa417..a92abf15a1005098a3c14dffae503c5fee4164a4 100644 (file)
           <scope>provided</scope>
         </dependency>
         <dependency>
-          <groupId>org.codehaus.sonar.plugins</groupId>
+          <groupId>org.codehaus.sonar-plugins.java</groupId>
           <artifactId>sonar-jacoco-plugin</artifactId>
-          <version>${project.version}</version>
+          <version>${sonarJava.version}</version>
           <type>sonar-plugin</type>
           <scope>provided</scope>
         </dependency>