From e5a5982d9004ac5ad1187cff8f23cd8f028190f0 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 6 Nov 2012 22:52:48 +0100 Subject: [PATCH] SONAR-3934 Extract sonar-jacoco-plugin into Sonar Java --- plugins/sonar-jacoco-plugin/infinitest.args | 1 - plugins/sonar-jacoco-plugin/pom.xml | 138 -------------- .../plugins/jacoco/AbstractAnalyzer.java | 176 ------------------ .../plugins/jacoco/JaCoCoAgentDownloader.java | 62 ------ .../sonar/plugins/jacoco/JaCoCoItSensor.java | 102 ---------- .../jacoco/JaCoCoMavenPluginHandler.java | 93 --------- .../plugins/jacoco/JaCoCoOverallSensor.java | 165 ---------------- .../sonar/plugins/jacoco/JaCoCoPlugin.java | 44 ----- .../sonar/plugins/jacoco/JaCoCoSensor.java | 75 -------- .../org/sonar/plugins/jacoco/JaCoCoUtils.java | 39 ---- .../plugins/jacoco/JacocoAntInitializer.java | 143 -------------- .../plugins/jacoco/JacocoConfiguration.java | 163 ---------------- .../jacoco/JacocoMavenInitializer.java | 57 ------ .../sonar/plugins/jacoco/package-info.java | 25 --- .../plugins/jacoco/AbstractAnalyzerTest.java | 90 --------- .../plugins/jacoco/JaCoCoItSensorTest.java | 143 -------------- .../jacoco/JaCoCoMavenPluginHandlerTest.java | 89 --------- .../jacoco/JaCoCoOverallSensorTest.java | 134 ------------- .../plugins/jacoco/JaCoCoPluginTest.java | 33 ---- .../plugins/jacoco/JaCoCoSensorTest.java | 131 ------------- .../jacoco/JacocoConfigurationTest.java | 146 --------------- .../jacoco/JacocoMavenInitializerTest.java | 93 --------- .../src/test/resources/Hello.class.toCopy | Bin 531 -> 0 bytes .../test/resources/HelloWorld.class.toCopy | Bin 954 -> 0 bytes .../JaCoCoMavenPluginHandlerTest/pom.xml | 18 -- .../JaCoCoMavenPluginHandlerTest/pom2.xml | 25 --- .../jacoco/JaCoCoOverallSensorTest/it.exec | Bin 5862 -> 0 bytes .../jacoco/JaCoCoOverallSensorTest/ut.exec | Bin 5851 -> 0 bytes .../jacoco/JaCoCoSensorTest/jacoco.exec | Bin 4422 -> 0 bytes pom.xml | 6 +- sonar-application/pom.xml | 3 +- sonar-server/pom.xml | 4 +- 32 files changed, 8 insertions(+), 2190 deletions(-) delete mode 100644 plugins/sonar-jacoco-plugin/infinitest.args delete mode 100644 plugins/sonar-jacoco-plugin/pom.xml delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/AbstractAnalyzer.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAgentDownloader.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandler.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoUtils.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java delete mode 100644 plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/package-info.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/AbstractAnalyzerTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/Hello.class.toCopy delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/HelloWorld.class.toCopy delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom.xml delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom2.xml delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/it.exec delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest/ut.exec delete mode 100644 plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoSensorTest/jacoco.exec diff --git a/plugins/sonar-jacoco-plugin/infinitest.args b/plugins/sonar-jacoco-plugin/infinitest.args deleted file mode 100644 index ed9f41dadc7..00000000000 --- a/plugins/sonar-jacoco-plugin/infinitest.args +++ /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 index 985a5d5a0d5..00000000000 --- a/plugins/sonar-jacoco-plugin/pom.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - 4.0.0 - - - org.codehaus.sonar - sonar - 3.4-SNAPSHOT - ../.. - - - org.codehaus.sonar.plugins - sonar-jacoco-plugin - sonar-plugin - - Sonar :: Plugins :: JaCoCo - JaCoCo is an alternative to Clover and Cobertura to measure coverage by unit tests - http://docs.codehaus.org/display/SONAR/JaCoCo+Plugin - 2010 - - SonarSource - http://www.sonarsource.com - - - - GNU LGPL 3 - http://www.gnu.org/licenses/lgpl.txt - repo - - - - - - godin - Evgeny Mandrikov - - - - - 0.5.10.201208310627 - - JaCoCo - org.sonar.plugins.jacoco.JaCoCoPlugin - - - - - org.jacoco - org.jacoco.core - ${jacoco.version} - - - org.jacoco - org.jacoco.agent - ${jacoco.version} - - - org.codehaus.sonar - sonar-plugin-api - provided - - - org.codehaus.sonar-plugins.java - sonar-java-plugin - ${sonarJava.version} - provided - - - - org.apache.ant - ant - 1.7.0 - provided - - - - org.codehaus.sonar - sonar-testing-harness - test - - - org.apache.maven - maven-project - 2.0.7 - test - - - - - - - org.codehaus.sonar - sonar-dev-maven-plugin - - - trim - process-resources - - trim - - - ${project.build.outputDirectory} - - **/*.erb - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-plugin-size - - enforce - - verify - - - - 400000 - 300000 - - ${project.build.directory}/${project.build.finalName}.jar - - - - - - - - - - - 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 index ca4542faae0..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/AbstractAnalyzer.java +++ /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 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 index 90571ed6fb3..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoAgentDownloader.java +++ /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 index 881c513819e..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java +++ /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 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 index a674f2482e2..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandler.java +++ /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 index 84c0c5f0a39..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java +++ /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 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 index 025d4dd1714..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java +++ /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 index d5d19c416af..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoSensor.java +++ /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 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 index 050a39a2fd9..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoUtils.java +++ /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 index 85fefdebecb..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java +++ /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 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 true 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 index 7d13a752630..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoConfiguration.java +++ /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: - *
-   * Javassist Enhancement failed: org.sonar.api.profiles.Alert
-   * java.lang.VerifyError: (class: org/sonar/api/profiles/Alert_$$_javassist_3, method:  signature: ()V) Illegal local variable number
-   * 
- */ - 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 index c7c320537a3..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java +++ /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 index 67ea3154bf2..00000000000 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/package-info.java +++ /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 index 2783b462dcc..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/AbstractAnalyzerTest.java +++ /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 sameResource() { - return new Answer() { - 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 index a36882c4f0a..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java +++ /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 index 7b51c2d5811..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java +++ /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 index 0525c62b5bc..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoOverallSensorTest.java +++ /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 index c54c3617ba2..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoPluginTest.java +++ /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 index fcc6bacabd7..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoSensorTest.java +++ /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 index f548d7963b4..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java +++ /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 index e82fc70ad18..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java +++ /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 index e004f4f6149fca8c1f695d7476074e399e08a570..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 531 zcma)3%SyvQ6g`uskEF4!RqJadh_qQaxK>0c6bnTcO83)rs8hy_B&p!f_yyevKEQ<^ z;75r!52Q;6=Dy~hb1rwje?GqeoM6vI8JiAlY`J7QRcu$W!@v~XAw%U%g(^8`u)D+F zm|WjXB|~$hLV2~gpUCJ|Of*&6BNGTc7LiKxqG%^~DrPtunP|pi6N-pG=*3KhF`tXT z1coOvPGWv3wKk^=rC2|<~ zEY!(1s27B?3Fi>TqpXv6V~t+Z<7TY1*>u{1lapukR`y?EEh)(9Dp|3f(Rg`7L1Sb6 k4}4L88!7l1HUAx@Si&t;k$zvA3fr2qf` 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 index 5965c3d25afcd8a9e2517ba3e0216348571e6c3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 954 zcmaJ<%Wl&^6g`u;v6Hw>N!z5f&>C7GDNw83uqa}Kgg}Z4QbLfr8#|-al{16vNu_=Y zU%(m`AhF;B_$b63J4#Z?!i$;vJm=i&`SbVJZvZFoYpCO175A~{V7~?r4;(ynaNyw3 z!6OHcZ9K8jVW_-}WTam)lsnxagY{aC1Vf`2NpU`%1R@#mAf`yOr$QbNc@i0a7PRzb zlrng|P)+<)NuKzjx)uo^i`0KB;#hrBNjy4Z*hu+J78t0H#5WMBrpBE`^qtgVoNyf} zIZHZ0!ew|VsLtwKWa2cnF|Z4Unp8TY5+ic@YMO-NO=N^N7QDw-{F=LPv1+61;s{R} z*0Z!{M0gpIjb|>Ne-pRr|WpHzW-l-RuE!5AI_U4-Q{=X6uV#N6| zmt+5Za3w+-Y$?>gNwt{JUr|#^Z1u9@NckU&!#Ar)Yr)yGZyNK z6T{tN+0|Rn`Rr|yy - 4.0.0 - foo - bar - 0.2-SNAPSHOT - jar - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - - - - - \ 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 index 127ec720f95..00000000000 --- a/plugins/sonar-jacoco-plugin/src/test/resources/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest/pom2.xml +++ /dev/null @@ -1,25 +0,0 @@ - - 4.0.0 - foo - bar - 0.2-SNAPSHOT - jar - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - - - - org.apache.maven.plugins - maven-surefire-plugin - - -esa - - - - - \ 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 index 3a75745c38048aaafef95b86ae07bd79fde53ba6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5862 zcmb_gdvp_39==H$Qd(MaDPTnkErh3*X-T0_Q0RlwBBh}LY8M|&)0=kaWG391lt!K+ zk5v{$7g1CM+VX}2E3ZW=RF;K>t_wY)s|W~1M8qCM)E3ySq>oIiXZfQ!Ipp5C z_xpXn@B4nEtEn+}GK07bx{N6j;&W(68qb%;+b}$PimncVzSt`pQWL4Ty!Y>YmY6qtEqKKU_`qo$?>ov z$kati#xyW0Jy&LOhe`V5*=GIb3i1lIiL5=M~N360Ym)f zP>`WGnNtpeBhQgTaFYq1h;T1d2QMzYEzC&YwH}x(gwN&PgeVAfa6?6&dF7GSTnDO@ zh8g6{WLV^@wO$9aVm#MgA6A=bTKj2g~pecp|}?+XMb` zX3pK$Rv43&izvbnq*y*du-IuQ@_p&NK?nb!dtv>gI#(5lcknJs;5iyo4!#UwA^-xF zg;{KV8$q8~=TE z^36jl4=ZeI8$!Xuh)CjF9ui0~!Zzq(O!%BrkB3ED0!jLy>V+PLC65s(xgV`*%GZzx zSigGLkDvXxLSKp)ZEQoHohUl}*=q^N#D%QPT&3@VY z9vBz=P(le^ged9%9mE|>&Uob&5Uy_PzOl6)YMk{F+giKP-x z%jTRs5fQv<U0*B_n>dQ7uO5fpYHDzA0@;u~ZiR>_CD4k|m zx{yT%1N``v603Ldr9r^biW@GPW85BAk!L$`bA(N)aMzVnE5_w!4%3nvmAje5?TFhF zoCMx4#35Z_RkxUP$?wIT0F#2_-44~tT`cvK+ilI@UHO>wGw$+pXSgBUIrYkx?qflU z|1z!1pUSeT4%>J^U7_ri)D!Z&-|3!8a z7|`0*2N6zl9DEI+n1>dC| zb@1)3=BwdDF54INvKe6MhJT00S${6=04$0h*+qs~6wAacTEQtmk z6!g84>dPEaS{~Tqo~kX8Q|;WbBV+oGEe8%Bx%H1H;LzB#bv^Che+sgHGYwki>`Y?< zFvfzYt^n45_s-R~wtQ#|l!SJgJ9450zB;pZQi0iV9`tUBBFXlG12b-Em>K*HnZXvr z2=Ml*l+pL{wZKrzW@lU^NGZjez=_yPeH1QfAAJc9UMeX++%10Vx-_^sJ zch_#U|L}_gkS7G2^V(4+JCZUOk7Zci)xquE-rjz=JQVEj)P335^O3hU8A2h-KXvx4 zh9y%2XHbQk0@e15fsDpyE*xzrtNu6=ZjC;E?32A0-|uLR+aOG&F&Pg1{`#9=bHkll zaEk$9Rvje5`s!eD&Byz`{8s|~YflisvZ#2$2=5%;)_8BW+pA1TEeKQS8_Mj`G^emc zbs}Q~y!%l~HN16Yrq+NZYqT#D^PF6eVc+zd1I%&o^V;Jca6Mib* zXR#7y-uSj(Y}MRF=~@qK)|=8r$r~iS9?o!p{@cg)(rMX33t?9$qlX`^BZeDt>vZ_l z73(Rj^;3AxXNR)76Q3uxLOkik+q1L(He=f!Fg7@weI;(Gqyz-=I*aThbQ%XgrKe`c z?atftYl4ylTV){649*Bw3519 zXd6bN=(S-I`$%3=Muzz7v-C|(0N#1{!ZY>rep(vb8l@3jmL(EhPZS(FVB1I^(ZbxX zCV_7#Iv>)(_hYhB8lw_k0)4cZ^?1|4raKcsc_=Ji@y`XH_u0LmU6h6sNY^FIt}@T- z`YuQfUemS@X9<`Phzgc_LrgG#!lYSq`#n1a$RmH-I^T@hzC0WElcTgm2m7DCO>bQI W?!}JemcaKM7CZ034kSPw(EShM$*So9 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 index bf1248b02f61d06c441093ee8f9c9e587a855f47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5851 zcmb_gdvp_39==H$Qd(MaDPToPTMQ4uGAXST3JQHtTc9*FLh0gzX?oKRoy>$glhTMh zM3e=NiY%fi2(}e@9#me7RH!Tq3tbm_09TP`0THnWkyUi}l@B6;r=xS@tUCbaplP+h9g@jz%kw`4LFuaS1ic!!aVoa3aDS%~IIIaR>{Pi!VkjHJ)~qK7|BvGA}Yt z2H|j>0lt4=bkch-Ouh(Gq~)}m`~*=hx*Tzo;K9hrU_@c$=CMfS%O42m(i~laa2D+l zdF&l@V9)vb5%Ad_%-#ua$GDYaXzr6%B#4+S_U&hBtQs2~3jf+`qwR89eKL5g!;|EC zSdnqig2-?szFkrmG&k$OB@=-9L$(DW_Dws%@D4YU(6A%XF47`Hc5?{kzkCay*fsd< zT|7P<4D=(~638q}yU-jSmt`@CEegWEjuMiAryC$7fux!FqQkdinmKKD3 zxhR%Iy#cyQ|NQBZl%mDJ>|d592ndS>z^vDSg*rg~!OF^th`C$ubpc8KpS7tm_OM8x z^2uNMRMTjdDW*w{|c@X zRZ7PUa%M3s^3__egV`~jD=UZ96@UlY97VyG{HCGM^wEV&cM8E^|8M-Tq1hf%eSuPH zqI@%$;QUn&%|CKsQBN>JTGT#~JtD(WnaD{K9%hmbksHD8prvLTG~>;Crfj$ho?l#q zqE;w`Xn&g`o+o{(9KcPBrTvVxH4nqhhmJqD=$nFit&VKHGK1%wOo<1}@DF&xnv~ZI z{&sx!oi~;kQAGGAS41ZF{qE?X9UwV480uNlX#tV)68X9> z4LyFoqKDW2^ZKM4dzbH1IMY55f`<{2#F~605JtRgz?4yr|MOy-?cE5H-9)=~4 z5h%H~zrQMtBW$HbRIDyE8R3oN2QFmZszzW~@QY$q z20ff#FHAa^v}$$ajfpG0V37Zr3eG;=y)PHJ$W?@}F$y+REv#?oRdoVHw_Zb3R_0|l zA}W<@R@SiJ^t}tl20xTgN*5za`hN$}_)^*VK|crYq6D6!F?oDB!o(K@ zDjTsZU%+Fw*fbR0o|!#*Tf&yiKw)fK$D9(5$M@@DFv1^u4?Yr}?B&6z;8zc9f=N7q z0k>#_&?=bpvTdyMYL;G0V?;>=kVr{ZkcNpd5@*WcoIH^N{OX7ox>wcyNsGEN%FVSyITl z@1L&y?)0+db)67BpM|vm7iLrdcsMTFwrl_4sfxF>PeB#k>A92g)v%nh^~wn&IO&4f zZ{|H#*tGMHTJ=?z`x01S4?&ppTOUf<86_EL;Ceczn{Y zWu1UU@guv45$(#L-69!JFx=e*K+o8(uXTN;W~7qy+OLeN(@0q!5)QYHcFkcYB`nZt z7GJ-qgAlQONpj8G-+&cOA2%Jp9(i1gQED}POlZNVh?oap-jMLwJL9j8Ix)+myME;umbmPV4n-;zmcA&da;yqY@dZh;mUYT4|Jiv%g9c;h({ zd#TUEC9#JW>u%J%ACmnf7#AD`5{q194w6H6vXWAhNpJdwB6V~&>fr|4&cxeCPVLaj zIf0ucsgYM^Mk#WXA^gB&qq5=3)ML{R|B`S6^w&;g(mEoDvA@0g!I;vwURGpVqhqFG zRtk`UdE;krSM`S%k5x9FRKN@Jra_Q`wF_}%u*%`e`7)G?B-tm=>=AcuuKDC=W{?mZ zHPwcl&37-5iYS`TO3S^c5? z$KM=)JR#U{*MX4Pkrdf@EW@%^2RHY4XY;;_P_U~@&zHxXj=cH4Arzv5qbJ^OTr?$c z@KmTQQ0>1B$ZUG%?19GenlB>ZhtY=)p8DwAC!M84JN$|?robUTTzl&(H{7WOwEC;T08&OJ2u65&-=?O!v)o=~sA@%+BHs*Wmxe!uC8}{5 zBjBCSQ)}SOOEa|QF86hhNpLD;!c;c?86@Rt15w(U|a4u}Vu4 zVdnMk`o~qzS&*UiuokT>U6i~w((BLB&tgZ0FpLv9`mzr17} zrL}%C&-vU_HUkn1hzk)5d+FA!oWD)mv;&L@&SqbUTMI7%fxN>a`v_ge!ZY-gocQhe zJAO~Dl7LIQuq^z`bN$0QL^+X6Q%wtN2Q6y8@|^EAP;zf*35BOW6(|wS{8B5}%Z0XK zB#K@eCMl7`D`mn+xHePY+zjCD2hTp!F!$%h!JSl^*kxHFN%wH!-rcqh^nNYO{b~~U zLZjNmec^#rOoItw9I;+||xBFU< z7QCkIAI=gmP!JWY@P?RR!T1R?=k$MeGLYX8w6F6mnC*+d@jpAtN_FtzW4GuH^Vgp1 UOw0*0r9_&B@)B)Xp0qql~+W-In 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 index c7cadccb04e741dfb4db985769babebc0f06005a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4422 zcmbtYdsGzH8NbW!vOFT}^=;&7R+Az)yyT?@c}PIeF04fDX;O#fE)34jEHksp#u#j* zlIpQ*iN~mTw2e7JJtVbFswX{QB*`&}p43PBP)rD7HOkR?0CUi&q<0?s5OzV^`GaNH z`_28`@AvzD-#4gEoX`jA!Q?8ol425Q(k8IBgpACTTP7hA6W$%cXn78PWsP@OlGv`?;W;qd@P8 z%i(#%39CSiCIA36z!%(F`-ZLL@cmd&C@v#yq`4XqR&pI;2;R;i3&kOVuO=%IA%1UW zD^WFR=Ls8)>hOnMplBkef)_Z_ESSus1S^&q%2U_C6Mrvj?o8^M34Y=M;0JgK#R~|Z zC`bk0Drn|nGmk`q0{?g_SXRKt9|u;^Ps=g7T=A4(@w@n_i$XSD`t{tVgJ72bN1K#0 z7pMUEpz*bnmjS$75EQrnli5y??mvt}HkK0zjCn1^ROPV@&(f$&`Xk~r;gDKc?JQgO z(lrn>G8a5yBss(gm_D2ULu!Bu7Dn2yG|fA`5=yC8y46X*xdDc)2 z&I&`)1cz$vh!=Pwk0yD(Oukd=;4DYN%fY{29y-=ZBt~6X$j9uP1(tIt)J6teyAuuX zovI!DZKF0Fqj`b^ZrSlGLxZQ!2+hpvElkAB?yyHV#b3@eZVs#JgnY2nV5rGYzk zhnxg)oUL36fp#{ z#Q@*Rc>-Glt-lL^uintL4NpPugZ%&bnI?h5wk6snzfWoll4&YG^gs8$^Zh&QUsJfC zE#Yv!H#MUbwKy`OlWG+SP=@FMm^=;@I@f zv%uilTJb$A$xt>sEq7uQZUuVL0s*sinE#44LDC7-pfOYO(V zAwh5$u_lF8%Sz;PCmW`e^!ykNV98&O>t=Vqyb&b(2d&soE=M6t0p;n$Dix$7Hg}$0 z{vQLF2X}9R$({E3QI^^r5(+f%)y`x5J zKsH2$avYVM+x$##%Zz`Gl|1Dr;w*!kriH4qbCRy-7bS_OP{V!2?Xh&}Fbj(PGoUy*|mLhBWbFfqa}aSAL@X6ZiM$`b+`NxB>F#q zA|Y4jT1GNt72?WOCsZ#y=;&83t_QHJF>HC|tw|rte!#N~$>F)!UPUoHQA3(pGfN2K z2tyPinr1a>xah0^L_^)7zJ#PHDM^PMp41q1w^%}KPK*>~|VbU$KT z#>V-*PV`t>~R}S5`NF=|FHGpP>szY_xKS|-Tl!dmV}H?G04D3IQ?w> ztJJQhVK7_dO%8R{fihJ{gQXG?t^-j2%Oy1pLBmf0ox#Ylb&ixsa!p_$Br<=oEoe9) zdvv22HBS~$h^`D&!?>)0zM1Dh_*n10plugins/sonar-design-plugin plugins/sonar-l10n-en-plugin plugins/sonar-email-notifications-plugin - plugins/sonar-jacoco-plugin @@ -634,6 +633,11 @@ sonar-cobertura-plugin ${sonarJava.version} + + org.codehaus.sonar-plugins.java + sonar-jacoco-plugin + ${sonarJava.version} + asm asm-all diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml index ac950cdabfd..fba2c585659 100644 --- a/sonar-application/pom.xml +++ b/sonar-application/pom.xml @@ -137,9 +137,8 @@ runtime - org.codehaus.sonar.plugins + org.codehaus.sonar-plugins.java sonar-jacoco-plugin - ${project.version} runtime diff --git a/sonar-server/pom.xml b/sonar-server/pom.xml index bf96e6d43df..a92abf15a10 100644 --- a/sonar-server/pom.xml +++ b/sonar-server/pom.xml @@ -475,9 +475,9 @@ provided - org.codehaus.sonar.plugins + org.codehaus.sonar-plugins.java sonar-jacoco-plugin - ${project.version} + ${sonarJava.version} sonar-plugin provided -- 2.39.5