@@ -20,36 +20,84 @@ | |||
package org.sonar.plugins.core; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.*; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.Properties; | |||
import org.sonar.api.Property; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.SonarPlugin; | |||
import org.sonar.api.checks.NoSonarFilter; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.batch.components.PastSnapshotFinder; | |||
import org.sonar.batch.debt.IssueChangelogDebtCalculator; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import org.sonar.core.timemachine.Periods; | |||
import org.sonar.plugins.core.batch.IndexProjectPostJob; | |||
import org.sonar.plugins.core.charts.DistributionAreaChart; | |||
import org.sonar.plugins.core.charts.DistributionBarChart; | |||
import org.sonar.plugins.core.charts.XradarChart; | |||
import org.sonar.plugins.core.colorizers.JavaColorizerFormat; | |||
import org.sonar.plugins.core.dashboards.*; | |||
import org.sonar.plugins.core.issue.*; | |||
import org.sonar.plugins.core.issue.notification.*; | |||
import org.sonar.plugins.core.dashboards.GlobalDefaultDashboard; | |||
import org.sonar.plugins.core.dashboards.ProjectDefaultDashboard; | |||
import org.sonar.plugins.core.dashboards.ProjectHotspotDashboard; | |||
import org.sonar.plugins.core.dashboards.ProjectIssuesDashboard; | |||
import org.sonar.plugins.core.dashboards.ProjectTimeMachineDashboard; | |||
import org.sonar.plugins.core.issue.CountFalsePositivesDecorator; | |||
import org.sonar.plugins.core.issue.CountUnresolvedIssuesDecorator; | |||
import org.sonar.plugins.core.issue.InitialOpenIssuesSensor; | |||
import org.sonar.plugins.core.issue.InitialOpenIssuesStack; | |||
import org.sonar.plugins.core.issue.IssueHandlers; | |||
import org.sonar.plugins.core.issue.IssueTracking; | |||
import org.sonar.plugins.core.issue.IssueTrackingDecorator; | |||
import org.sonar.plugins.core.issue.IssuesDensityDecorator; | |||
import org.sonar.plugins.core.issue.WeightedIssuesDecorator; | |||
import org.sonar.plugins.core.issue.notification.ChangesOnMyIssueNotificationDispatcher; | |||
import org.sonar.plugins.core.issue.notification.IssueChangesEmailTemplate; | |||
import org.sonar.plugins.core.issue.notification.NewFalsePositiveNotificationDispatcher; | |||
import org.sonar.plugins.core.issue.notification.NewIssuesEmailTemplate; | |||
import org.sonar.plugins.core.issue.notification.NewIssuesNotificationDispatcher; | |||
import org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob; | |||
import org.sonar.plugins.core.measurefilters.MyFavouritesFilter; | |||
import org.sonar.plugins.core.measurefilters.ProjectFilter; | |||
import org.sonar.plugins.core.notifications.alerts.NewAlerts; | |||
import org.sonar.plugins.core.security.ApplyProjectRolesDecorator; | |||
import org.sonar.plugins.core.sensors.*; | |||
import org.sonar.plugins.core.technicaldebt.DebtDecorator; | |||
import org.sonar.plugins.core.technicaldebt.NewDebtDecorator; | |||
import org.sonar.plugins.core.timemachine.*; | |||
import org.sonar.plugins.core.sensors.BranchCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.CommentDensityDecorator; | |||
import org.sonar.plugins.core.sensors.CoverageDecorator; | |||
import org.sonar.plugins.core.sensors.CoverageMeasurementFilter; | |||
import org.sonar.plugins.core.sensors.DirectoriesDecorator; | |||
import org.sonar.plugins.core.sensors.FileHashSensor; | |||
import org.sonar.plugins.core.sensors.FilesDecorator; | |||
import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.ItCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.ItLineCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.LineCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.ManualMeasureDecorator; | |||
import org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.OverallCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.OverallLineCoverageDecorator; | |||
import org.sonar.plugins.core.sensors.ProfileEventsSensor; | |||
import org.sonar.plugins.core.sensors.ProjectLinksSensor; | |||
import org.sonar.plugins.core.sensors.UnitTestDecorator; | |||
import org.sonar.plugins.core.sensors.VersionEventsSensor; | |||
import org.sonar.plugins.core.timemachine.NewCoverageAggregator; | |||
import org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer; | |||
import org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer; | |||
import org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer; | |||
import org.sonar.plugins.core.timemachine.TendencyDecorator; | |||
import org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister; | |||
import org.sonar.plugins.core.timemachine.VariationDecorator; | |||
import org.sonar.plugins.core.web.TestsViewer; | |||
import org.sonar.plugins.core.widgets.*; | |||
import org.sonar.plugins.core.widgets.issues.*; | |||
import org.sonar.plugins.core.widgets.measures.*; | |||
import org.sonar.plugins.core.widgets.issues.ActionPlansWidget; | |||
import org.sonar.plugins.core.widgets.issues.FalsePositiveIssuesWidget; | |||
import org.sonar.plugins.core.widgets.issues.IssueFilterWidget; | |||
import org.sonar.plugins.core.widgets.issues.IssuesWidget; | |||
import org.sonar.plugins.core.widgets.issues.MyUnresolvedIssuesWidget; | |||
import org.sonar.plugins.core.widgets.issues.UnresolvedIssuesPerAssigneeWidget; | |||
import org.sonar.plugins.core.widgets.issues.UnresolvedIssuesStatusesWidget; | |||
import org.sonar.plugins.core.widgets.measures.MeasureFilterAsBubbleChartWidget; | |||
import org.sonar.plugins.core.widgets.measures.MeasureFilterAsCloudWidget; | |||
import org.sonar.plugins.core.widgets.measures.MeasureFilterAsHistogramWidget; | |||
import org.sonar.plugins.core.widgets.measures.MeasureFilterAsPieChartWidget; | |||
import org.sonar.plugins.core.widgets.measures.MeasureFilterListWidget; | |||
import org.sonar.plugins.core.widgets.measures.MeasureFilterTreemapWidget; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
@Properties({ | |||
@@ -292,11 +340,6 @@ public final class CorePlugin extends SonarPlugin { | |||
NewFalsePositiveNotificationDispatcher.class, | |||
NewFalsePositiveNotificationDispatcher.newMetadata(), | |||
// technical debt | |||
DebtDecorator.class, | |||
NewDebtDecorator.class, | |||
IssueChangelogDebtCalculator.class, | |||
// batch | |||
ProfileEventsSensor.class, | |||
ProjectLinksSensor.class, | |||
@@ -334,64 +377,7 @@ public final class CorePlugin extends SonarPlugin { | |||
NewAlerts.class, | |||
NewAlerts.newMetadata()); | |||
extensions.addAll(ExclusionProperties.definitions()); | |||
extensions.addAll(IssueExclusionsConfiguration.getPropertyDefinitions()); | |||
extensions.addAll(CoverageMeasurementFilter.getPropertyDefinitions()); | |||
extensions.addAll(PastSnapshotFinder.getPropertyDefinitions()); | |||
extensions.addAll(DebtDecorator.definitions()); | |||
extensions.addAll(propertyDefinitions()); | |||
return extensions.build(); | |||
} | |||
static List<PropertyDefinition> propertyDefinitions() { | |||
return Arrays.asList( | |||
PropertyDefinition.builder(CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY) | |||
.defaultValue("en") | |||
.name("Locale used for issue messages") | |||
.description("Deprecated property. Keep default value for backward compatibility.") | |||
.hidden() | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY) | |||
.defaultValue("" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE) | |||
.name("Allow users to sign up online") | |||
.description("Users can sign up online.") | |||
.type(PropertyType.BOOLEAN) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_DEFAULT_GROUP) | |||
.defaultValue(CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE) | |||
.name("Default user group") | |||
.description("Any new users will automatically join this group.") | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_IMPORT_SOURCES_PROPERTY) | |||
.defaultValue("" + CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE) | |||
.name("Import sources") | |||
.description("Set to false if sources should not be imported and therefore not available in the Web UI (e.g. for security reasons).") | |||
.type(PropertyType.BOOLEAN) | |||
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY) | |||
.defaultValue("" + CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE) | |||
.name("Force user authentication") | |||
.description("Forcing user authentication stops un-logged users to access SonarQube.") | |||
.type(PropertyType.BOOLEAN) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_PREVENT_AUTOMATIC_PROJECT_CREATION) | |||
.defaultValue(Boolean.toString(false)) | |||
.name("Prevent automatic project creation") | |||
.description("Set to true to prevent automatic project creation at first analysis and force project provisioning.") | |||
.type(PropertyType.BOOLEAN) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build() | |||
); | |||
} | |||
} |
@@ -23,34 +23,26 @@ import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.ImmutableList.Builder; | |||
import com.google.common.collect.ImmutableSet; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.measures.Measure; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.api.utils.WildcardPattern; | |||
import org.sonar.core.measure.MeasurementFilter; | |||
import java.util.Collection; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
public class CoverageMeasurementFilter implements MeasurementFilter { | |||
public static final String PROPERTY_COVERAGE_EXCLUSIONS = "sonar.coverage.exclusions"; | |||
public static final String PROPERTY_COVERAGE_INCLUSIONS = "sonar.coverage.inclusions"; | |||
private final Settings settings; | |||
private final ImmutableSet<Metric> coverageMetrics; | |||
private Collection<WildcardPattern> resourcePatterns; | |||
public CoverageMeasurementFilter(Settings settings, | |||
CoverageDecorator coverageDecorator, | |||
LineCoverageDecorator lineCoverageDecorator, | |||
BranchCoverageDecorator branchCoverageDecorator) { | |||
CoverageDecorator coverageDecorator, | |||
LineCoverageDecorator lineCoverageDecorator, | |||
BranchCoverageDecorator branchCoverageDecorator) { | |||
this.settings = settings; | |||
this.coverageMetrics = ImmutableSet.<Metric>builder() | |||
.addAll(coverageDecorator.generatedMetrics()) | |||
@@ -88,22 +80,10 @@ public class CoverageMeasurementFilter implements MeasurementFilter { | |||
@VisibleForTesting | |||
final void initPatterns() { | |||
Builder<WildcardPattern> builder = ImmutableList.<WildcardPattern>builder(); | |||
for (String pattern : settings.getStringArray(PROPERTY_COVERAGE_EXCLUSIONS)) { | |||
Builder<WildcardPattern> builder = ImmutableList.builder(); | |||
for (String pattern : settings.getStringArray("sonar.coverage.exclusions")) { | |||
builder.add(WildcardPattern.create(pattern)); | |||
} | |||
resourcePatterns = builder.build(); | |||
} | |||
public static List<PropertyDefinition> getPropertyDefinitions() { | |||
return ImmutableList.of( | |||
PropertyDefinition.builder(PROPERTY_COVERAGE_EXCLUSIONS) | |||
.category(CoreProperties.CATEGORY_EXCLUSIONS) | |||
.subCategory(CoreProperties.SUBCATEGORY_COVERAGE_EXCLUSIONS) | |||
.type(PropertyType.STRING) | |||
.multiValues(true) | |||
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE) | |||
.build() | |||
); | |||
} | |||
} |
@@ -1,23 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.plugins.core.technicaldebt; | |||
import javax.annotation.ParametersAreNonnullByDefault; |
@@ -1,36 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.core; | |||
import org.junit.Test; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class ExclusionPropertiesTest { | |||
@Test | |||
public void definitions() throws Exception { | |||
assertThat(ExclusionProperties.definitions().size()).isGreaterThan(0); | |||
for (PropertyDefinition definition : ExclusionProperties.definitions()) { | |||
assertThat(definition.category()).isEqualTo(CoreProperties.CATEGORY_EXCLUSIONS); | |||
} | |||
} | |||
} |
@@ -27,6 +27,7 @@ import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.measures.Measure; | |||
import org.sonar.api.resources.File; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.core.config.ExclusionProperties; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
@@ -40,7 +41,7 @@ public class CoverageMeasurementFilterTest { | |||
@Before | |||
public void createFilter() { | |||
settings = new Settings(new PropertyDefinitions(CoverageMeasurementFilter.getPropertyDefinitions())); | |||
settings = new Settings(new PropertyDefinitions(ExclusionProperties.all())); | |||
filter = new CoverageMeasurementFilter(settings, new CoverageDecorator(), new LineCoverageDecorator(), new BranchCoverageDecorator()); | |||
} | |||
@@ -57,7 +58,7 @@ public class CoverageMeasurementFilterTest { | |||
Measure coverageMeasure = mock(Measure.class); | |||
when(coverageMeasure.getMetric()).thenReturn(CoreMetrics.LINES_TO_COVER); | |||
settings.setProperty(CoverageMeasurementFilter.PROPERTY_COVERAGE_EXCLUSIONS, "src/org/polop/*"); | |||
settings.setProperty("sonar.coverage.exclusions", "src/org/polop/*"); | |||
filter.initPatterns(); | |||
assertThat(filter.accept(resource, coverageMeasure)).isFalse(); | |||
} | |||
@@ -68,7 +69,7 @@ public class CoverageMeasurementFilterTest { | |||
Measure coverageMeasure = mock(Measure.class); | |||
when(coverageMeasure.getMetric()).thenReturn(CoreMetrics.COVERAGE); | |||
settings.setProperty(CoverageMeasurementFilter.PROPERTY_COVERAGE_EXCLUSIONS, "src/org/other/*"); | |||
settings.setProperty("sonar.coverage.exclusions", "src/org/other/*"); | |||
filter.initPatterns(); | |||
assertThat(filter.accept(resource, coverageMeasure)).isTrue(); | |||
} |
@@ -1,76 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar</artifactId> | |||
<version>4.3-SNAPSHOT</version> | |||
<relativePath>../..</relativePath> | |||
</parent> | |||
<groupId>org.codehaus.sonar.plugins</groupId> | |||
<artifactId>sonar-maven-batch-plugin</artifactId> | |||
<packaging>sonar-plugin</packaging> | |||
<name>SonarQube :: Maven Batch Plugin</name> | |||
<properties> | |||
<maven.version>3.0</maven.version> | |||
</properties> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.google.code.findbugs</groupId> | |||
<artifactId>jsr305</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-batch</artifactId> | |||
<version>${project.version}</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-plugin-api</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-plugin-api</artifactId> | |||
<version>${maven.version}</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-core</artifactId> | |||
<version>${maven.version}</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<!-- unit tests --> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-testing-harness</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-all</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-packaging-maven-plugin</artifactId> | |||
<configuration> | |||
<pluginName>Maven Batch Plugin</pluginName> | |||
<pluginClass>org.sonar.plugins.maven.MavenBatchPlugin</pluginClass> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -1,32 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.SonarPlugin; | |||
import java.util.List; | |||
public final class MavenBatchPlugin extends SonarPlugin { | |||
public List getExtensions() { | |||
return ImmutableList.of(MavenProjectBootstrapper.class, DefaultMavenPluginExecutor.class, MavenProjectConverter.class, MavenProjectBuilder.class); | |||
} | |||
} |
@@ -35,7 +35,6 @@ | |||
<module>plugins/sonar-cpd-plugin</module> | |||
<module>plugins/sonar-design-plugin</module> | |||
<module>plugins/sonar-email-notifications-plugin</module> | |||
<module>plugins/sonar-maven-batch-plugin</module> | |||
<module>plugins/sonar-xoo-plugin</module> | |||
</modules> | |||
@@ -18,8 +18,16 @@ | |||
<exclude>net.sourceforge.jtds:jtds</exclude> | |||
<exclude>org.codehaus.sonar.plugins:*</exclude> | |||
<exclude>org.codehaus.sonar-plugins.*:*</exclude> | |||
<exclude>org.codehaus.sonar:sonar-batch-maven-compat</exclude> | |||
</excludes> | |||
</dependencySet> | |||
<dependencySet> | |||
<outputDirectory>lib/batch</outputDirectory> | |||
<useTransitiveDependencies>false</useTransitiveDependencies> | |||
<includes> | |||
<include>org.codehaus.sonar:sonar-batch-maven-compat</include> | |||
</includes> | |||
</dependencySet> | |||
<!-- Plugins --> | |||
<dependencySet> | |||
<outputDirectory>lib/core-plugins</outputDirectory> |
@@ -57,6 +57,12 @@ | |||
<groupId>ch.qos.logback</groupId> | |||
<artifactId>logback-core</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>${pom.groupId}</groupId> | |||
<artifactId>sonar-batch-maven-compat</artifactId> | |||
<version>${pom.version}</version> | |||
<scope>runtime</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.tomcat.embed</groupId> | |||
<artifactId>tomcat-embed-core</artifactId> | |||
@@ -163,13 +169,6 @@ | |||
<type>sonar-plugin</type> | |||
<scope>runtime</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar.plugins</groupId> | |||
<artifactId>sonar-maven-batch-plugin</artifactId> | |||
<version>${project.version}</version> | |||
<type>sonar-plugin</type> | |||
<scope>runtime</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.sonatype.jsw-binaries</groupId> | |||
<artifactId>jsw-binaries</artifactId> | |||
@@ -258,8 +257,8 @@ | |||
<configuration> | |||
<rules> | |||
<requireFilesSize> | |||
<minsize>55000000</minsize> | |||
<maxsize>75000000</maxsize> | |||
<minsize>80000000</minsize> | |||
<maxsize>88000000</maxsize> | |||
<files> | |||
<file>${project.build.directory}/sonarqube-${project.version}.zip</file> | |||
</files> |
@@ -13,11 +13,15 @@ | |||
<description>Compatibility layer, which provides MavenProject for non-Maven environments.</description> | |||
<dependencies> | |||
<dependency> | |||
<groupId>${pom.groupId}</groupId> | |||
<artifactId>sonar-batch</artifactId> | |||
<version>${pom.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-project</artifactId> | |||
<version>2.0.7</version> | |||
<scope>compile</scope> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>org.codehaus.plexus</groupId> | |||
@@ -43,20 +47,4 @@ | |||
</plugin> | |||
</plugins> | |||
</build> | |||
<profiles> | |||
<profile> | |||
<id>release</id> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<artifactId>maven-deploy-plugin</artifactId> | |||
<configuration> | |||
<skip>true</skip> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</profile> | |||
</profiles> | |||
</project> |
@@ -7,7 +7,6 @@ | |||
<version>4.3-SNAPSHOT</version> | |||
</parent> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-batch</artifactId> | |||
<name>SonarQube :: Batch</name> | |||
@@ -40,6 +39,16 @@ | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-plugin-api</artifactId> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>jfree</groupId> | |||
<artifactId>jcommon</artifactId> | |||
</exclusion> | |||
<exclusion> | |||
<groupId>jfree</groupId> | |||
<artifactId>jfreechat</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
@@ -52,11 +61,13 @@ | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-plugin-api</artifactId> | |||
<version>3.0</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-core</artifactId> | |||
<version>3.0</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> |
@@ -0,0 +1,47 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.bootstrap; | |||
import com.google.common.collect.Lists; | |||
import org.sonar.batch.debt.DebtDecorator; | |||
import org.sonar.batch.debt.IssueChangelogDebtCalculator; | |||
import org.sonar.batch.debt.NewDebtDecorator; | |||
import org.sonar.batch.maven.DefaultMavenPluginExecutor; | |||
import org.sonar.batch.maven.MavenProjectBootstrapper; | |||
import org.sonar.batch.maven.MavenProjectBuilder; | |||
import org.sonar.batch.maven.MavenProjectConverter; | |||
import org.sonar.core.config.CorePropertyDefinitions; | |||
import java.util.Collection; | |||
import java.util.List; | |||
public class BatchComponents { | |||
public static Collection all() { | |||
List components = Lists.newArrayList( | |||
// Maven | |||
MavenProjectBootstrapper.class, DefaultMavenPluginExecutor.class, MavenProjectConverter.class, MavenProjectBuilder.class, | |||
// Debt | |||
IssueChangelogDebtCalculator.class, DebtDecorator.class, NewDebtDecorator.class | |||
); | |||
components.addAll(CorePropertyDefinitions.all()); | |||
return components; | |||
} | |||
} |
@@ -44,6 +44,13 @@ public class ExtensionInstaller { | |||
public ExtensionInstaller install(ComponentContainer container, ExtensionMatcher matcher) { | |||
boolean preview = analysisMode.isPreview(); | |||
// core components | |||
for (Object o : BatchComponents.all()) { | |||
doInstall(container, matcher, null, preview, o); | |||
} | |||
// plugin extensions | |||
for (Map.Entry<PluginMetadata, Plugin> entry : pluginRepository.getPluginsByMetadata().entrySet()) { | |||
PluginMetadata metadata = entry.getKey(); | |||
Plugin plugin = entry.getValue(); |
@@ -24,6 +24,7 @@ import org.sonar.api.config.Settings; | |||
import org.sonar.api.platform.ComponentContainer; | |||
import org.sonar.api.resources.ResourceTypes; | |||
import org.sonar.api.task.Task; | |||
import org.sonar.api.task.TaskComponent; | |||
import org.sonar.api.task.TaskDefinition; | |||
import org.sonar.api.task.TaskExtension; | |||
import org.sonar.api.utils.SonarException; | |||
@@ -55,7 +56,7 @@ public class TaskContainer extends ComponentContainer { | |||
private void installTaskExtensions() { | |||
getComponentByType(ExtensionInstaller.class).install(this, new ExtensionMatcher() { | |||
public boolean accept(Object extension) { | |||
return ExtensionUtils.isType(extension, TaskExtension.class); | |||
return ExtensionUtils.isType(extension, TaskComponent.class); | |||
} | |||
}); | |||
} |
@@ -20,24 +20,19 @@ | |||
package org.sonar.batch.components; | |||
import com.google.common.base.Strings; | |||
import com.google.common.collect.ImmutableList; | |||
import org.apache.commons.configuration.Configuration; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.BatchExtension; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.database.model.Snapshot; | |||
import org.sonar.api.resources.Qualifiers; | |||
import javax.annotation.Nullable; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
public class PastSnapshotFinder implements BatchExtension { | |||
@@ -196,60 +191,4 @@ public class PastSnapshotFinder implements BatchExtension { | |||
} | |||
} | |||
public static List<PropertyDefinition> getPropertyDefinitions() { | |||
return ImmutableList.of( | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 1) | |||
.name("Period 1") | |||
.description("Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " + | |||
"analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " + | |||
"compare to previous analysis</li><li>'previous_version' to compare to the previous version in the project history</li></ul>" + | |||
"<p>When specifying a number of days or a date, the snapshot selected for comparison is " + | |||
" the first one available inside the corresponding time range. </p>" + | |||
"<p>Changing this property only takes effect after subsequent project inspections.<p/>") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 2) | |||
.name("Period 2") | |||
.description("See the property 'Period 1'") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 3) | |||
.name("Period 3") | |||
.description("See the property 'Period 1'") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 4) | |||
.name("Period 4") | |||
.description("Period used to compare measures and track new violations. This property is specific to the project. Values are : " + | |||
"<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " + | |||
"for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li>" + | |||
"<li>'previous_version' to compare to the previous version in the project history</li><li>A version, for example 1.2</li></ul>" + | |||
"<p>When specifying a number of days or a date, the snapshot selected for comparison is the first one available inside the corresponding time range. </p>" + | |||
"<p>Changing this property only takes effect after subsequent project inspections.<p/>") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4) | |||
.onlyOnQualifiers(Qualifiers.PROJECT) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 5) | |||
.name("Period 5") | |||
.description("See the property 'Period 4'") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5) | |||
.onlyOnQualifiers(Qualifiers.PROJECT) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build() | |||
); | |||
} | |||
} |
@@ -18,21 +18,26 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.core.technicaldebt; | |||
package org.sonar.batch.debt; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.batch.*; | |||
import org.sonar.api.batch.Decorator; | |||
import org.sonar.api.batch.DecoratorBarriers; | |||
import org.sonar.api.batch.DecoratorContext; | |||
import org.sonar.api.batch.DependedUpon; | |||
import org.sonar.api.batch.DependsUpon; | |||
import org.sonar.api.batch.rule.Rule; | |||
import org.sonar.api.batch.rule.Rules; | |||
import org.sonar.api.component.ResourcePerspectives; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.issue.Issuable; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.internal.DefaultIssue; | |||
import org.sonar.api.measures.*; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.measures.Measure; | |||
import org.sonar.api.measures.MeasuresFilters; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.measures.PersistenceMode; | |||
import org.sonar.api.measures.RuleMeasure; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.api.resources.ResourceUtils; | |||
@@ -43,7 +48,6 @@ import org.sonar.api.technicaldebt.batch.TechnicalDebtModel; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -185,18 +189,6 @@ public final class DebtDecorator implements Decorator { | |||
return context.getMeasure(CoreMetrics.TECHNICAL_DEBT) == null; | |||
} | |||
public static List<PropertyDefinition> definitions() { | |||
return ImmutableList.of( | |||
PropertyDefinition.builder(CoreProperties.HOURS_IN_DAY) | |||
.name("Number of working hours in a day") | |||
.type(PropertyType.INTEGER) | |||
.defaultValue("8") | |||
.category(CoreProperties.CATEGORY_TECHNICAL_DEBT) | |||
.deprecatedKey("sqale.hoursInDay") | |||
.build() | |||
); | |||
} | |||
private static class SumMap<E> { | |||
private Map<E, Long> sumByKeys; | |||
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.core.technicaldebt; | |||
package org.sonar.batch.debt; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.batch.*; |
@@ -19,8 +19,6 @@ | |||
*/ | |||
package org.sonar.batch.issue.ignore.pattern; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.StringUtils; | |||
@@ -67,8 +65,8 @@ public abstract class AbstractPatternInitializer implements BatchExtension { | |||
String patternConf = StringUtils.defaultIfBlank(settings.getString(getMulticriteriaConfigurationKey()), ""); | |||
for (String id : StringUtils.split(patternConf, ',')) { | |||
String propPrefix = getMulticriteriaConfigurationKey() + "." + id + "."; | |||
String resourceKeyPattern = settings.getString(propPrefix + IssueExclusionsConfiguration.RESOURCE_KEY); | |||
String ruleKeyPattern = settings.getString(propPrefix + IssueExclusionsConfiguration.RULE_KEY); | |||
String resourceKeyPattern = settings.getString(propPrefix + "resourceKey"); | |||
String ruleKeyPattern = settings.getString(propPrefix + "ruleKey"); | |||
String lineRange = "*"; | |||
String[] fields = new String[] { resourceKeyPattern, ruleKeyPattern, lineRange }; | |||
PatternDecoder.checkRegularLineConstraints(StringUtils.join(fields, ","), fields); |
@@ -20,12 +20,11 @@ | |||
package org.sonar.batch.issue.ignore.pattern; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.core.config.IssueExclusionProperties; | |||
import java.util.List; | |||
@@ -45,7 +44,7 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
@Override | |||
protected String getMulticriteriaConfigurationKey() { | |||
return IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY; | |||
return "sonar.issue.ignore" + ".multicriteria"; | |||
} | |||
public PatternMatcher getPatternMatcher() { | |||
@@ -54,7 +53,7 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
@Override | |||
public void initializePatternsForPath(String relativePath, String componentKey) { | |||
for (IssuePattern pattern: getMulticriteriaPatterns()) { | |||
for (IssuePattern pattern : getMulticriteriaPatterns()) { | |||
if (pattern.matchResource(relativePath)) { | |||
getPatternMatcher().addPatternForComponent(componentKey, pattern); | |||
} | |||
@@ -70,12 +69,12 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
protected final void loadFileContentPatterns() { | |||
// Patterns Block | |||
blockPatterns = Lists.newArrayList(); | |||
String patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY), ""); | |||
String patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionProperties.PATTERNS_BLOCK_KEY), ""); | |||
for (String id : StringUtils.split(patternConf, ',')) { | |||
String propPrefix = IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + "." + id + "."; | |||
String beginBlockRegexp = getSettings().getString(propPrefix + IssueExclusionsConfiguration.BEGIN_BLOCK_REGEXP); | |||
String endBlockRegexp = getSettings().getString(propPrefix + IssueExclusionsConfiguration.END_BLOCK_REGEXP); | |||
String[] fields = new String[] { beginBlockRegexp, endBlockRegexp }; | |||
String propPrefix = IssueExclusionProperties.PATTERNS_BLOCK_KEY + "." + id + "."; | |||
String beginBlockRegexp = getSettings().getString(propPrefix + IssueExclusionProperties.BEGIN_BLOCK_REGEXP); | |||
String endBlockRegexp = getSettings().getString(propPrefix + IssueExclusionProperties.END_BLOCK_REGEXP); | |||
String[] fields = new String[]{beginBlockRegexp, endBlockRegexp}; | |||
PatternDecoder.checkDoubleRegexpLineConstraints(StringUtils.join(fields, ","), fields); | |||
IssuePattern pattern = new IssuePattern().setBeginBlockRegexp(nullToEmpty(beginBlockRegexp)).setEndBlockRegexp(nullToEmpty(endBlockRegexp)); | |||
blockPatterns.add(pattern); | |||
@@ -83,10 +82,10 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
// Patterns All File | |||
allFilePatterns = Lists.newArrayList(); | |||
patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY), ""); | |||
patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionProperties.PATTERNS_ALLFILE_KEY), ""); | |||
for (String id : StringUtils.split(patternConf, ',')) { | |||
String propPrefix = IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY + "." + id + "."; | |||
String allFileRegexp = getSettings().getString(propPrefix + IssueExclusionsConfiguration.FILE_REGEXP); | |||
String propPrefix = IssueExclusionProperties.PATTERNS_ALLFILE_KEY + "." + id + "."; | |||
String allFileRegexp = getSettings().getString(propPrefix + IssueExclusionProperties.FILE_REGEXP); | |||
PatternDecoder.checkWholeFileRegexp(allFileRegexp); | |||
IssuePattern pattern = new IssuePattern().setAllFileRegexp(nullToEmpty(allFileRegexp)); | |||
allFilePatterns.add(pattern); | |||
@@ -102,6 +101,6 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
} | |||
public boolean hasFileContentPattern() { | |||
return ! (blockPatterns.isEmpty() && allFilePatterns.isEmpty()); | |||
return !(blockPatterns.isEmpty() && allFilePatterns.isEmpty()); | |||
} | |||
} |
@@ -20,8 +20,6 @@ | |||
package org.sonar.batch.issue.ignore.pattern; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import com.google.common.collect.Maps; | |||
import org.sonar.api.config.Settings; | |||
@@ -38,7 +36,7 @@ public class IssueInclusionPatternInitializer extends AbstractPatternInitializer | |||
@Override | |||
protected String getMulticriteriaConfigurationKey() { | |||
return IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_INCLUSION_KEY; | |||
return "sonar.issue.enforce" + ".multicriteria"; | |||
} | |||
@Override |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.maven.execution.MavenSession; | |||
import org.apache.maven.execution.ReactorManager; | |||
@@ -33,7 +33,6 @@ import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; | |||
import org.sonar.batch.scan.maven.MavenPluginExecutor; | |||
import javax.annotation.Nullable; | |||
import java.lang.reflect.Method; | |||
import java.util.Arrays; | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.maven.execution.MavenSession; | |||
import org.apache.maven.project.MavenProject; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.maven.execution.MavenSession; | |||
import org.apache.maven.project.MavenProject; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.base.Function; | |||
@@ -40,7 +40,6 @@ import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; | |||
import org.sonar.java.api.JavaUtils; | |||
import javax.annotation.Nullable; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Arrays; |
@@ -22,7 +22,7 @@ | |||
* This package is a part of bootstrap process, so we should take care about backward compatibility. | |||
*/ | |||
@ParametersAreNonnullByDefault | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import javax.annotation.ParametersAreNonnullByDefault; | |||
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.batch.scan; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.batch.qualitygate.GenerateQualityGateEvents; | |||
import org.slf4j.Logger; | |||
@@ -158,7 +159,7 @@ public class ModuleScanContainer extends ComponentContainer { | |||
ExtensionInstaller installer = getComponentByType(ExtensionInstaller.class); | |||
installer.install(this, new ExtensionMatcher() { | |||
public boolean accept(Object extension) { | |||
if (ExtensionUtils.isType(extension, BatchExtension.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT)) { | |||
if (ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT)) { | |||
// Special use-case: the extension point ProjectBuilder is used in a Maven environment to define some | |||
// new sub-projects without pom. | |||
// Example : C# plugin adds sub-projects at runtime, even if they are not defined in root pom. |
@@ -20,6 +20,7 @@ | |||
package org.sonar.batch.scan; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import org.sonar.api.BatchComponent; | |||
import org.sonar.api.BatchExtension; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.InstantiationStrategy; | |||
@@ -201,7 +202,7 @@ public class ProjectScanContainer extends ComponentContainer { | |||
static class BatchExtensionFilter implements ExtensionMatcher { | |||
public boolean accept(Object extension) { | |||
return ExtensionUtils.isType(extension, BatchExtension.class) | |||
return ExtensionUtils.isType(extension, BatchComponent.class) | |||
&& ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_BATCH); | |||
} | |||
} |
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.core.technicaldebt; | |||
package org.sonar.batch.debt; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.ObjectUtils; | |||
@@ -38,7 +38,11 @@ import org.sonar.api.component.ResourcePerspectives; | |||
import org.sonar.api.issue.Issuable; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.internal.DefaultIssue; | |||
import org.sonar.api.measures.*; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.measures.Measure; | |||
import org.sonar.api.measures.MeasuresFilter; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.measures.RuleMeasure; | |||
import org.sonar.api.resources.File; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.resources.Resource; | |||
@@ -55,7 +59,12 @@ import java.util.Collections; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Mockito.*; | |||
import static org.mockito.Mockito.argThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.never; | |||
import static org.mockito.Mockito.times; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.when; | |||
@RunWith(MockitoJUnitRunner.class) | |||
public class DebtDecoratorTest { | |||
@@ -275,15 +284,10 @@ public class DebtDecoratorTest { | |||
DecoratorContext context = mock(DecoratorContext.class); | |||
when(context.getResource()).thenReturn(new File("foo")); | |||
decorator.saveCharacteristicMeasure(context, (Characteristic) null, 0.0, true); | |||
decorator.saveCharacteristicMeasure(context, null, 0.0, true); | |||
verify(context, never()).saveMeasure(new Measure(CoreMetrics.TECHNICAL_DEBT)); | |||
} | |||
@Test | |||
public void check_definitions() { | |||
assertThat(DebtDecorator.definitions()).hasSize(1); | |||
} | |||
private DefaultIssue createIssue(String ruleKey, String repositoryKey) { | |||
return new DefaultIssue().setRuleKey(RuleKey.of(repositoryKey, ruleKey)); | |||
} |
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.core.technicaldebt; | |||
package org.sonar.batch.debt; | |||
import org.apache.commons.lang.ObjectUtils; | |||
import org.apache.commons.lang.time.DateUtils; | |||
@@ -45,6 +45,7 @@ import org.sonar.api.utils.Duration; | |||
import org.sonar.batch.components.Period; | |||
import org.sonar.batch.components.TimeMachineConfiguration; | |||
import org.sonar.batch.debt.IssueChangelogDebtCalculator; | |||
import org.sonar.batch.debt.NewDebtDecorator; | |||
import java.util.Date; | |||
@@ -1,33 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.issue.ignore; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import org.junit.Test; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class IssueExclusionsConfigurationTest { | |||
@Test | |||
public void justForCoverage() { | |||
assertThat(IssueExclusionsConfiguration.getPropertyDefinitions()).hasSize(4); | |||
} | |||
} |
@@ -20,14 +20,14 @@ | |||
package org.sonar.batch.issue.ignore.pattern; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.core.config.IssueExclusionProperties; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class IssueExclusionPatternInitializerTest { | |||
@@ -38,7 +38,7 @@ public class IssueExclusionPatternInitializerTest { | |||
@Before | |||
public void init() { | |||
settings = new Settings(new PropertyDefinitions(IssueExclusionsConfiguration.getPropertyDefinitions())); | |||
settings = new Settings(new PropertyDefinitions(IssueExclusionProperties.all())); | |||
patternsInitializer = new IssueExclusionPatternInitializer(settings); | |||
} | |||
@@ -51,11 +51,11 @@ public class IssueExclusionPatternInitializerTest { | |||
@Test | |||
public void shouldHavePatternsBasedOnMulticriteriaPattern() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY, "1,2"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RESOURCE_KEY, "org/foo/Bar.java"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RULE_KEY, "*"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".2." + IssueExclusionsConfiguration.RESOURCE_KEY, "org/foo/Hello.java"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".2." + IssueExclusionsConfiguration.RULE_KEY, "checkstyle:MagicNumber"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria", "1,2"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "resourceKey", "org/foo/Bar.java"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "ruleKey", "*"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".2." + "resourceKey", "org/foo/Hello.java"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".2." + "ruleKey", "checkstyle:MagicNumber"); | |||
patternsInitializer.initPatterns(); | |||
assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue(); | |||
@@ -77,29 +77,29 @@ public class IssueExclusionPatternInitializerTest { | |||
@Test(expected = SonarException.class) | |||
public void shouldLogInvalidResourceKey() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY, "1"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RESOURCE_KEY, ""); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RULE_KEY, "*"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria", "1"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "resourceKey", ""); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "ruleKey", "*"); | |||
patternsInitializer.initPatterns(); | |||
} | |||
@Test(expected = SonarException.class) | |||
public void shouldLogInvalidRuleKey() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY, "1"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RESOURCE_KEY, "*"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_EXCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RULE_KEY, ""); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria", "1"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "resourceKey", "*"); | |||
settings.setProperty("sonar.issue.ignore" + ".multicriteria" + ".1." + "ruleKey", ""); | |||
patternsInitializer.initPatterns(); | |||
} | |||
@Test | |||
public void shouldReturnBlockPattern() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY, "1,2,3"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionsConfiguration.BEGIN_BLOCK_REGEXP, "// SONAR-OFF"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionsConfiguration.END_BLOCK_REGEXP, "// SONAR-ON"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".2." + IssueExclusionsConfiguration.BEGIN_BLOCK_REGEXP, "// FOO-OFF"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".2." + IssueExclusionsConfiguration.END_BLOCK_REGEXP, "// FOO-ON"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".3." + IssueExclusionsConfiguration.BEGIN_BLOCK_REGEXP, "// IGNORE-TO-EOF"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".3." + IssueExclusionsConfiguration.END_BLOCK_REGEXP, ""); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY, "1,2,3"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionProperties.BEGIN_BLOCK_REGEXP, "// SONAR-OFF"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionProperties.END_BLOCK_REGEXP, "// SONAR-ON"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".2." + IssueExclusionProperties.BEGIN_BLOCK_REGEXP, "// FOO-OFF"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".2." + IssueExclusionProperties.END_BLOCK_REGEXP, "// FOO-ON"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".3." + IssueExclusionProperties.BEGIN_BLOCK_REGEXP, "// IGNORE-TO-EOF"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".3." + IssueExclusionProperties.END_BLOCK_REGEXP, ""); | |||
patternsInitializer.loadFileContentPatterns(); | |||
assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue(); | |||
@@ -112,17 +112,17 @@ public class IssueExclusionPatternInitializerTest { | |||
@Test(expected = SonarException.class) | |||
public void shouldLogInvalidStartBlockPattern() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY, "1"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionsConfiguration.BEGIN_BLOCK_REGEXP, ""); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionsConfiguration.END_BLOCK_REGEXP, "// SONAR-ON"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY, "1"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionProperties.BEGIN_BLOCK_REGEXP, ""); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_BLOCK_KEY + ".1." + IssueExclusionProperties.END_BLOCK_REGEXP, "// SONAR-ON"); | |||
patternsInitializer.loadFileContentPatterns(); | |||
} | |||
@Test | |||
public void shouldReturnAllFilePattern() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY, "1,2"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY + ".1." + IssueExclusionsConfiguration.FILE_REGEXP, "@SONAR-IGNORE-ALL"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY + ".2." + IssueExclusionsConfiguration.FILE_REGEXP, "//FOO-IGNORE-ALL"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY, "1,2"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY + ".1." + IssueExclusionProperties.FILE_REGEXP, "@SONAR-IGNORE-ALL"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY + ".2." + IssueExclusionProperties.FILE_REGEXP, "//FOO-IGNORE-ALL"); | |||
patternsInitializer.loadFileContentPatterns(); | |||
assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue(); | |||
@@ -135,8 +135,8 @@ public class IssueExclusionPatternInitializerTest { | |||
@Test(expected = SonarException.class) | |||
public void shouldLogInvalidAllFilePattern() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY, "1"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_ALLFILE_KEY + ".1." + IssueExclusionsConfiguration.FILE_REGEXP, ""); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY, "1"); | |||
settings.setProperty(IssueExclusionProperties.PATTERNS_ALLFILE_KEY + ".1." + IssueExclusionProperties.FILE_REGEXP, ""); | |||
patternsInitializer.loadFileContentPatterns(); | |||
} | |||
} |
@@ -20,13 +20,12 @@ | |||
package org.sonar.batch.issue.ignore.pattern; | |||
import org.sonar.batch.issue.ignore.IssueExclusionsConfiguration; | |||
import org.sonar.batch.issue.ignore.pattern.IssueInclusionPatternInitializer; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.core.config.IssueExclusionProperties; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class IssueInclusionPatternInitializerTest { | |||
@@ -37,7 +36,7 @@ public class IssueInclusionPatternInitializerTest { | |||
@Before | |||
public void init() { | |||
settings = new Settings(new PropertyDefinitions(IssueExclusionsConfiguration.getPropertyDefinitions())); | |||
settings = new Settings(new PropertyDefinitions(IssueExclusionProperties.all())); | |||
patternsInitializer = new IssueInclusionPatternInitializer(settings); | |||
} | |||
@@ -49,11 +48,11 @@ public class IssueInclusionPatternInitializerTest { | |||
@Test | |||
public void shouldHavePatternsBasedOnMulticriteriaPattern() { | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_INCLUSION_KEY, "1,2"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_INCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RESOURCE_KEY, "org/foo/Bar.java"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_INCLUSION_KEY + ".1." + IssueExclusionsConfiguration.RULE_KEY, "*"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_INCLUSION_KEY + ".2." + IssueExclusionsConfiguration.RESOURCE_KEY, "org/foo/Hello.java"); | |||
settings.setProperty(IssueExclusionsConfiguration.PATTERNS_MULTICRITERIA_INCLUSION_KEY + ".2." + IssueExclusionsConfiguration.RULE_KEY, "checkstyle:MagicNumber"); | |||
settings.setProperty("sonar.issue.enforce" + ".multicriteria", "1,2"); | |||
settings.setProperty("sonar.issue.enforce" + ".multicriteria" + ".1." + "resourceKey", "org/foo/Bar.java"); | |||
settings.setProperty("sonar.issue.enforce" + ".multicriteria" + ".1." + "ruleKey", "*"); | |||
settings.setProperty("sonar.issue.enforce" + ".multicriteria" + ".2." + "resourceKey", "org/foo/Hello.java"); | |||
settings.setProperty("sonar.issue.enforce" + ".multicriteria" + ".2." + "ruleKey", "checkstyle:MagicNumber"); | |||
patternsInitializer.initPatterns(); | |||
assertThat(patternsInitializer.hasConfiguredPatterns()).isTrue(); |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.maven.project.MavenProject; | |||
import org.junit.Test; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.maven.execution.MavenSession; | |||
import org.apache.maven.project.MavenProject; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.maven.model.Model; | |||
@@ -119,10 +119,10 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void moduleNameShouldEqualArtifactId() throws Exception { | |||
File rootDir = TestUtils.getResource("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/"); | |||
MavenProject parent = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/pom.xml", true); | |||
MavenProject module1 = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/module1/pom.xml", false); | |||
MavenProject module2 = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/module2/pom.xml", false); | |||
File rootDir = TestUtils.getResource("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/"); | |||
MavenProject parent = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/pom.xml", true); | |||
MavenProject module1 = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/module1/pom.xml", false); | |||
MavenProject module2 = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameShouldEqualArtifactId/module2/pom.xml", false); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(parent, module1, module2), parent); | |||
@@ -140,10 +140,10 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void moduleNameDifferentThanArtifactId() throws Exception { | |||
File rootDir = TestUtils.getResource("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/"); | |||
MavenProject parent = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/pom.xml", true); | |||
MavenProject module1 = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/path1/pom.xml", false); | |||
MavenProject module2 = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/path2/pom.xml", false); | |||
File rootDir = TestUtils.getResource("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/"); | |||
MavenProject parent = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/pom.xml", true); | |||
MavenProject module1 = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/path1/pom.xml", false); | |||
MavenProject module2 = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/moduleNameDifferentThanArtifactId/path2/pom.xml", false); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(parent, module1, module2), parent); | |||
@@ -161,9 +161,9 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void should_find_module_with_maven_project_file_naming_different_from_pom_xml() throws Exception { | |||
File rootDir = TestUtils.getResource("/org/sonar/plugins/maven/MavenProjectConverterTest/mavenProjectFileNameNotEqualsToPomXml/"); | |||
MavenProject parent = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/mavenProjectFileNameNotEqualsToPomXml/pom.xml", true); | |||
MavenProject module = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/mavenProjectFileNameNotEqualsToPomXml/module/pom_having_different_name.xml", false); | |||
File rootDir = TestUtils.getResource("/org/sonar/batch/maven/MavenProjectConverterTest/mavenProjectFileNameNotEqualsToPomXml/"); | |||
MavenProject parent = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/mavenProjectFileNameNotEqualsToPomXml/pom.xml", true); | |||
MavenProject module = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/mavenProjectFileNameNotEqualsToPomXml/module/pom_having_different_name.xml", false); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(parent, module), parent); | |||
@@ -181,8 +181,8 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void testSingleProjectWithoutModules() throws Exception { | |||
File rootDir = TestUtils.getResource("/org/sonar/plugins/maven/MavenProjectConverterTest/singleProjectWithoutModules/"); | |||
MavenProject pom = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/singleProjectWithoutModules/pom.xml", true); | |||
File rootDir = TestUtils.getResource("/org/sonar/batch/maven/MavenProjectConverterTest/singleProjectWithoutModules/"); | |||
MavenProject pom = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/singleProjectWithoutModules/pom.xml", true); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(pom), pom); | |||
@@ -194,7 +194,7 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void shouldConvertLinksToProperties() throws Exception { | |||
MavenProject pom = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/projectWithLinks/pom.xml", true); | |||
MavenProject pom = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/projectWithLinks/pom.xml", true); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(pom), pom); | |||
@@ -208,7 +208,7 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void shouldNotConvertLinksToPropertiesIfPropertyAlreadyDefined() throws Exception { | |||
MavenProject pom = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/projectWithLinksAndProperties/pom.xml", true); | |||
MavenProject pom = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/projectWithLinksAndProperties/pom.xml", true); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(pom), pom); | |||
@@ -226,7 +226,7 @@ public class MavenProjectConverterTest { | |||
@Test | |||
public void shouldLoadSourceEncoding() throws Exception { | |||
MavenProject pom = loadPom("/org/sonar/plugins/maven/MavenProjectConverterTest/sourceEncoding/pom.xml", true); | |||
MavenProject pom = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/sourceEncoding/pom.xml", true); | |||
ProjectDefinition rootDef = converter.configure(Arrays.asList(pom), pom); | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.batch.maven; | |||
import org.apache.maven.execution.MavenSession; | |||
import org.apache.maven.project.MavenProject; |
@@ -0,0 +1,117 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.core.config; | |||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.Lists; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.resources.Qualifiers; | |||
import java.util.List; | |||
public class CorePropertyDefinitions { | |||
private CorePropertyDefinitions() { | |||
// only static stuff | |||
} | |||
public static List<PropertyDefinition> all() { | |||
List<PropertyDefinition> defs = Lists.newArrayList(); | |||
defs.addAll(IssueExclusionProperties.all()); | |||
defs.addAll(ExclusionProperties.all()); | |||
defs.addAll(SecurityProperties.all()); | |||
defs.addAll(ImmutableList.of( | |||
// DEBT | |||
PropertyDefinition.builder(CoreProperties.HOURS_IN_DAY) | |||
.name("Number of working hours in a day") | |||
.type(PropertyType.INTEGER) | |||
.defaultValue("8") | |||
.category(CoreProperties.CATEGORY_TECHNICAL_DEBT) | |||
.deprecatedKey("sqale.hoursInDay") | |||
.build(), | |||
// BATCH | |||
PropertyDefinition.builder(CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY) | |||
.defaultValue("en") | |||
.name("Locale used for issue messages") | |||
.description("Deprecated property. Keep default value for backward compatibility.") | |||
.hidden() | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 1) | |||
.name("Period 1") | |||
.description("Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " + | |||
"analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " + | |||
"compare to previous analysis</li><li>'previous_version' to compare to the previous version in the project history</li></ul>" + | |||
"<p>When specifying a number of days or a date, the snapshot selected for comparison is " + | |||
" the first one available inside the corresponding time range. </p>" + | |||
"<p>Changing this property only takes effect after subsequent project inspections.<p/>") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 2) | |||
.name("Period 2") | |||
.description("See the property 'Period 1'") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 3) | |||
.name("Period 3") | |||
.description("See the property 'Period 1'") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 4) | |||
.name("Period 4") | |||
.description("Period used to compare measures and track new violations. This property is specific to the project. Values are : " + | |||
"<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " + | |||
"for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li>" + | |||
"<li>'previous_version' to compare to the previous version in the project history</li><li>A version, for example 1.2</li></ul>" + | |||
"<p>When specifying a number of days or a date, the snapshot selected for comparison is the first one available inside the corresponding time range. </p>" + | |||
"<p>Changing this property only takes effect after subsequent project inspections.<p/>") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4) | |||
.onlyOnQualifiers(Qualifiers.PROJECT) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 5) | |||
.name("Period 5") | |||
.description("See the property 'Period 4'") | |||
.defaultValue(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5) | |||
.onlyOnQualifiers(Qualifiers.PROJECT) | |||
.category(CoreProperties.CATEGORY_GENERAL) | |||
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS) | |||
.build() | |||
)); | |||
return defs; | |||
} | |||
} |
@@ -17,23 +17,35 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.core; | |||
package org.sonar.core.config; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.resources.Qualifiers; | |||
import java.util.List; | |||
class ExclusionProperties { | |||
public class ExclusionProperties { | |||
private ExclusionProperties() { | |||
// only static stuff | |||
} | |||
static List<PropertyDefinition> definitions() { | |||
public static List<PropertyDefinition> all() { | |||
return ImmutableList.of( | |||
// COVERAGE | |||
PropertyDefinition.builder("sonar.coverage.exclusions") | |||
.category(CoreProperties.CATEGORY_EXCLUSIONS) | |||
.subCategory(CoreProperties.SUBCATEGORY_COVERAGE_EXCLUSIONS) | |||
.type(PropertyType.STRING) | |||
.multiValues(true) | |||
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE) | |||
.build(), | |||
// FILES | |||
PropertyDefinition.builder(CoreProperties.PROJECT_INCLUSIONS_PROPERTY) | |||
.name("Source File Inclusions") | |||
.multiValues(true) | |||
@@ -97,6 +109,7 @@ class ExclusionProperties { | |||
.subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS) | |||
.onlyOnQualifiers(Qualifiers.PROJECT) | |||
.index(1) | |||
.build()); | |||
.build() | |||
); | |||
} | |||
} |
@@ -17,8 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.issue.ignore; | |||
package org.sonar.core.config; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.CoreProperties; | |||
@@ -29,7 +28,7 @@ import org.sonar.api.resources.Qualifiers; | |||
import java.util.List; | |||
public final class IssueExclusionsConfiguration { | |||
public final class IssueExclusionProperties { | |||
public static final String SUB_CATEGORY_IGNORE_ISSUES = "issues"; | |||
@@ -56,14 +55,13 @@ public final class IssueExclusionsConfiguration { | |||
public static final String PATTERNS_ALLFILE_KEY = EXCLUSION_KEY_PREFIX + ALLFILE_SUFFIX; | |||
public static final String FILE_REGEXP = "fileRegexp"; | |||
static final int LARGE_SIZE = 40; | |||
static final int SMALL_SIZE = 10; | |||
public static final int LARGE_SIZE = 40; | |||
private IssueExclusionsConfiguration() { | |||
// static configuration declaration only | |||
private IssueExclusionProperties() { | |||
// only static | |||
} | |||
public static List<PropertyDefinition> getPropertyDefinitions() { | |||
public static List<PropertyDefinition> all() { | |||
return ImmutableList.of( | |||
PropertyDefinition.builder(PATTERNS_MULTICRITERIA_EXCLUSION_KEY) | |||
.category(CoreProperties.CATEGORY_EXCLUSIONS) | |||
@@ -84,7 +82,8 @@ public final class IssueExclusionsConfiguration { | |||
.description("Pattern to match files which should be ignored.") | |||
.type(PropertyType.STRING) | |||
.indicativeSize(LARGE_SIZE) | |||
.build()) | |||
.build() | |||
) | |||
.build(), | |||
PropertyDefinition.builder(PATTERNS_BLOCK_KEY) | |||
.category(CoreProperties.CATEGORY_EXCLUSIONS) | |||
@@ -105,7 +104,8 @@ public final class IssueExclusionsConfiguration { | |||
.description("If specified, this regular expression is used to determine the end of code blocks to ignore. If not, then block ends at the end of file.") | |||
.type(PropertyType.STRING) | |||
.indicativeSize(LARGE_SIZE) | |||
.build()) | |||
.build() | |||
) | |||
.build(), | |||
PropertyDefinition.builder(PATTERNS_ALLFILE_KEY) | |||
.category(CoreProperties.CATEGORY_EXCLUSIONS) | |||
@@ -120,7 +120,8 @@ public final class IssueExclusionsConfiguration { | |||
.description("If this regular expression is found in a file, then the whole file is ignored.") | |||
.type(PropertyType.STRING) | |||
.indicativeSize(LARGE_SIZE) | |||
.build()) | |||
.build() | |||
) | |||
.build(), | |||
PropertyDefinition.builder(PATTERNS_MULTICRITERIA_INCLUSION_KEY) | |||
.category(CoreProperties.CATEGORY_EXCLUSIONS) | |||
@@ -141,7 +142,9 @@ public final class IssueExclusionsConfiguration { | |||
.description("Pattern used to match files to which the rules should be restricted.") | |||
.type(PropertyType.STRING) | |||
.indicativeSize(LARGE_SIZE) | |||
.build()) | |||
.build()); | |||
.build() | |||
) | |||
.build() | |||
); | |||
} | |||
} |
@@ -0,0 +1,80 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.core.config; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.PropertyType; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.resources.Qualifiers; | |||
import java.util.List; | |||
class SecurityProperties { | |||
private SecurityProperties() { | |||
// only static stuff | |||
} | |||
static List<PropertyDefinition> all() { | |||
return ImmutableList.of( | |||
PropertyDefinition.builder(CoreProperties.CORE_IMPORT_SOURCES_PROPERTY) | |||
.defaultValue("" + CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE) | |||
.name("Import sources") | |||
.description("Set to false if sources should not be imported and therefore not available in the Web UI (e.g. for security reasons).") | |||
.type(PropertyType.BOOLEAN) | |||
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY) | |||
.defaultValue("" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE) | |||
.name("Allow users to sign up online") | |||
.description("Users can sign up online.") | |||
.type(PropertyType.BOOLEAN) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_DEFAULT_GROUP) | |||
.defaultValue(CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE) | |||
.name("Default user group") | |||
.description("Any new users will automatically join this group.") | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY) | |||
.defaultValue("" + CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE) | |||
.name("Force user authentication") | |||
.description("Forcing user authentication stops un-logged users to access SonarQube.") | |||
.type(PropertyType.BOOLEAN) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build(), | |||
PropertyDefinition.builder(CoreProperties.CORE_PREVENT_AUTOMATIC_PROJECT_CREATION) | |||
.defaultValue(Boolean.toString(false)) | |||
.name("Prevent automatic project creation") | |||
.description("Set to true to prevent automatic project creation at first analysis and force project provisioning.") | |||
.type(PropertyType.BOOLEAN) | |||
.category(CoreProperties.CATEGORY_SECURITY) | |||
.build() | |||
); | |||
} | |||
} |
@@ -17,18 +17,19 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.plugins.maven; | |||
package org.sonar.core.config; | |||
import org.junit.Test; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import java.util.List; | |||
public class MavenBatchPluginTest { | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class CorePropertyDefinitionsTest { | |||
@Test | |||
public void testGetExtensions() { | |||
MavenBatchPlugin plugin = new MavenBatchPlugin(); | |||
assertThat(plugin.getExtensions()).hasSize(4); | |||
public void all() { | |||
List<PropertyDefinition> defs = CorePropertyDefinitions.all(); | |||
assertThat(defs.size()).isGreaterThan(10); | |||
} | |||
} |
@@ -25,14 +25,8 @@ | |||
<artifactId>gson</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-batch</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-batch-maven-compat</artifactId> | |||
<version>${project.version}</version> | |||
<groupId>com.h2database</groupId> | |||
<artifactId>h2</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
@@ -49,6 +43,12 @@ | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-deprecated</artifactId> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-project</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
@@ -503,13 +503,6 @@ | |||
<type>sonar-plugin</type> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar.plugins</groupId> | |||
<artifactId>sonar-maven-batch-plugin</artifactId> | |||
<version>${project.version}</version> | |||
<type>sonar-plugin</type> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar-plugins.java</groupId> | |||
<artifactId>sonar-jacoco-plugin</artifactId> | |||
@@ -629,12 +622,6 @@ | |||
</plugin> | |||
</plugins> | |||
</build> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.h2database</groupId> | |||
<artifactId>h2</artifactId> | |||
</dependency> | |||
</dependencies> | |||
</profile> | |||
<profile> |
@@ -182,10 +182,6 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable { | |||
return new File(getDeployDir(), "plugins/index.txt"); | |||
} | |||
public File getBootstrapIndex() { | |||
return new File(getDeployDir(), "bootstrap/index.txt"); | |||
} | |||
/** | |||
* @deprecated since 4.1 | |||
*/ |
@@ -39,6 +39,7 @@ import org.sonar.api.utils.UriReader; | |||
import org.sonar.api.utils.internal.TempFolderCleaner; | |||
import org.sonar.core.component.SnapshotPerspectives; | |||
import org.sonar.core.component.db.ComponentDao; | |||
import org.sonar.core.config.CorePropertyDefinitions; | |||
import org.sonar.core.config.Logback; | |||
import org.sonar.core.i18n.DefaultI18n; | |||
import org.sonar.core.i18n.GwtI18n; | |||
@@ -162,6 +163,7 @@ class ServerComponents { | |||
new TempFolderProvider(), | |||
System2.INSTANCE | |||
)); | |||
components.addAll(CorePropertyDefinitions.all()); | |||
components.addAll(DatabaseMigrations.CLASSES); | |||
components.addAll(DaoUtils.getDaoClasses()); | |||
return components; | |||
@@ -191,7 +193,8 @@ class ServerComponents { | |||
// ws | |||
RestartHandler.class, | |||
SystemWs.class | |||
SystemWs.class, | |||
BatchWs.class | |||
); | |||
} | |||
@@ -405,7 +408,6 @@ class ServerComponents { | |||
startupContainer.addSingleton(JdbcDriverDeployer.class); | |||
startupContainer.addSingleton(RegisterDebtModel.class); | |||
startupContainer.addSingleton(GeneratePluginIndex.class); | |||
startupContainer.addSingleton(GenerateBootstrapIndex.class); | |||
startupContainer.addSingleton(RegisterNewMeasureFilters.class); | |||
startupContainer.addSingleton(RegisterDashboards.class); | |||
startupContainer.addSingleton(RegisterPermissionTemplates.class); |
@@ -1,83 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.plugins; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.http.HttpServlet; | |||
import javax.servlet.http.HttpServletRequest; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.OutputStream; | |||
/** | |||
* This servlet allows to load libraries from directory "WEB-INF/lib" in order to provide them for batch-bootstrapper. | |||
* Most probably this is not a best solution. | |||
*/ | |||
public class BatchResourcesServlet extends HttpServlet { | |||
private static final Logger LOG = LoggerFactory.getLogger(BatchResourcesServlet.class); | |||
private static final long serialVersionUID = -2100128371794649028L; | |||
@Override | |||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | |||
String filename = filename(request); | |||
if (StringUtils.isBlank(filename)) { | |||
throw new IllegalArgumentException("Filename is missing."); | |||
} else { | |||
InputStream in = null; | |||
OutputStream out = null; | |||
try { | |||
in = getServletContext().getResourceAsStream("/WEB-INF/lib/" + filename); | |||
if (in == null) { | |||
// TODO | |||
} else { | |||
response.setContentType("application/java-archive"); | |||
out = response.getOutputStream(); | |||
IOUtils.copy(in, out); | |||
} | |||
} catch (Exception e) { | |||
LOG.error("Unable to load batch resource '" + filename + "'", e); | |||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); | |||
} finally { | |||
IOUtils.closeQuietly(in); | |||
IOUtils.closeQuietly(out); | |||
} | |||
} | |||
} | |||
/** | |||
* @return part of request URL after servlet path | |||
*/ | |||
String filename(HttpServletRequest request) { | |||
String filename = null; | |||
if (StringUtils.endsWithIgnoreCase(request.getRequestURI(), "jar")) { | |||
filename = StringUtils.substringAfterLast(request.getRequestURI(), "/"); | |||
} | |||
return filename; | |||
} | |||
} |
@@ -0,0 +1,122 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.plugins; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.io.filefilter.FileFilterUtils; | |||
import org.apache.commons.io.filefilter.HiddenFileFilter; | |||
import org.apache.commons.lang.CharUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.picocontainer.Startable; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.RequestHandler; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
import org.sonar.home.cache.FileHashes; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Collection; | |||
/** | |||
* JAR files to be downloaded by sonar-runner. | |||
*/ | |||
public class BatchWs implements WebService, Startable { | |||
private final Server server; | |||
private String index; | |||
private File batchDir; | |||
public BatchWs(Server server) { | |||
this.server = server; | |||
} | |||
@Override | |||
public void start() { | |||
StringBuilder sb = new StringBuilder(); | |||
batchDir = new File(server.getRootDir(), "lib/batch"); | |||
if (batchDir.exists()) { | |||
Collection<File> files = FileUtils.listFiles(batchDir, HiddenFileFilter.VISIBLE, FileFilterUtils.directoryFileFilter()); | |||
for (File file : files) { | |||
String filename = file.getName(); | |||
if (StringUtils.endsWith(filename, ".jar")) { | |||
sb.append(filename).append('|').append(new FileHashes().of(file)).append(CharUtils.LF); | |||
} | |||
} | |||
} | |||
this.index = sb.toString(); | |||
} | |||
@Override | |||
public void stop() { | |||
// nothing to do | |||
} | |||
@Override | |||
public void define(Context context) { | |||
NewController controller = context.createController("batch"); | |||
controller.createAction("index") | |||
.setInternal(true) | |||
.setDescription("List the JAR files to be downloaded by source analyzer") | |||
.setHandler(new RequestHandler() { | |||
@Override | |||
public void handle(Request request, Response response) { | |||
index(response); | |||
} | |||
}); | |||
controller.createAction("file") | |||
.setInternal(true) | |||
.setDescription("Download a JAR file required by source analyzer") | |||
.setHandler(new RequestHandler() { | |||
@Override | |||
public void handle(Request request, Response response) { | |||
file(request, response); | |||
} | |||
}).createParam("name", "Filename"); | |||
controller.done(); | |||
} | |||
private void index(Response response) { | |||
try { | |||
response.stream().setMediaType("text/plain"); | |||
IOUtils.write(index, response.stream().output()); | |||
} catch (IOException e) { | |||
throw new IllegalStateException("Fail to send batch index", e); | |||
} | |||
} | |||
private void file(Request request, Response response) { | |||
String filename = request.mandatoryParam("name"); | |||
try { | |||
File input = new File(batchDir, filename); | |||
if (!input.exists() || !FileUtils.directoryContains(batchDir, input)) { | |||
throw new IllegalArgumentException("Bad filename: " + filename); | |||
} | |||
response.stream().setMediaType("application/java-archive"); | |||
FileUtils.copyFile(input, response.stream().output()); | |||
} catch (IOException e) { | |||
throw new IllegalStateException("Fail to send batch file " + filename, e); | |||
} | |||
} | |||
} |
@@ -1,112 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.startup; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.io.filefilter.FileFilterUtils; | |||
import org.apache.commons.io.filefilter.HiddenFileFilter; | |||
import org.apache.commons.lang.CharUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.home.cache.FileHashes; | |||
import org.sonar.server.platform.DefaultServerFileSystem; | |||
import java.io.File; | |||
import java.io.FileWriter; | |||
import java.io.IOException; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* @since 3.5 | |||
*/ | |||
public final class GenerateBootstrapIndex { | |||
// JARs starting with one of these prefixes are excluded from batch | |||
private static final String[] IGNORE = {"jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", | |||
"elasticsearch", "lucene"}; | |||
private static final String LIB_DIR = "/web/WEB-INF/lib"; | |||
private final Server server; | |||
private final DefaultServerFileSystem fileSystem; | |||
public GenerateBootstrapIndex(DefaultServerFileSystem fileSystem, Server server) { | |||
this.server = server; | |||
this.fileSystem = fileSystem; | |||
} | |||
public void start() throws IOException { | |||
writeIndex(fileSystem.getBootstrapIndex()); | |||
} | |||
void writeIndex(File indexFile) throws IOException { | |||
FileUtils.forceMkdir(indexFile.getParentFile()); | |||
FileWriter writer = new FileWriter(indexFile, false); | |||
try { | |||
File libDir = new File(server.getRootDir(), LIB_DIR); | |||
// TODO hack for Medium tests | |||
if (libDir.exists()) { | |||
for (String path : getLibs(libDir)) { | |||
writer.append(path); | |||
File is = new File(libDir, path); | |||
writer.append("|").append(new FileHashes().of(is)); | |||
writer.append(CharUtils.LF); | |||
} | |||
writer.flush(); | |||
} | |||
} finally { | |||
IOUtils.closeQuietly(writer); | |||
} | |||
} | |||
@VisibleForTesting | |||
static List<String> getLibs(File libDir) { | |||
List<String> libs = Lists.newArrayList(); | |||
Collection<File> files = FileUtils.listFiles(libDir, HiddenFileFilter.VISIBLE, FileFilterUtils.directoryFileFilter()); | |||
for (File file : files) { | |||
String path = file.getPath(); | |||
if (StringUtils.endsWith(path, ".jar")) { | |||
String filename = StringUtils.removeStart(path, libDir.getAbsolutePath() + "/"); | |||
if (!isIgnored(filename)) { | |||
libs.add(filename); | |||
} | |||
} | |||
} | |||
return libs; | |||
} | |||
/** | |||
* Dirty hack to disable downloading for certain files. | |||
*/ | |||
static boolean isIgnored(String filename) { | |||
for (String prefix : IGNORE) { | |||
if (StringUtils.startsWith(filename, prefix)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
} |
@@ -35,7 +35,11 @@ import org.sonar.api.test.MutableTestPlan; | |||
import org.sonar.api.test.MutableTestable; | |||
import org.sonar.api.test.TestPlan; | |||
import org.sonar.api.test.Testable; | |||
import org.sonar.api.web.*; | |||
import org.sonar.api.web.Footer; | |||
import org.sonar.api.web.NavigationSection; | |||
import org.sonar.api.web.Page; | |||
import org.sonar.api.web.RubyRailsWebservice; | |||
import org.sonar.api.web.Widget; | |||
import org.sonar.core.component.SnapshotPerspectives; | |||
import org.sonar.core.measure.MeasureFilterEngine; | |||
import org.sonar.core.measure.MeasureFilterResult; | |||
@@ -46,8 +50,15 @@ import org.sonar.core.resource.ResourceIndexerDao; | |||
import org.sonar.core.resource.ResourceKeyUpdaterDao; | |||
import org.sonar.core.timemachine.Periods; | |||
import org.sonar.server.db.migrations.DatabaseMigrator; | |||
import org.sonar.server.platform.*; | |||
import org.sonar.server.plugins.*; | |||
import org.sonar.server.platform.Platform; | |||
import org.sonar.server.platform.ServerIdGenerator; | |||
import org.sonar.server.platform.ServerSettings; | |||
import org.sonar.server.platform.SettingsChangeNotifier; | |||
import org.sonar.server.plugins.InstalledPluginReferentialFactory; | |||
import org.sonar.server.plugins.PluginDownloader; | |||
import org.sonar.server.plugins.ServerPluginJarsInstaller; | |||
import org.sonar.server.plugins.ServerPluginRepository; | |||
import org.sonar.server.plugins.UpdateCenterMatrixFactory; | |||
import org.sonar.server.rule.RuleRepositories; | |||
import org.sonar.server.source.CodeColorizers; | |||
import org.sonar.server.user.NewUserNotifier; | |||
@@ -57,7 +68,6 @@ import org.sonar.updatecenter.common.Version; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.io.IOException; | |||
import java.net.InetAddress; | |||
import java.sql.Connection; | |||
import java.util.Collection; | |||
@@ -369,10 +379,6 @@ public final class JRubyFacade { | |||
return Platform.getInstance().getContainer(); | |||
} | |||
public String boostrapIndexPath() throws IOException { | |||
return getContainer().getComponentByType(DefaultServerFileSystem.class).getBootstrapIndex().getCanonicalPath(); | |||
} | |||
// UPDATE PROJECT KEY ------------------------------------------------------------------ | |||
public void updateResourceKey(long projectId, String newKey) { | |||
get(ResourceKeyUpdaterDao.class).updateKey(projectId, newKey); |
@@ -90,11 +90,6 @@ class BatchBootstrapController < Api::ApiController | |||
render :json => JSON(json_properties) | |||
end | |||
# GET /batch_bootstrap/index | |||
def index | |||
render :file => java_facade.boostrapIndexPath(), :layout => false | |||
end | |||
private | |||
def render_unauthorized(message, status=403) |
@@ -14,6 +14,11 @@ ActionController::Routing::Routes.draw do |map| | |||
end | |||
map.connect 'api', :controller => 'api/java_ws', :action => 'redirect_to_ws_listing' | |||
# deprecated, sonar-runner should use batch/index and batch/file?name=xxx | |||
map.connect 'batch_bootstrap/index', :controller => 'api/java_ws', :action => 'index', :wspath => 'batch', :wsaction => 'index' | |||
map.connect 'batch/:name', :controller => 'api/java_ws', :action => 'index', :wspath => 'batch', :wsaction => 'file', :requirements => { :name => /.*/ } | |||
map.connect 'api/metrics', :controller => 'api/metrics', :action => 'index', :conditions => { :method => :get } | |||
map.connect 'api/metrics/:id', :controller => 'api/metrics', :action => 'show', :conditions => { :method => :get } | |||
map.connect 'api/metrics/:id', :controller => 'api/metrics', :action => 'create', :conditions => { :method => :post } |
@@ -90,10 +90,6 @@ | |||
<servlet-name>static</servlet-name> | |||
<servlet-class>org.sonar.server.plugins.StaticResourcesServlet</servlet-class> | |||
</servlet> | |||
<servlet> | |||
<servlet-name>batch</servlet-name> | |||
<servlet-class>org.sonar.server.plugins.BatchResourcesServlet</servlet-class> | |||
</servlet> | |||
<servlet-mapping> | |||
<servlet-name>chart</servlet-name> | |||
@@ -107,10 +103,6 @@ | |||
<servlet-name>static</servlet-name> | |||
<url-pattern>/static/*</url-pattern> | |||
</servlet-mapping> | |||
<servlet-mapping> | |||
<servlet-name>batch</servlet-name> | |||
<url-pattern>/batch/*</url-pattern> | |||
</servlet-mapping> | |||
<session-config> | |||
<!-- in minutes --> |
@@ -1,62 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.plugins; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import javax.servlet.http.HttpServletRequest; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
public class BatchResourcesServletTest { | |||
private BatchResourcesServlet servlet; | |||
private HttpServletRequest request; | |||
@Before | |||
public void setUp() throws Exception { | |||
servlet = new BatchResourcesServlet(); | |||
request = mock(HttpServletRequest.class); | |||
} | |||
@Test | |||
public void test_filename() { | |||
when(request.getContextPath()).thenReturn("sonar"); | |||
when(request.getServletPath()).thenReturn("/batch"); | |||
when(request.getRequestURI()).thenReturn("/sonar/batch/sonar-core-2.6.jar"); | |||
assertThat(servlet.filename(request)).isEqualTo("sonar-core-2.6.jar"); | |||
when(request.getRequestURI()).thenReturn("/sonar/batch/"); | |||
assertThat(servlet.filename(request)).isNull(); | |||
when(request.getRequestURI()).thenReturn("/sonar/batch"); | |||
assertThat(servlet.filename(request)).isNull(); | |||
when(request.getRequestURI()).thenReturn("/sonar/batch.html"); | |||
assertThat(servlet.filename(request)).isNull(); | |||
when(request.getRequestURI()).thenReturn("/sonar/batch/index.html"); | |||
assertThat(servlet.filename(request)).isNull(); | |||
} | |||
} |
@@ -0,0 +1,108 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.plugins; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.CharUtils; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.platform.Server; | |||
import org.sonar.api.server.ws.WsTester; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
public class BatchWsTest { | |||
@Rule | |||
public TemporaryFolder temp = new TemporaryFolder(); | |||
@Rule | |||
public ExpectedException thrown = ExpectedException.none(); | |||
Server server = mock(Server.class); | |||
@Before | |||
public void prepare_fs() throws IOException { | |||
File rootDir = temp.newFolder(); | |||
when(server.getRootDir()).thenReturn(rootDir); | |||
File batchDir = new File(rootDir, "lib/batch"); | |||
FileUtils.forceMkdir(batchDir); | |||
FileUtils.writeStringToFile(new File(batchDir, "sonar-batch.jar"), "foo"); | |||
} | |||
@Test | |||
public void download_index() throws Exception { | |||
BatchWs ws = new BatchWs(server); | |||
ws.start(); | |||
WsTester tester = new WsTester(ws); | |||
String index = tester.newRequest("index").execute().outputAsString(); | |||
assertThat(index).isEqualTo("sonar-batch.jar|acbd18db4cc2f85cedef654fccc4a4d8" + CharUtils.LF); | |||
ws.stop(); | |||
} | |||
@Test | |||
public void download_file() throws Exception { | |||
BatchWs ws = new BatchWs(server); | |||
ws.start(); | |||
WsTester tester = new WsTester(ws); | |||
String jar = tester.newRequest("file").setParam("name", "sonar-batch.jar").execute().outputAsString(); | |||
assertThat(jar).isEqualTo("foo"); | |||
} | |||
/** | |||
* Do not allow to download files located outside the directory lib/batch, for example | |||
* /etc/passwd | |||
*/ | |||
@Test | |||
public void check_location_of_file() throws Exception { | |||
thrown.expect(IllegalArgumentException.class); | |||
thrown.expectMessage("Bad filename: ../sonar-batch.jar"); | |||
BatchWs ws = new BatchWs(server); | |||
ws.start(); | |||
WsTester tester = new WsTester(ws); | |||
tester.newRequest("file").setParam("name", "../sonar-batch.jar").execute(); | |||
} | |||
@Test | |||
public void file_does_not_exist() throws Exception { | |||
thrown.expect(IllegalArgumentException.class); | |||
thrown.expectMessage("Bad filename: other.jar"); | |||
BatchWs ws = new BatchWs(server); | |||
ws.start(); | |||
WsTester tester = new WsTester(ws); | |||
tester.newRequest("file").setParam("name", "other.jar").execute(); | |||
} | |||
} |
@@ -1,69 +0,0 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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 this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.startup; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class GenerateBootstrapIndexTest { | |||
@Rule | |||
public TemporaryFolder rootDir = new TemporaryFolder(); | |||
@Before | |||
public void setUp() throws Exception { | |||
} | |||
@Test | |||
public void determine_list_of_resources() throws IOException { | |||
new File(rootDir.getRoot(), "/web/WEB-INF/lib").mkdirs(); | |||
File webInf = new File(rootDir.getRoot(), "/web/WEB-INF"); | |||
File lib = new File(rootDir.getRoot(), "/web/WEB-INF/lib"); | |||
new File(webInf, "directory").mkdir(); | |||
new File(lib, "sonar-core-2.6.jar").createNewFile(); | |||
new File(lib, "treemap.rbr").createNewFile(); | |||
new File(lib, "sonar-core-2.6.jar").createNewFile(); | |||
assertThat(GenerateBootstrapIndex.getLibs(lib)).hasSize(1); | |||
assertThat(GenerateBootstrapIndex.getLibs(lib).get(0)).isEqualTo("sonar-core-2.6.jar"); | |||
} | |||
@Test | |||
public void ignore_some_jars() { | |||
assertThat(GenerateBootstrapIndex.isIgnored("sonar-batch-2.6-SNAPSHOT.jar")).isFalse(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("mysql-connector-java-5.1.13.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("postgresql-9.0-801.jdbc3.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("jtds-1.2.4.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("jfreechart-1.0.9.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("eastwood-1.1.0.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("jruby-complete-1.5.6.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("jruby-rack-1.0.5.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("elasticsearch-0.90.6.jar")).isTrue(); | |||
assertThat(GenerateBootstrapIndex.isIgnored("lucene-core-4.5.1.jar")).isTrue(); | |||
} | |||
} |