]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2860 Drop commons-configuration
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 5 Sep 2014 12:58:03 +0000 (14:58 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 5 Sep 2014 12:58:03 +0000 (14:58 +0200)
43 files changed:
plugins/sonar-email-notifications-plugin/pom.xml
pom.xml
server/sonar-server/pom.xml
server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettings.java
server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java
server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java
sonar-batch/pom.xml
sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java
sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java
sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
sonar-core/src/main/java/org/sonar/api/database/configuration/DatabaseConfiguration.java [deleted file]
sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java
sonar-core/src/test/java/org/sonar/api/database/configuration/DatabaseConfigurationTest.java [deleted file]
sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java [deleted file]
sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java [deleted file]
sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java [deleted file]
sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java [deleted file]
sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java [deleted file]
sonar-java-api/pom.xml
sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java
sonar-plugin-api/pom.xml
sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaContext.java
sonar-plugin-api/src/main/java/org/sonar/api/measures/FormulaContext.java
sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java
sonar-plugin-api/src/test/java/org/sonar/api/test/MavenTestUtils.java
sonar-plugin-api/src/test/java/org/sonar/api/test/ProjectTestBuilder.java

index 792e80179be4f1b1aae68e1f74a4f1f13faea017..3d78b68cc60fcd9cb47957258c2fb57ea799555c 100644 (file)
       <artifactId>sonar-plugin-api</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-email</artifactId>
diff --git a/pom.xml b/pom.xml
index 98330ad0ec451d3e0bfa304891ad1df6f9d8b9d4..21e3b8b432a28f34362e2763e509eba8f83e190e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           </exclusion>
         </exclusions>
       </dependency>
-      <dependency>
-        <groupId>commons-configuration</groupId>
-        <artifactId>commons-configuration</artifactId>
-        <version>1.6</version>
-        <exclusions>
-          <exclusion>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-          </exclusion>
-          <exclusion>
-            <!-- See SONAR-2512 -->
-            <groupId>commons-beanutils</groupId>
-            <artifactId>commons-beanutils-core</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>commons-digester</groupId>
-            <artifactId>commons-digester</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
       <dependency>
         <groupId>com.ibm.icu</groupId>
         <artifactId>icu4j</artifactId>
index 47ec2324e261f38ebb51ac0c73b4d3c5aabacfff..39af6f5b17e5452e7fe06c4c934d5749cfdf4aba 100644 (file)
       <groupId>commons-beanutils</groupId>
       <artifactId>commons-beanutils</artifactId>
     </dependency>
-    <dependency>
-      <groupId>commons-configuration</groupId>
-      <artifactId>commons-configuration</artifactId>
-    </dependency>
     <dependency>
       <groupId>com.thoughtworks.xstream</groupId>
       <artifactId>xstream</artifactId>
index 418cba0bcf5a6e3df764ebd1ad89a6747bd2d1ea..f53f013929a1bb60be6329ce55d8cf4d688e0b41 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.platform;
 
 import com.google.common.collect.Lists;
-import org.apache.commons.configuration.BaseConfiguration;
 import org.sonar.api.config.EmailSettings;
 import org.sonar.api.issue.action.Actions;
 import org.sonar.api.platform.ComponentContainer;
@@ -52,7 +51,13 @@ import org.sonar.core.measure.db.MeasureFilterDao;
 import org.sonar.core.metric.DefaultMetricFinder;
 import org.sonar.core.notification.DefaultNotificationManager;
 import org.sonar.core.permission.PermissionFacade;
-import org.sonar.core.persistence.*;
+import org.sonar.core.persistence.DaoUtils;
+import org.sonar.core.persistence.DatabaseVersion;
+import org.sonar.core.persistence.DefaultDatabase;
+import org.sonar.core.persistence.MyBatis;
+import org.sonar.core.persistence.PreviewDatabaseFactory;
+import org.sonar.core.persistence.SemaphoreUpdater;
+import org.sonar.core.persistence.SemaphoresImpl;
 import org.sonar.core.preview.PreviewCache;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.purge.PurgeProfiler;
@@ -86,18 +91,44 @@ import org.sonar.server.charts.ChartFactory;
 import org.sonar.server.component.DefaultComponentFinder;
 import org.sonar.server.component.DefaultRubyComponentService;
 import org.sonar.server.component.persistence.ComponentDao;
-import org.sonar.server.component.ws.*;
+import org.sonar.server.component.ws.ComponentAppAction;
+import org.sonar.server.component.ws.ComponentsWs;
+import org.sonar.server.component.ws.EventsWs;
+import org.sonar.server.component.ws.ProjectsWs;
+import org.sonar.server.component.ws.ResourcesWs;
 import org.sonar.server.config.ws.PropertiesWs;
 import org.sonar.server.db.DatabaseChecker;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.db.EmbeddedDatabaseFactory;
 import org.sonar.server.db.migrations.DatabaseMigrations;
 import org.sonar.server.db.migrations.DatabaseMigrator;
-import org.sonar.server.debt.*;
+import org.sonar.server.debt.DebtCharacteristicsXMLImporter;
+import org.sonar.server.debt.DebtModelBackup;
+import org.sonar.server.debt.DebtModelLookup;
+import org.sonar.server.debt.DebtModelOperations;
+import org.sonar.server.debt.DebtModelPluginRepository;
+import org.sonar.server.debt.DebtModelService;
+import org.sonar.server.debt.DebtModelXMLExporter;
+import org.sonar.server.debt.DebtRulesXMLImporter;
 import org.sonar.server.duplication.ws.DuplicationsJsonWriter;
 import org.sonar.server.duplication.ws.DuplicationsParser;
 import org.sonar.server.duplication.ws.DuplicationsWs;
-import org.sonar.server.issue.*;
+import org.sonar.server.issue.ActionService;
+import org.sonar.server.issue.AssignAction;
+import org.sonar.server.issue.CommentAction;
+import org.sonar.server.issue.DefaultIssueFinder;
+import org.sonar.server.issue.InternalRubyIssueService;
+import org.sonar.server.issue.IssueBulkChangeService;
+import org.sonar.server.issue.IssueChangelogFormatter;
+import org.sonar.server.issue.IssueChangelogService;
+import org.sonar.server.issue.IssueCommentService;
+import org.sonar.server.issue.IssueService;
+import org.sonar.server.issue.IssueStatsFinder;
+import org.sonar.server.issue.PlanAction;
+import org.sonar.server.issue.PublicRubyIssueService;
+import org.sonar.server.issue.ServerIssueStorage;
+import org.sonar.server.issue.SetSeverityAction;
+import org.sonar.server.issue.TransitionAction;
 import org.sonar.server.issue.actionplan.ActionPlanService;
 import org.sonar.server.issue.actionplan.ActionPlanWs;
 import org.sonar.server.issue.db.IssueDao;
@@ -130,22 +161,84 @@ import org.sonar.server.platform.ws.L10nWs;
 import org.sonar.server.platform.ws.RestartHandler;
 import org.sonar.server.platform.ws.ServerWs;
 import org.sonar.server.platform.ws.SystemWs;
-import org.sonar.server.plugins.*;
+import org.sonar.server.plugins.InstalledPluginReferentialFactory;
+import org.sonar.server.plugins.PluginDownloader;
+import org.sonar.server.plugins.ServerExtensionInstaller;
+import org.sonar.server.plugins.ServerPluginJarInstaller;
+import org.sonar.server.plugins.ServerPluginJarsInstaller;
+import org.sonar.server.plugins.ServerPluginRepository;
+import org.sonar.server.plugins.UpdateCenterClient;
+import org.sonar.server.plugins.UpdateCenterMatrixFactory;
 import org.sonar.server.qualitygate.QgateProjectFinder;
 import org.sonar.server.qualitygate.QualityGates;
 import org.sonar.server.qualitygate.RegisterQualityGates;
-import org.sonar.server.qualitygate.ws.*;
-import org.sonar.server.qualityprofile.*;
+import org.sonar.server.qualitygate.ws.QGatesAppAction;
+import org.sonar.server.qualitygate.ws.QGatesCopyAction;
+import org.sonar.server.qualitygate.ws.QGatesCreateAction;
+import org.sonar.server.qualitygate.ws.QGatesCreateConditionAction;
+import org.sonar.server.qualitygate.ws.QGatesDeleteConditionAction;
+import org.sonar.server.qualitygate.ws.QGatesDeselectAction;
+import org.sonar.server.qualitygate.ws.QGatesDestroyAction;
+import org.sonar.server.qualitygate.ws.QGatesListAction;
+import org.sonar.server.qualitygate.ws.QGatesRenameAction;
+import org.sonar.server.qualitygate.ws.QGatesSearchAction;
+import org.sonar.server.qualitygate.ws.QGatesSelectAction;
+import org.sonar.server.qualitygate.ws.QGatesSetAsDefaultAction;
+import org.sonar.server.qualitygate.ws.QGatesShowAction;
+import org.sonar.server.qualitygate.ws.QGatesUnsetDefaultAction;
+import org.sonar.server.qualitygate.ws.QGatesUpdateConditionAction;
+import org.sonar.server.qualitygate.ws.QGatesWs;
+import org.sonar.server.qualityprofile.BuiltInProfiles;
+import org.sonar.server.qualityprofile.QProfileBackuper;
+import org.sonar.server.qualityprofile.QProfileCopier;
+import org.sonar.server.qualityprofile.QProfileExporters;
+import org.sonar.server.qualityprofile.QProfileFactory;
+import org.sonar.server.qualityprofile.QProfileLoader;
+import org.sonar.server.qualityprofile.QProfileLookup;
+import org.sonar.server.qualityprofile.QProfileProjectLookup;
+import org.sonar.server.qualityprofile.QProfileProjectOperations;
+import org.sonar.server.qualityprofile.QProfileRepositoryExporter;
+import org.sonar.server.qualityprofile.QProfileReset;
+import org.sonar.server.qualityprofile.QProfileService;
+import org.sonar.server.qualityprofile.QProfiles;
+import org.sonar.server.qualityprofile.RegisterQualityProfiles;
+import org.sonar.server.qualityprofile.RuleActivator;
+import org.sonar.server.qualityprofile.RuleActivatorContextFactory;
 import org.sonar.server.qualityprofile.db.ActiveRuleDao;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
 import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer;
-import org.sonar.server.qualityprofile.ws.*;
-import org.sonar.server.rule.*;
+import org.sonar.server.qualityprofile.ws.BulkRuleActivationActions;
+import org.sonar.server.qualityprofile.ws.ProfilesWs;
+import org.sonar.server.qualityprofile.ws.QProfileRestoreBuiltInAction;
+import org.sonar.server.qualityprofile.ws.QProfilesWs;
+import org.sonar.server.qualityprofile.ws.RuleActivationActions;
+import org.sonar.server.rule.DefaultRuleFinder;
+import org.sonar.server.rule.DeprecatedRulesDefinition;
+import org.sonar.server.rule.RegisterRules;
+import org.sonar.server.rule.RubyRuleService;
+import org.sonar.server.rule.RuleCreator;
+import org.sonar.server.rule.RuleDefinitionsLoader;
+import org.sonar.server.rule.RuleDeleter;
+import org.sonar.server.rule.RuleOperations;
+import org.sonar.server.rule.RuleRepositories;
+import org.sonar.server.rule.RuleService;
+import org.sonar.server.rule.RuleUpdater;
 import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.rule.index.RuleIndex;
 import org.sonar.server.rule.index.RuleNormalizer;
-import org.sonar.server.rule.ws.*;
-import org.sonar.server.search.*;
+import org.sonar.server.rule.ws.ActiveRuleCompleter;
+import org.sonar.server.rule.ws.AppAction;
+import org.sonar.server.rule.ws.DeleteAction;
+import org.sonar.server.rule.ws.RuleMapping;
+import org.sonar.server.rule.ws.RulesWebService;
+import org.sonar.server.rule.ws.SearchAction;
+import org.sonar.server.rule.ws.TagsAction;
+import org.sonar.server.rule.ws.UpdateAction;
+import org.sonar.server.search.IndexClient;
+import org.sonar.server.search.IndexQueue;
+import org.sonar.server.search.IndexSynchronizer;
+import org.sonar.server.search.SearchClient;
+import org.sonar.server.search.SearchHealth;
 import org.sonar.server.source.CodeColorizers;
 import org.sonar.server.source.DeprecatedSourceDecorator;
 import org.sonar.server.source.HtmlSourceDecorator;
@@ -154,9 +247,27 @@ import org.sonar.server.source.ws.ScmAction;
 import org.sonar.server.source.ws.ScmWriter;
 import org.sonar.server.source.ws.ShowAction;
 import org.sonar.server.source.ws.SourcesWs;
-import org.sonar.server.startup.*;
+import org.sonar.server.startup.CleanPreviewAnalysisCache;
+import org.sonar.server.startup.CopyRequirementsFromCharacteristicsToRules;
+import org.sonar.server.startup.GeneratePluginIndex;
+import org.sonar.server.startup.GwtPublisher;
+import org.sonar.server.startup.JdbcDriverDeployer;
+import org.sonar.server.startup.LogServerId;
+import org.sonar.server.startup.RegisterDashboards;
+import org.sonar.server.startup.RegisterDebtModel;
+import org.sonar.server.startup.RegisterMetrics;
+import org.sonar.server.startup.RegisterNewMeasureFilters;
+import org.sonar.server.startup.RegisterPermissionTemplates;
+import org.sonar.server.startup.RegisterServletFilters;
+import org.sonar.server.startup.RenameDeprecatedPropertyKeys;
+import org.sonar.server.startup.ServerMetadataPersister;
 import org.sonar.server.test.CoverageService;
-import org.sonar.server.test.ws.*;
+import org.sonar.server.test.ws.CoverageShowAction;
+import org.sonar.server.test.ws.CoverageWs;
+import org.sonar.server.test.ws.TestsCoveredFilesAction;
+import org.sonar.server.test.ws.TestsShowAction;
+import org.sonar.server.test.ws.TestsTestCasesAction;
+import org.sonar.server.test.ws.TestsWs;
 import org.sonar.server.text.MacroInterpreter;
 import org.sonar.server.text.RubyTextService;
 import org.sonar.server.ui.JRubyI18n;
@@ -164,11 +275,22 @@ import org.sonar.server.ui.JRubyProfiling;
 import org.sonar.server.ui.PageDecorations;
 import org.sonar.server.ui.Views;
 import org.sonar.server.updatecenter.ws.UpdateCenterWs;
-import org.sonar.server.user.*;
+import org.sonar.server.user.DefaultUserService;
+import org.sonar.server.user.DoPrivileged;
+import org.sonar.server.user.GroupMembershipFinder;
+import org.sonar.server.user.GroupMembershipService;
+import org.sonar.server.user.NewUserNotifier;
+import org.sonar.server.user.SecurityRealmFactory;
 import org.sonar.server.user.ws.FavoritesWs;
 import org.sonar.server.user.ws.UserPropertiesWs;
 import org.sonar.server.user.ws.UsersWs;
-import org.sonar.server.util.*;
+import org.sonar.server.util.BooleanTypeValidation;
+import org.sonar.server.util.FloatTypeValidation;
+import org.sonar.server.util.IntegerTypeValidation;
+import org.sonar.server.util.StringListTypeValidation;
+import org.sonar.server.util.StringTypeValidation;
+import org.sonar.server.util.TextTypeValidation;
+import org.sonar.server.util.TypeValidations;
 import org.sonar.server.ws.ListingWs;
 import org.sonar.server.ws.WebServiceEngine;
 
@@ -191,7 +313,6 @@ class ServerComponents {
   Collection level1Components() {
     List components = Lists.newArrayList(rootComponents);
     components.addAll(Arrays.asList(
-      new BaseConfiguration(),
       ServerSettings.class,
       ServerImpl.class,
       Logback.class,
index 21c301b3cfe44937a073cf0ab2281199fcd40b61..cf63e34f87ff334935323ce98385a3b5f91d2358 100644 (file)
  */
 package org.sonar.server.platform;
 
-import org.apache.commons.configuration.Configuration;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
 
-import javax.annotation.Nullable;
-
 import java.util.Collections;
 import java.util.Map;
 import java.util.Properties;
@@ -44,11 +41,9 @@ import java.util.Properties;
 public class ServerSettings extends Settings {
 
   private final Properties properties;
-  private Configuration deprecatedConfiguration;
 
-  public ServerSettings(PropertyDefinitions definitions, Configuration deprecatedConfiguration, Properties properties) {
+  public ServerSettings(PropertyDefinitions definitions, Properties properties) {
     super(definitions);
-    this.deprecatedConfiguration = deprecatedConfiguration;
     this.properties = properties;
     load(Collections.<String, String>emptyMap());
     // Secret key is loaded from conf/sonar.properties
@@ -68,19 +63,4 @@ public class ServerSettings extends Settings {
 
     return this;
   }
-
-  @Override
-  protected void doOnSetProperty(String key, @Nullable String value) {
-    deprecatedConfiguration.setProperty(key, value);
-  }
-
-  @Override
-  protected void doOnRemoveProperty(String key) {
-    deprecatedConfiguration.clearProperty(key);
-  }
-
-  @Override
-  protected void doOnClearProperties() {
-    deprecatedConfiguration.clear();
-  }
 }
index 3612c1045268bfde8fc645e30530a279bc9c16bd..920853a84636760730a8b7b14375da33b63438db 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.platform;
 
 import com.google.common.collect.ImmutableMap;
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentMatcher;
@@ -34,7 +33,9 @@ import java.util.Properties;
 
 import static org.fest.assertions.Assertions.assertThat;
 import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class PersistentSettingsTest {
 
@@ -47,7 +48,6 @@ public class PersistentSettingsTest {
 
     settings = new ServerSettings(
       new PropertyDefinitions(),
-      new PropertiesConfiguration(),
       new Properties());
   }
 
@@ -55,7 +55,7 @@ public class PersistentSettingsTest {
   public void load_database_properties_at_startup() {
     when(dao.selectGlobalProperties()).thenReturn(Arrays.asList(
       new PropertyDto().setKey("in_db").setValue("bar")
-    ));
+      ));
 
     PersistentSettings persistentSettings = new PersistentSettings(dao, settings);
     persistentSettings.start();
index af0cc558e8f326cc5db97ce3a35d64405b201daa..ca465ee40970715141f54168e62682ee002526ad 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.platform;
 
 import com.google.common.collect.ImmutableMap;
-import org.apache.commons.configuration.BaseConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.config.PropertyDefinitions;
@@ -42,7 +41,7 @@ public class ServerSettingsTest {
     properties.put("hello", "world");
     properties.put("in_file", "true");
     properties.put("ServerSettingsTestEnv", "in_file");
-    settings = new ServerSettings(new PropertyDefinitions(), new BaseConfiguration(), properties);
+    settings = new ServerSettings(new PropertyDefinitions(), properties);
   }
 
   @Test
@@ -68,18 +67,4 @@ public class ServerSettingsTest {
     assertThat(settings.getString("in_file")).isEqualTo("true");
   }
 
-  @Test
-  public void synchronize_deprecated_commons_configuration() {
-    BaseConfiguration deprecated = new BaseConfiguration();
-    ServerSettings settings = new ServerSettings(new PropertyDefinitions(), deprecated, properties);
-
-    assertThat(settings.getString("in_file")).isEqualTo("true");
-    assertThat(deprecated.getString("in_file")).isEqualTo("true");
-
-    assertThat(deprecated.getString("foo")).isNull();
-    settings.setProperty("foo", "bar");
-    assertThat(deprecated.getString("foo")).isEqualTo("bar");
-    settings.removeProperty("foo");
-    assertThat(deprecated.getString("foo")).isNull();
-  }
 }
index 41e7ebdc841c8b58f2d504b135eb9903333d52c5..8a44063c1513ab3f5035aeeddd4ca1b9d796d033 100644 (file)
@@ -88,8 +88,8 @@
       <artifactId>commons-lang</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-configuration</groupId>
-      <artifactId>commons-configuration</artifactId>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
     </dependency>
     <dependency>
       <groupId>com.google.code.gson</groupId>
index 70d05de7356e357ba34138bd6e0db2df25cfe9de..2f972a398e6f6f04df5ba56f35c78c71c7ff38a4 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.batch;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.project.MavenProject;
 import org.slf4j.Logger;
@@ -75,8 +74,6 @@ public class ProjectConfigurator implements BatchComponent {
     checkCurrentAnalysisIsTheLatestOne(project.getKey(), analysisDate);
 
     project
-      // will be populated by ProjectSettings
-      .setConfiguration(new PropertiesConfiguration())
       .setAnalysisDate(analysisDate)
       .setAnalysisVersion(loadAnalysisVersion())
       .setAnalysisType(loadAnalysisType());
@@ -89,10 +86,9 @@ public class ProjectConfigurator implements BatchComponent {
       Snapshot lastSnapshot = databaseSession.getSingleResult(Snapshot.class, "resourceId", persistedProject.getId(), "last", true);
       if (lastSnapshot != null && !lastSnapshot.getCreatedAt().before(analysisDate)) {
         throw new IllegalArgumentException(
-          "'sonar.projectDate' property cannot be older than the date of the last known quality snapshot on this project. Value: '"+
+          "'sonar.projectDate' property cannot be older than the date of the last known quality snapshot on this project. Value: '" +
             settings.getString(CoreProperties.PROJECT_DATE_PROPERTY) + "'. " +
-            "Latest quality snapshot: '"+ DateUtils.formatDate(lastSnapshot.getCreatedAt()) +"'. This property may only be used to rebuild the past in a chronological order."
-        );
+            "Latest quality snapshot: '" + DateUtils.formatDate(lastSnapshot.getCreatedAt()) + "'. This property may only be used to rebuild the past in a chronological order.");
       }
     }
 
index d08d78beafbfc6928987513d22b6594ab3fd961b..dd49c4e9a1298cfc9dae9dbbc8c99332e81b42c8 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.batch.bootstrap;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.Plugin;
 import org.sonar.api.config.EmailSettings;
@@ -88,7 +87,6 @@ public class BootstrapContainer extends ComponentContainer {
 
   private void addBootstrapComponents() {
     add(
-      new PropertiesConfiguration(),
       new BootstrapProperties(bootstrapProperties),
       AnalysisMode.class,
       BatchPluginRepository.class,
index 96922f5b93f24cd263ccac25a426306940b25c72..befb89563fe4e109e82f8e958bf07252bce763bb 100644 (file)
  */
 package org.sonar.batch.bootstrap;
 
-import org.apache.commons.configuration.Configuration;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
 import org.sonar.api.utils.MessageException;
 import org.sonar.batch.protocol.input.GlobalReferentials;
 
-import javax.annotation.Nullable;
-
 public class GlobalSettings extends Settings {
 
-  private Configuration deprecatedConfiguration;
-
   private final BootstrapProperties bootstrapProps;
   private final GlobalReferentials globalReferentials;
   private final AnalysisMode mode;
 
   public GlobalSettings(BootstrapProperties bootstrapProps, PropertyDefinitions propertyDefinitions,
-    GlobalReferentials globalReferentials, Configuration deprecatedConfiguration, AnalysisMode mode) {
+    GlobalReferentials globalReferentials, AnalysisMode mode) {
 
     super(propertyDefinitions);
     this.mode = mode;
     getEncryption().setPathToSecretKey(bootstrapProps.property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
     this.bootstrapProps = bootstrapProps;
     this.globalReferentials = globalReferentials;
-    this.deprecatedConfiguration = deprecatedConfiguration;
     init();
   }
 
@@ -53,21 +47,6 @@ public class GlobalSettings extends Settings {
     addProperties(bootstrapProps.properties());
   }
 
-  @Override
-  protected void doOnSetProperty(String key, @Nullable String value) {
-    deprecatedConfiguration.setProperty(key, value);
-  }
-
-  @Override
-  protected void doOnRemoveProperty(String key) {
-    deprecatedConfiguration.clearProperty(key);
-  }
-
-  @Override
-  protected void doOnClearProperties() {
-    deprecatedConfiguration.clear();
-  }
-
   @Override
   protected void doOnGetProperties(String key) {
     if (mode.isPreview() && key.endsWith(".secured") && !key.contains(".license")) {
index 541a63a6bd7792498d3ac37d63dc6c5c7d8b42e7..56263637b14b8cfd102dc2a96d1c8133e5856b8e 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.batch.components;
 
 import com.google.common.base.Strings;
-import org.apache.commons.configuration.Configuration;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,6 +29,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.database.model.Snapshot;
 
 import javax.annotation.Nullable;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -45,8 +45,8 @@ public class PastSnapshotFinder implements BatchExtension {
   private PastSnapshotFinderByPreviousVersion finderByPreviousVersion;
 
   public PastSnapshotFinder(PastSnapshotFinderByDays finderByDays, PastSnapshotFinderByVersion finderByVersion,
-                            PastSnapshotFinderByDate finderByDate, PastSnapshotFinderByPreviousAnalysis finderByPreviousAnalysis,
-                            PastSnapshotFinderByPreviousVersion finderByPreviousVersion) {
+    PastSnapshotFinderByDate finderByDate, PastSnapshotFinderByPreviousAnalysis finderByPreviousAnalysis,
+    PastSnapshotFinderByPreviousVersion finderByPreviousVersion) {
     this.finderByDays = finderByDays;
     this.finderByVersion = finderByVersion;
     this.finderByDate = finderByDate;
@@ -54,45 +54,6 @@ public class PastSnapshotFinder implements BatchExtension {
     this.finderByPreviousVersion = finderByPreviousVersion;
   }
 
-  /**
-   * @deprecated since 3.6. Replaced by {@link #find(Snapshot projectSnapshot, String rootQualifier, Settings settings, int index) }
-   */
-  @Deprecated
-  public PastSnapshot find(Snapshot projectSnapshot, Configuration conf, int index) {
-    String propertyValue = getPropertyValue(conf, index);
-    PastSnapshot pastSnapshot = find(projectSnapshot, index, propertyValue);
-    if (pastSnapshot == null && StringUtils.isNotBlank(propertyValue)) {
-      LoggerFactory.getLogger(PastSnapshotFinder.class).debug("Property " + CoreProperties.TIMEMACHINE_PERIOD_PREFIX + index + " is not valid: " + propertyValue);
-    }
-    return pastSnapshot;
-  }
-
-  /**
-   * @deprecated since 3.6. Replace by {@link #getPropertyValue(String rootQualifier, Settings settings, int index) }
-   */
-  @Deprecated
-  static String getPropertyValue(Configuration conf, int index) {
-    String defaultValue = null;
-    switch (index) {
-      case 1:
-        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1;
-        break;
-      case 2:
-        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2;
-        break;
-      case 3:
-        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3;
-        break;
-      case 4:
-        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4;
-        break;
-      case 5:
-        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5;
-        break;
-    }
-    return conf.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + index, defaultValue);
-  }
-
   public PastSnapshot find(Snapshot projectSnapshot, @Nullable String rootQualifier, Settings settings, int index) {
     String propertyValue = getPropertyValue(rootQualifier, settings, index);
     PastSnapshot pastSnapshot = find(projectSnapshot, index, propertyValue);
index 7194f548f02377a4c9f8afd7eaa338376f3fb3cd..43f557a3c4400d16240abbd9ac90702bf8aaf258 100644 (file)
@@ -41,6 +41,7 @@ public class ProjectInitializer implements BatchComponent {
   }
 
   public void execute(Project project) {
+    project.setSettings(settings);
     if (project.getLanguage() == null) {
       initDeprecatedLanguage(project);
     }
index 733a8237dd8e5db65861dcec7d007d75a996644d..800210aa1c9f6cacc3946ea7ff84b9ccf5de02d6 100644 (file)
@@ -28,13 +28,22 @@ import org.sonar.api.batch.rule.CheckFactory;
 import org.sonar.api.platform.ComponentContainer;
 import org.sonar.api.resources.Project;
 import org.sonar.api.scan.filesystem.FileExclusions;
-import org.sonar.batch.*;
+import org.sonar.batch.DefaultProjectClasspath;
+import org.sonar.batch.DefaultSensorContext;
+import org.sonar.batch.DefaultTimeMachine;
+import org.sonar.batch.ProjectTree;
+import org.sonar.batch.ResourceFilters;
+import org.sonar.batch.ViolationFilters;
 import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
 import org.sonar.batch.bootstrap.ExtensionInstaller;
 import org.sonar.batch.bootstrap.ExtensionMatcher;
 import org.sonar.batch.bootstrap.ExtensionUtils;
 import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.debt.*;
+import org.sonar.batch.debt.DebtDecorator;
+import org.sonar.batch.debt.IssueChangelogDebtCalculator;
+import org.sonar.batch.debt.NewDebtDecorator;
+import org.sonar.batch.debt.SqaleRatingDecorator;
+import org.sonar.batch.debt.SqaleRatingSettings;
 import org.sonar.batch.events.EventBus;
 import org.sonar.batch.index.DefaultIndex;
 import org.sonar.batch.index.ResourcePersister;
@@ -53,8 +62,26 @@ import org.sonar.batch.phases.PhasesTimeProfiler;
 import org.sonar.batch.qualitygate.GenerateQualityGateEvents;
 import org.sonar.batch.qualitygate.QualityGateProvider;
 import org.sonar.batch.qualitygate.QualityGateVerifier;
-import org.sonar.batch.rule.*;
-import org.sonar.batch.scan.filesystem.*;
+import org.sonar.batch.rule.ActiveRulesProvider;
+import org.sonar.batch.rule.ModuleQProfiles;
+import org.sonar.batch.rule.QProfileDecorator;
+import org.sonar.batch.rule.QProfileEventsDecorator;
+import org.sonar.batch.rule.QProfileSensor;
+import org.sonar.batch.rule.QProfileVerifier;
+import org.sonar.batch.rule.RulesProfileProvider;
+import org.sonar.batch.scan.filesystem.ComponentIndexer;
+import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
+import org.sonar.batch.scan.filesystem.DeprecatedFileFilters;
+import org.sonar.batch.scan.filesystem.ExclusionFilters;
+import org.sonar.batch.scan.filesystem.FileIndexer;
+import org.sonar.batch.scan.filesystem.FileSystemLogger;
+import org.sonar.batch.scan.filesystem.InputFileBuilderFactory;
+import org.sonar.batch.scan.filesystem.LanguageDetectionFactory;
+import org.sonar.batch.scan.filesystem.ModuleFileSystemInitializer;
+import org.sonar.batch.scan.filesystem.ModuleInputFileCache;
+import org.sonar.batch.scan.filesystem.PreviousFileHashLoader;
+import org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter;
+import org.sonar.batch.scan.filesystem.StatusDetectionFactory;
 import org.sonar.batch.scan.report.JsonReport;
 import org.sonar.batch.scan2.AnalyzerOptimizer;
 import org.sonar.core.component.ScanPerspectives;
@@ -80,7 +107,6 @@ public class ModuleScanContainer extends ComponentContainer {
     ProjectDefinition moduleDefinition = getComponentByType(ProjectTree.class).getProjectDefinition(module);
     add(
       moduleDefinition,
-      module.getConfiguration(),
       module,
       ModuleSettings.class);
 
index 72063cc1541011f75f11d863b60bdebbc59772ae..f7c2d9fa27d7458cfd5f445ec102a01f211165ff 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.batch.scan;
 
 import com.google.common.collect.Lists;
-import org.apache.commons.configuration.Configuration;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
@@ -30,8 +29,6 @@ import org.sonar.batch.bootstrap.AnalysisMode;
 import org.sonar.batch.bootstrap.GlobalSettings;
 import org.sonar.batch.protocol.input.ProjectReferentials;
 
-import javax.annotation.Nullable;
-
 import java.util.List;
 
 /**
@@ -39,11 +36,10 @@ import java.util.List;
  */
 public class ModuleSettings extends Settings {
 
-  private final Configuration deprecatedCommonsConf;
   private final ProjectReferentials projectReferentials;
   private AnalysisMode analysisMode;
 
-  public ModuleSettings(GlobalSettings batchSettings, ProjectDefinition project, Configuration deprecatedCommonsConf, ProjectReferentials projectReferentials,
+  public ModuleSettings(GlobalSettings batchSettings, ProjectDefinition project, ProjectReferentials projectReferentials,
     AnalysisMode analysisMode) {
     super(batchSettings.getDefinitions());
     this.projectReferentials = projectReferentials;
@@ -51,7 +47,6 @@ public class ModuleSettings extends Settings {
     getEncryption().setPathToSecretKey(batchSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 
     LoggerFactory.getLogger(ModuleSettings.class).info("Load module settings");
-    this.deprecatedCommonsConf = deprecatedCommonsConf;
     init(project, batchSettings);
   }
 
@@ -86,21 +81,6 @@ public class ModuleSettings extends Settings {
     return result;
   }
 
-  @Override
-  protected void doOnSetProperty(String key, @Nullable String value) {
-    deprecatedCommonsConf.setProperty(key, value);
-  }
-
-  @Override
-  protected void doOnRemoveProperty(String key) {
-    deprecatedCommonsConf.clearProperty(key);
-  }
-
-  @Override
-  protected void doOnClearProperties() {
-    deprecatedCommonsConf.clear();
-  }
-
   @Override
   protected void doOnGetProperties(String key) {
     if (analysisMode.isPreview() && key.endsWith(".secured") && !key.contains(".license")) {
index e404ad075270c6597ad7dc844d8583e6c3a91b4c..c2749ba0099a83eb2b023d0a728eae1d523c795a 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.batch.scan;
 
-import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
@@ -31,26 +30,21 @@ import org.sonar.batch.bootstrap.AnalysisMode;
 import org.sonar.batch.bootstrap.GlobalSettings;
 import org.sonar.batch.protocol.input.ProjectReferentials;
 
-import javax.annotation.Nullable;
-
 public class ProjectSettings extends Settings {
 
   private static final Logger LOG = LoggerFactory.getLogger(ProjectSettings.class);
 
-  private Configuration deprecatedConfiguration;
-
   private final GlobalSettings globalSettings;
   private final ProjectReferentials projectReferentials;
   private final AnalysisMode mode;
 
   public ProjectSettings(ProjectReactor reactor, GlobalSettings globalSettings, PropertyDefinitions propertyDefinitions,
-    ProjectReferentials projectReferentials, Configuration deprecatedConfiguration, AnalysisMode mode) {
+    ProjectReferentials projectReferentials, AnalysisMode mode) {
     super(propertyDefinitions);
     this.mode = mode;
     getEncryption().setPathToSecretKey(globalSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
     this.globalSettings = globalSettings;
     this.projectReferentials = projectReferentials;
-    this.deprecatedConfiguration = deprecatedConfiguration;
     init(reactor);
   }
 
@@ -64,21 +58,6 @@ public class ProjectSettings extends Settings {
     addProperties(reactor.getRoot().getProperties());
   }
 
-  @Override
-  protected void doOnSetProperty(String key, @Nullable String value) {
-    deprecatedConfiguration.setProperty(key, value);
-  }
-
-  @Override
-  protected void doOnRemoveProperty(String key) {
-    deprecatedConfiguration.clearProperty(key);
-  }
-
-  @Override
-  protected void doOnClearProperties() {
-    deprecatedConfiguration.clear();
-  }
-
   @Override
   protected void doOnGetProperties(String key) {
     if (mode.isPreview() && key.endsWith(".secured") && !key.contains(".license")) {
index 34bd571d7ce2a4635f9576c1e3e2770291bd78c5..da6d442ec39aadfdcc48f2d8736e62fd89ecf1c1 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.batch.bootstrap;
 
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -41,7 +39,6 @@ public class GlobalSettingsTest {
 
   GlobalReferentials globalRef;
   ProjectDefinition project = ProjectDefinition.create().setKey("struts");
-  Configuration deprecatedConf = new BaseConfiguration();
   BootstrapProperties bootstrapProps;
 
   private AnalysisMode mode;
@@ -57,7 +54,7 @@ public class GlobalSettingsTest {
   public void should_load_global_settings() {
     globalRef.globalSettings().put("sonar.cpd.cross", "true");
 
-    GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), globalRef, deprecatedConf, mode);
+    GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), globalRef, mode);
 
     assertThat(batchSettings.getBoolean("sonar.cpd.cross")).isTrue();
   }
index 95bfb40be3daaa1431b809f7f059055bb5c079bb..7f914256695c1189a5b7ad399e660edb8766438f 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.batch.components;
 
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentMatcher;
@@ -95,30 +93,6 @@ public class PastSnapshotFinderTest {
     assertThat(variationSnapshot.getProjectSnapshot(), not(nullValue()));
   }
 
-  @Test
-  public void should_find_with_configuration() {
-    Configuration conf = new BaseConfiguration();
-    conf.addProperty("sonar.timemachine.period1", "1.2");
-    conf.addProperty("sonar.timemachine.period2", "1.2");
-    conf.addProperty("sonar.timemachine.period3", "1.2");
-    conf.addProperty("sonar.timemachine.period4", "1.2");
-    conf.addProperty("sonar.timemachine.period5", "1.2");
-
-    when(finderByVersion.findByVersion(null, "1.2")).thenReturn(new PastSnapshot("version", new Date(), new Snapshot()));
-
-    PastSnapshot variationSnapshot = finder.find(null, conf, 1);
-
-    verify(finderByVersion).findByVersion(null, "1.2");
-    assertThat(variationSnapshot.getIndex(), is(1));
-    assertThat(variationSnapshot.getMode(), is("version"));
-    assertThat(variationSnapshot.getProjectSnapshot(), not(nullValue()));
-
-    assertThat(finder.find(null, conf, 2).getIndex(), is(2));
-    assertThat(finder.find(null, conf, 3).getIndex(), is(3));
-    assertThat(finder.find(null, conf, 4).getIndex(), is(4));
-    assertThat(finder.find(null, conf, 5).getIndex(), is(5));
-  }
-
   @Test
   public void should_find_by_number_of_days() {
     when(finderByDays.findFromDays(null, 30)).thenReturn(new PastSnapshot("days", null).setModeParameter("30"));
@@ -144,7 +118,7 @@ public class PastSnapshotFinderTest {
   public void should_find_by_date() throws ParseException {
     final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
     final Date date = format.parse("2010-05-18");
-    when(finderByDate.findByDate((Snapshot)null, date)).thenReturn(new PastSnapshot("date", date, new Snapshot()));
+    when(finderByDate.findByDate((Snapshot) null, date)).thenReturn(new PastSnapshot("date", date, new Snapshot()));
 
     PastSnapshot variationSnapshot = finder.find(null, 2, "2010-05-18");
 
@@ -247,6 +221,6 @@ public class PastSnapshotFinderTest {
     Settings settings = new Settings().setProperty("sonar.timemachine.period1", "5");
 
     assertThat(PastSnapshotFinder.getPropertyValue("FIL", settings, 1), is("5"));
-    assertThat(PastSnapshotFinder.getPropertyValue("FIL",settings, 999), nullValue());
+    assertThat(PastSnapshotFinder.getPropertyValue("FIL", settings, 999), nullValue());
   }
 }
index c9ae930855ba763db24ba5289b0894804d2c9f3f..d90d4e1a24c5dca83e5acd73310bcea102f8e7a0 100644 (file)
  */
 package org.sonar.batch.index;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.Settings;
 import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.resources.Directory;
 import org.sonar.api.resources.File;
@@ -39,7 +40,10 @@ import static org.fest.assertions.Assertions.assertThat;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
 
@@ -210,15 +214,15 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
   }
 
   private static Project newProject(String key, String language) {
-    PropertiesConfiguration configuration = new PropertiesConfiguration();
-    configuration.setProperty("sonar.language", language);
-    return new Project(key).setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC);
+    Settings settings = new Settings();
+    settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, language);
+    return new Project(key).setSettings(settings).setAnalysisType(Project.AnalysisType.DYNAMIC);
   }
 
   private static Project newCopyProject(String key, String language, int copyResourceId) {
-    PropertiesConfiguration configuration = new PropertiesConfiguration();
-    configuration.setProperty("sonar.language", language);
-    return new CopyProject(key, copyResourceId).setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC);
+    Settings settings = new Settings();
+    settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, language);
+    return new CopyProject(key, copyResourceId).setSettings(settings).setAnalysisType(Project.AnalysisType.DYNAMIC);
   }
 
   private static class CopyProject extends Project implements ResourceCopy {
index d3710e6448853141f66926f26347a3c48ff7cd16..e91b5596101599ba4cbf3ce4a23ef4fcaca14c76 100644 (file)
  */
 package org.sonar.batch.index;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.slf4j.Logger;
+import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.config.Settings;
 import org.sonar.api.resources.Project;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
@@ -114,9 +115,9 @@ public class ResourceKeyMigrationTest extends AbstractDbUnitTestCase {
   }
 
   private static Project newProject(String key, String language) {
-    PropertiesConfiguration configuration = new PropertiesConfiguration();
-    configuration.setProperty("sonar.language", language);
-    return new Project(key).setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC);
+    Settings settings = new Settings();
+    settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, language);
+    return new Project(key).setSettings(settings).setAnalysisType(Project.AnalysisType.DYNAMIC);
   }
 
 }
index 3bbed76aa17721397eaf3b098703c68f31475d6f..a7a12f16e2c014625e65b305c447e49ead3b892e 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonar.batch.scan;
 
 import com.google.common.collect.ImmutableMap;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -78,17 +76,13 @@ public class ModuleSettingsTest {
     projectRef.addSettings("struts-core", ImmutableMap.of("on-module", "true", "overridding", "module"));
 
     ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-    Configuration deprecatedConf = new PropertiesConfiguration();
 
-    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, deprecatedConf, projectRef, mode);
+    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, projectRef, mode);
 
     assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
     assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
     assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
 
-    assertThat(deprecatedConf.getString("overridding")).isEqualTo("module");
-    assertThat(deprecatedConf.getString("on-batch")).isEqualTo("true");
-    assertThat(deprecatedConf.getString("on-module")).isEqualTo("true");
   }
 
   @Test
@@ -101,9 +95,8 @@ public class ModuleSettingsTest {
     projectRef.addSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
 
     ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-    Configuration deprecatedConf = new PropertiesConfiguration();
 
-    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, deprecatedConf, projectRef, mode);
+    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, projectRef, mode);
 
     assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
     assertThat(moduleSettings.getString("sonar.foo.secured")).isEqualTo("bar");
@@ -121,9 +114,8 @@ public class ModuleSettingsTest {
     when(mode.isPreview()).thenReturn(true);
 
     ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
-    Configuration deprecatedConf = new PropertiesConfiguration();
 
-    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, deprecatedConf, projectRef, mode);
+    ModuleSettings moduleSettings = new ModuleSettings(batchSettings, module, projectRef, mode);
 
     assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
 
index c40d9456ce3e555494edaceccf402a698f6c8eaa..a66f7f1378f04be4f0cb5a3f643794a0efca10f7 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.batch.scan;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.BatchExtension;
@@ -69,9 +68,8 @@ public class ProjectScanContainerTest {
     parentContainer.add(System2.INSTANCE);
     parentContainer.add(bootstrapProperties);
     parentContainer.add(analysisMode);
-    parentContainer.add(new PropertiesConfiguration());
     GlobalReferentials globalRef = new GlobalReferentials();
-    settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), globalRef, new PropertiesConfiguration(), analysisMode);
+    settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), globalRef, analysisMode);
     parentContainer.add(settings);
     ProjectReferentialsLoader projectReferentialsLoader = new ProjectReferentialsLoader() {
       @Override
index 4f7726f6695a87f433f7b9e05da2d24d1d1130a6..8cede90928b4861fbf51fa73e7595ae52cd297d1 100644 (file)
@@ -20,8 +20,6 @@
 package org.sonar.batch.scan;
 
 import com.google.common.collect.ImmutableMap;
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -50,7 +48,6 @@ public class ProjectSettingsTest {
 
   ProjectReferentials projectRef;
   ProjectDefinition project = ProjectDefinition.create().setKey("struts");
-  Configuration deprecatedConf = new BaseConfiguration();
   GlobalSettings bootstrapProps;
 
   private AnalysisMode mode;
@@ -59,14 +56,14 @@ public class ProjectSettingsTest {
   public void prepare() {
     projectRef = new ProjectReferentials();
     mode = mock(AnalysisMode.class);
-    bootstrapProps = new GlobalSettings(new BootstrapProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), new GlobalReferentials(), deprecatedConf, mode);
+    bootstrapProps = new GlobalSettings(new BootstrapProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), new GlobalReferentials(), mode);
   }
 
   @Test
   public void should_load_project_props() {
     project.setProperty("project.prop", "project");
 
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, deprecatedConf, mode);
+    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, mode);
 
     assertThat(batchSettings.getString("project.prop")).isEqualTo("project");
   }
@@ -75,7 +72,7 @@ public class ProjectSettingsTest {
   public void should_load_project_root_settings() {
     projectRef.addSettings("struts", ImmutableMap.of("sonar.cpd.cross", "true", "sonar.java.coveragePlugin", "jacoco"));
 
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, deprecatedConf, mode);
+    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, mode);
 
     assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
   }
@@ -86,7 +83,7 @@ public class ProjectSettingsTest {
 
     projectRef.addSettings("struts:mybranch", ImmutableMap.of("sonar.cpd.cross", "true", "sonar.java.coveragePlugin", "jacoco"));
 
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, deprecatedConf, mode);
+    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, mode);
 
     assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
   }
@@ -95,7 +92,7 @@ public class ProjectSettingsTest {
   public void should_not_fail_when_accessing_secured_properties() {
     projectRef.addSettings("struts", ImmutableMap.of("sonar.foo.secured", "bar", "sonar.foo.license.secured", "bar2"));
 
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, deprecatedConf, mode);
+    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, mode);
 
     assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
     assertThat(batchSettings.getString("sonar.foo.secured")).isEqualTo("bar");
@@ -107,7 +104,7 @@ public class ProjectSettingsTest {
 
     when(mode.isPreview()).thenReturn(true);
 
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, deprecatedConf, mode);
+    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, mode);
 
     assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
     thrown.expect(MessageException.class);
@@ -116,22 +113,4 @@ public class ProjectSettingsTest {
     batchSettings.getString("sonar.foo.secured");
   }
 
-  @Test
-  public void should_forward_to_deprecated_commons_configuration() {
-    projectRef.addSettings("struts", ImmutableMap.of("sonar.cpd.cross", "true", "sonar.java.coveragePlugin", "jacoco"));
-
-    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, deprecatedConf, mode);
-
-    assertThat(deprecatedConf.getString("sonar.cpd.cross")).isEqualTo("true");
-    assertThat(deprecatedConf.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
-
-    batchSettings.removeProperty("sonar.cpd.cross");
-    assertThat(deprecatedConf.getString("sonar.cpd.cross")).isNull();
-    assertThat(deprecatedConf.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
-
-    batchSettings.clear();
-    assertThat(deprecatedConf.getString("sonar.cpd.cross")).isNull();
-    assertThat(deprecatedConf.getString("sonar.java.coveragePlugin")).isNull();
-  }
-
 }
diff --git a/sonar-core/src/main/java/org/sonar/api/database/configuration/DatabaseConfiguration.java b/sonar-core/src/main/java/org/sonar/api/database/configuration/DatabaseConfiguration.java
deleted file mode 100644 (file)
index c166319..0000000
+++ /dev/null
@@ -1,75 +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.api.database.configuration;
-
-import org.apache.commons.configuration.BaseConfiguration;
-import org.sonar.api.database.DatabaseSession;
-import org.sonar.jpa.session.DatabaseSessionFactory;
-
-import java.util.List;
-
-/**
- * IMPORTANT : This class can't be moved to org.sonar.jpa.dao for backward-compatibility reasons.
- * This class is still used in some plugins.
- *
- * @since 1.10
- * @deprecated in 3.7. Replaced by {@link org.sonar.api.config.Settings}
- */
-@Deprecated
-public class DatabaseConfiguration extends BaseConfiguration {
-  private DatabaseSessionFactory sessionFactory;
-  private DatabaseSession session;
-
-  public DatabaseConfiguration(DatabaseSessionFactory sessionFactory) {
-    this.sessionFactory = sessionFactory;
-    load();
-  }
-
-  public DatabaseConfiguration(DatabaseSession session) {
-    this.session = session;
-    load();
-  }
-
-  public final void load() {
-    clear();
-
-    // Ugly workaround before the move to myBatis
-    // Session is not up-to-date when Ruby on Rails inserts new rows in its own transaction. Seems like
-    // Hibernate keeps a cache...
-    getSession().commit();
-
-    List<Property> properties = getSession()
-      .createQuery("from " + Property.class.getSimpleName() + " p where p.resourceId is null and p.userId is null")
-      .getResultList();
-
-    if (properties != null) {
-      for (Property property : properties) {
-        setProperty(property.getKey(), property.getValue());
-      }
-    }
-  }
-
-  private DatabaseSession getSession() {
-    if (session != null) {
-      return session;
-    }
-    return sessionFactory.getSession();
-  }
-}
index 59d7a9ceda379258e5eb8e2fc5329cdfeee5efce..568e97b35d7f82455bf83a11676f608d2bdcf588 100644 (file)
@@ -33,7 +33,9 @@ import javax.persistence.Table;
  * This class is still used in some plugins.
  *
  * @since 1.10
+ * @deprecated since 5.0 Hibernate is deprecated
  */
+@Deprecated
 @Entity
 @Table(name = "properties")
 public class Property extends BaseIdentifiable {
diff --git a/sonar-core/src/test/java/org/sonar/api/database/configuration/DatabaseConfigurationTest.java b/sonar-core/src/test/java/org/sonar/api/database/configuration/DatabaseConfigurationTest.java
deleted file mode 100644 (file)
index e6c11e0..0000000
+++ /dev/null
@@ -1,40 +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.api.database.configuration;
-
-import org.junit.Test;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-public class DatabaseConfigurationTest extends AbstractDbUnitTestCase {
-
-  @Test
-  public void shouldLoadPropertiesFromDatabase() {
-    setupData("some-properties");
-
-    DatabaseConfiguration configuration = new DatabaseConfiguration(getSessionFactory());
-
-    assertEquals("value1", configuration.getString("key1"));
-    assertEquals("value2", configuration.getString("key2"));
-    assertNull(configuration.getString("keyxxxx"));
-  }
-}
index b754732e01b3d64795df662a102a29b37a271adb..d852edd82d6314b418f55b187718c956015cc981 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.api.resources;
 
 import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
 
 import java.util.Collection;
 import java.util.List;
@@ -36,24 +35,6 @@ public final class ProjectUtils {
     // utility class with only static methods
   }
 
-  /**
-   * @deprecated since 2.6 use JavaUtils.getTargetVersion() instead.
-   */
-  @Deprecated
-  public static String getJavaVersion(Project project) {
-    String version = project.getConfiguration() != null ? project.getConfiguration().getString("sonar.java.target") : null;
-    return StringUtils.isNotBlank(version) ? version : "1.5";
-  }
-
-  /**
-   * @deprecated since 2.6 use JavaUtils.getSourceVersion() instead.
-   */
-  @Deprecated
-  public static String getJavaSourceVersion(Project project) {
-    String version = project.getConfiguration() != null ? project.getConfiguration().getString("sonar.java.source") : null;
-    return StringUtils.isNotBlank(version) ? version : "1.5";
-  }
-
   /**
    * @since 2.7
    * @deprecated in 4.2. Replaced by org.sonar.api.resources.InputFileUtils#toFiles()
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java
deleted file mode 100644 (file)
index 45ee16d..0000000
+++ /dev/null
@@ -1,134 +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.api.utils;
-
-import com.google.common.collect.Maps;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.staxmate.in.SMHierarchicCursor;
-import org.codehaus.staxmate.in.SMInputCursor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoverageMeasuresBuilder;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Resource;
-
-import javax.xml.stream.XMLStreamException;
-
-import java.io.File;
-import java.text.ParseException;
-import java.util.Map;
-
-import static java.util.Locale.ENGLISH;
-import static org.sonar.api.utils.ParsingUtils.parseNumber;
-
-/**
- * @since 3.7
- * @deprecated in 4.2. This class should be handled internally by plugins
- */
-@Deprecated
-public class CoberturaReportParserUtils {
-
-  private CoberturaReportParserUtils() {
-  }
-
-  public interface FileResolver {
-
-    /**
-     * Return a SonarQube file resource from a filename present in Cobertura report
-     */
-    Resource resolve(String filename);
-  }
-
-  /**
-   * Parse a Cobertura xml report and create measures accordingly
-   */
-  public static void parseReport(File xmlFile, final SensorContext context, final FileResolver fileResolver) {
-    try {
-      StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {
-
-        public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
-          rootCursor.advance();
-          collectPackageMeasures(rootCursor.descendantElementCursor("package"), context, fileResolver);
-        }
-      });
-      parser.parse(xmlFile);
-    } catch (XMLStreamException e) {
-      throw new XmlParserException(e);
-    }
-  }
-
-  private static void collectPackageMeasures(SMInputCursor pack, SensorContext context, final FileResolver fileResolver) throws XMLStreamException {
-    while (pack.getNext() != null) {
-      Map<String, CoverageMeasuresBuilder> builderByFilename = Maps.newHashMap();
-      collectFileMeasures(pack.descendantElementCursor("class"), builderByFilename);
-      for (Map.Entry<String, CoverageMeasuresBuilder> entry : builderByFilename.entrySet()) {
-        String filename = sanitizeFilename(entry.getKey());
-        Resource file = fileResolver.resolve(filename);
-        if (fileExists(context, file)) {
-          for (Measure measure : entry.getValue().createMeasures()) {
-            context.saveMeasure(file, measure);
-          }
-        }
-      }
-    }
-  }
-
-  private static boolean fileExists(SensorContext context, Resource file) {
-    return context.getResource(file) != null;
-  }
-
-  private static void collectFileMeasures(SMInputCursor clazz, Map<String, CoverageMeasuresBuilder> builderByFilename) throws XMLStreamException {
-    while (clazz.getNext() != null) {
-      String fileName = clazz.getAttrValue("filename");
-      CoverageMeasuresBuilder builder = builderByFilename.get(fileName);
-      if (builder == null) {
-        builder = CoverageMeasuresBuilder.create();
-        builderByFilename.put(fileName, builder);
-      }
-      collectFileData(clazz, builder);
-    }
-  }
-
-  private static void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builder) throws XMLStreamException {
-    SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");
-    while (line.getNext() != null) {
-      int lineId = Integer.parseInt(line.getAttrValue("number"));
-      try {
-        builder.setHits(lineId, (int) parseNumber(line.getAttrValue("hits"), ENGLISH));
-      } catch (ParseException e) {
-        throw new XmlParserException(e);
-      }
-
-      String isBranch = line.getAttrValue("branch");
-      String text = line.getAttrValue("condition-coverage");
-      if (StringUtils.equals(isBranch, "true") && StringUtils.isNotBlank(text)) {
-        String[] conditions = StringUtils.split(StringUtils.substringBetween(text, "(", ")"), "/");
-        builder.setConditions(lineId, Integer.parseInt(conditions[1]), Integer.parseInt(conditions[0]));
-      }
-    }
-  }
-
-  private static String sanitizeFilename(String s) {
-    String fileName = FilenameUtils.removeExtension(s);
-    fileName = fileName.replace('/', '.').replace('\\', '.');
-    return fileName;
-  }
-
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java b/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java
deleted file mode 100644 (file)
index c653ea9..0000000
+++ /dev/null
@@ -1,47 +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.cobertura.api;
-
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.utils.CoberturaReportParserUtils;
-import org.sonar.api.utils.CoberturaReportParserUtils.FileResolver;
-
-import java.io.File;
-
-/**
- * @since 2.4
- * @deprecated since 3.7 Used to keep backward compatibility since extraction
- * of Cobertura plugin.
- */
-@Deprecated
-public abstract class AbstractCoberturaParser {
-
-  public void parseReport(File xmlFile, final SensorContext context) {
-    CoberturaReportParserUtils.parseReport(xmlFile, context, new FileResolver() {
-      @Override
-      public Resource resolve(String filename) {
-        return getResource(filename);
-      }
-    });
-  }
-
-  protected abstract Resource getResource(String fileName);
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java b/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
deleted file mode 100644 (file)
index e1baa0d..0000000
+++ /dev/null
@@ -1,89 +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.cobertura.api;
-
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenUtils;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.Logs;
-
-import java.io.File;
-
-/**
- * @since 2.4
- * @deprecated since 3.7 Used to keep backward compatibility since extraction
- * of Cobertura plugin. Should be duplicated in each project.
- */
-@Deprecated
-public final class CoberturaUtils {
-
-  public static final String COBERTURA_GROUP_ID = MavenUtils.GROUP_ID_CODEHAUS_MOJO;
-  public static final String COBERTURA_ARTIFACT_ID = "cobertura-maven-plugin";
-  public static final String COBERTURA_REPORT_PATH_PROPERTY = "sonar.cobertura.reportPath";
-
-  /**
-   * @deprecated in 2.8, because assumes that Sonar executed from Maven. Not used any more in sonar-cobertura-plugin.
-   *             See http://jira.codehaus.org/browse/SONAR-2321
-   *             Used in groovy and flex plugins.
-   */
-  @Deprecated
-  public static File getReport(Project project) {
-    File report = getReportFromProperty(project);
-    if (report == null) {
-      report = getReportFromPluginConfiguration(project);
-    }
-    if (report == null) {
-      report = getReportFromDefaultPath(project);
-    }
-
-    if (report == null || !report.exists() || !report.isFile()) {
-      Logs.INFO.warn("Cobertura report not found at {}", report);
-      report = null;
-    }
-    return report;
-  }
-
-  private static File getReportFromProperty(Project project) {
-    String path = (String) project.getProperty(COBERTURA_REPORT_PATH_PROPERTY);
-    if (path != null) {
-      return project.getFileSystem().resolvePath(path);
-    }
-    return null;
-  }
-
-  private static File getReportFromPluginConfiguration(Project project) {
-    MavenPlugin mavenPlugin = MavenPlugin.getPlugin(project.getPom(), COBERTURA_GROUP_ID, COBERTURA_ARTIFACT_ID);
-    if (mavenPlugin != null) {
-      String path = mavenPlugin.getParameter("outputDirectory");
-      if (path != null) {
-        return new File(project.getFileSystem().resolvePath(path), "coverage.xml");
-      }
-    }
-    return null;
-  }
-
-  private static File getReportFromDefaultPath(Project project) {
-    return new File(project.getFileSystem().getReportOutputDir(), "cobertura/coverage.xml");
-  }
-
-  private CoberturaUtils() {
-  }
-
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
deleted file mode 100644 (file)
index 60b63e8..0000000
+++ /dev/null
@@ -1,227 +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.api.utils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.JavaPackage;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.Scopes;
-import org.sonar.api.test.IsMeasure;
-import org.sonar.api.test.IsResource;
-import org.sonar.api.utils.CoberturaReportParserUtils.FileResolver;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.Matchers.is;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class CoberturaReportParserUtilsTest {
-
-  private SensorContext context;
-
-  @Before
-  public void setUp() {
-    context = mock(SensorContext.class);
-  }
-
-  private static FileResolver JAVA_FILE_RESOLVER = new FileResolver() {
-
-    @Override
-    public Resource resolve(String filename) {
-      return new org.sonar.api.resources.File(filename);
-    }
-  };
-
-  @Test
-  public void doNotCollectProjectCoverage() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.COVERAGE), anyDouble());
-  }
-
-  @Test
-  public void doNotCollectProjectLineCoverage() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.LINE_COVERAGE), anyDouble());
-    verify(context, never()).saveMeasure(argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA)));
-  }
-
-  @Test
-  public void doNotCollectProjectBranchCoverage() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    verify(context, never()).saveMeasure(eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
-  }
-
-  @Test
-  public void collectPackageLineCoverage() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.LINE_COVERAGE), anyDouble());
-    verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.UNCOVERED_LINES), anyDouble());
-  }
-
-  @Test
-  public void collectPackageBranchCoverage() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.BRANCH_COVERAGE), anyDouble());
-    verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.UNCOVERED_CONDITIONS), anyDouble());
-  }
-
-  @Test
-  public void packageCoverageIsCalculatedLaterByDecorator() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    verify(context, never()).saveMeasure((Resource) argThat(is(JavaPackage.class)), eq(CoreMetrics.COVERAGE), anyDouble());
-  }
-
-  @Test
-  public void collectFileLineCoverage() throws URISyntaxException {
-    when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    final org.sonar.api.resources.File file = new org.sonar.api.resources.File("org.apache.commons.chain.config.ConfigParser");
-    verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 30.0)));
-    verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 5.0)));
-  }
-
-  @Test
-  public void collectFileBranchCoverage() throws URISyntaxException {
-    when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    final org.sonar.api.resources.File file = new org.sonar.api.resources.File("org.apache.commons.chain.config.ConfigParser");
-    verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 6.0)));
-    verify(context).saveMeasure(eq(file), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 2.0)));
-  }
-
-  @Test
-  public void testDoNotSaveMeasureOnResourceWhichDoesntExistInTheContext() throws URISyntaxException {
-    when(context.getResource(any(Resource.class))).thenReturn(null);
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-    verify(context, never()).saveMeasure(any(Resource.class), any(Measure.class));
-  }
-
-  @Test
-  public void javaInterfaceHasNoCoverage() throws URISyntaxException {
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-
-    final org.sonar.api.resources.File interfaze = new org.sonar.api.resources.File("org.apache.commons.chain.Chain");
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.COVERAGE)));
-
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.LINE_COVERAGE)));
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
-
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.BRANCH_COVERAGE)));
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
-    verify(context, never()).saveMeasure(eq(interfaze), argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
-  }
-
-  @Test
-  public void shouldInsertCoverageAtFileLevel() throws URISyntaxException {
-    File coverage = new File(getClass().getResource(
-      "/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldInsertCoverageAtFileLevel/coverage.xml").toURI());
-    when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
-    CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
-
-    verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
-      argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 35.0)));
-    verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
-      argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES, 22.0)));
-
-    verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
-      argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER, 4.0)));
-    verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass")),
-      argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS, 3.0)));
-
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
-      argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
-      argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
-      argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.InnerClass$InnerClassInside")),
-      argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
-
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
-      argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER)));
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
-      argThat(new IsMeasure(CoreMetrics.CONDITIONS_TO_COVER)));
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
-      argThat(new IsMeasure(CoreMetrics.UNCOVERED_CONDITIONS)));
-    verify(context, never()).saveMeasure(
-      argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.PrivateClass")),
-      argThat(new IsMeasure(CoreMetrics.UNCOVERED_LINES)));
-
-    verify(context)
-      .saveMeasure(
-        eq(new org.sonar.api.resources.File("org.sonar.samples.InnerClass")),
-        argThat(new IsMeasure(
-          CoreMetrics.COVERAGE_LINE_HITS_DATA,
-          "22=2;25=0;26=0;29=0;30=0;31=0;34=1;35=1;36=1;37=0;39=1;41=1;44=2;46=1;47=1;50=0;51=0;52=0;53=0;55=0;57=0;60=0;61=0;64=1;71=1;73=1;76=0;77=0;80=0;81=0;85=0;87=0;91=0;93=0;96=1")));
-  }
-
-  @Test
-  public void collectFileLineHitsData() throws URISyntaxException {
-    when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.MyClass"));
-    CoberturaReportParserUtils.parseReport(getCoverageReport(), context, JAVA_FILE_RESOLVER);
-    verify(context).saveMeasure(
-      eq(new org.sonar.api.resources.File("org.apache.commons.chain.impl.CatalogBase")),
-      argThat(new IsMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA,
-        "48=117;56=234;66=0;67=0;68=0;84=999;86=999;98=318;111=18;121=0;122=0;125=0;126=0;127=0;128=0;131=0;133=0")));
-  }
-
-  @Test
-  public void shouldNotCountTwiceAnonymousClasses() throws URISyntaxException {
-    File coverage = new File(getClass().getResource("/org/sonar/api/utils/CoberturaReportParserUtilsTest/shouldNotCountTwiceAnonymousClasses.xml").toURI());
-    when(context.getResource(any(Resource.class))).thenReturn(new org.sonar.api.resources.File("org.sonar.samples.MyClass"));
-    CoberturaReportParserUtils.parseReport(coverage, context, JAVA_FILE_RESOLVER);
-
-    verify(context).saveMeasure(argThat(new IsResource(Scopes.FILE, Qualifiers.FILE, "org.sonar.samples.MyFile")),
-      argThat(new IsMeasure(CoreMetrics.LINES_TO_COVER, 5.0))); // do not count line 26 twice
-  }
-
-  private File getCoverageReport() throws URISyntaxException {
-    return new File(getClass().getResource("/org/sonar/api/utils/CoberturaReportParserUtilsTest/commons-chain-coverage.xml").toURI());
-  }
-}
diff --git a/sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java
deleted file mode 100644 (file)
index f8f1348..0000000
+++ /dev/null
@@ -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.plugins.cobertura.api;
-
-import org.apache.maven.project.MavenProject;
-import org.junit.Test;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectFileSystem;
-import org.sonar.api.test.MavenTestUtils;
-
-import java.io.File;
-import java.net.URISyntaxException;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class CoberturaUtilsTest {
-  @Test
-  public void shouldGetReportPathFromProperty() throws URISyntaxException {
-    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
-    when(fileSystem.resolvePath("foo")).thenReturn(getCoverageReport());
-
-    Project project = mock(Project.class);
-    when(project.getFileSystem()).thenReturn(fileSystem);
-    when(project.getProperty(CoberturaUtils.COBERTURA_REPORT_PATH_PROPERTY)).thenReturn("foo");
-
-    File report = CoberturaUtils.getReport(project);
-    verify(fileSystem).resolvePath("foo");
-    assertNotNull(report);
-  }
-
-  @Test
-  public void shouldGetReportPathFromPom() {
-    MavenProject pom = MavenTestUtils.loadPom("/org/sonar/plugins/cobertura/CoberturaSensorTest/shouldGetReportPathFromPom/pom.xml");
-
-    ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
-
-    Project project = mock(Project.class);
-    when(project.getPom()).thenReturn(pom);
-    when(project.getFileSystem()).thenReturn(fileSystem);
-
-    CoberturaUtils.getReport(project);
-
-    verify(fileSystem).resolvePath("overridden/dir");
-  }
-
-  private File getCoverageReport() throws URISyntaxException {
-    return new File(getClass().getResource("/org/sonar/plugins/cobertura/CoberturaSensorTest/commons-chain-coverage.xml").toURI());
-  }
-}
index 7c18701b2f2a5ae2177fcc9ba97859cf16a5eb44..321e44fbc93410c325f7c34c7a3953d0f5573e5b 100644 (file)
       <groupId>org.codehaus.sonar</groupId>
       <artifactId>sonar-deprecated</artifactId>
     </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
 
     <!-- unit tests -->
     <dependency>
index fd8c163ef6d6a26356888f8e212bb8d0a95f3a03..53596792273bb09eb33992162eaf2dae1531939d 100644 (file)
@@ -80,12 +80,12 @@ public final class JavaUtils {
   }
 
   public static String getSourceVersion(Project project) {
-    String version = project.getConfiguration() != null ? project.getConfiguration().getString(JAVA_SOURCE_PROPERTY) : null;
+    String version = project.getSettings() != null ? project.getSettings().getString(JAVA_SOURCE_PROPERTY) : null;
     return StringUtils.isNotBlank(version) ? version : JAVA_SOURCE_DEFAULT_VALUE;
   }
 
   public static String getTargetVersion(Project project) {
-    String version = project.getConfiguration() != null ? project.getConfiguration().getString(JAVA_TARGET_PROPERTY) : null;
+    String version = project.getSettings() != null ? project.getSettings().getString(JAVA_TARGET_PROPERTY) : null;
     return StringUtils.isNotBlank(version) ? version : JAVA_TARGET_DEFAULT_VALUE;
   }
 }
index 5ec3d97a2a414f63ae2e24e1009aa346053e28d5..1c2eb29753b925ebd19915a7cee5b8fcbdccb4f4 100644 (file)
  */
 package org.sonar.java.api;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.apache.commons.configuration.BaseConfiguration;
 import org.junit.Test;
+import org.sonar.api.config.Settings;
 import org.sonar.api.resources.Project;
 
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
 public class JavaUtilsTest {
 
   @Test
@@ -41,8 +41,8 @@ public class JavaUtilsTest {
 
   @Test
   public void shouldReturnDefaultJavaVersion() {
-    BaseConfiguration configuration = new BaseConfiguration();
-    Project project = new Project("").setConfiguration(configuration);
+    Settings configuration = new Settings();
+    Project project = new Project("").setSettings(configuration);
 
     assertThat(JavaUtils.getSourceVersion(project), is("1.5"));
     assertThat(JavaUtils.getTargetVersion(project), is("1.5"));
@@ -50,8 +50,8 @@ public class JavaUtilsTest {
 
   @Test
   public void shouldReturnSpecifiedJavaVersion() {
-    BaseConfiguration configuration = new BaseConfiguration();
-    Project project = new Project("").setConfiguration(configuration);
+    Settings configuration = new Settings();
+    Project project = new Project("").setSettings(configuration);
     configuration.setProperty(JavaUtils.JAVA_SOURCE_PROPERTY, "1.4");
     configuration.setProperty(JavaUtils.JAVA_TARGET_PROPERTY, "1.6");
 
index 9dd9d2799428ea1217da3a27cf78ee9a7b68f888..06f98e88d24bd908fcafe881bef64bf18f0ea937 100644 (file)
       <scope>provided</scope>
     </dependency>
 
-    <dependency>
-      <groupId>commons-configuration</groupId>
-      <artifactId>commons-configuration</artifactId>
-    </dependency>
     <dependency>
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
     </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+    </dependency>
     <dependency>
       <groupId>jfree</groupId>
       <artifactId>jfreechart</artifactId>
index c226befb1b5bdfd64454e5101276402ec8f6bf4f..c1565281ef177c81b523dbf854bd389db8c37e0b 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.api.batch;
 
-import org.apache.commons.configuration.Configuration;
 import org.sonar.api.measures.FormulaContext;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.resources.Resource;
@@ -44,14 +43,6 @@ public class DefaultFormulaContext implements FormulaContext {
     return decoratorContext.getResource();
   }
 
-  /**
-   * @deprecated in 3.7. Use {@link org.sonar.api.config.Settings}.
-   */
-  @Deprecated
-  public Configuration getConfiguration() {
-    return decoratorContext.getProject().getConfiguration();
-  }
-
   public void setMetric(Metric metric) {
     this.metric = metric;
   }
index 59a375cad0023235c3e4923bb4b15d1e2dcf2312..b3c2fcb524b89325485e11fc414990f110bf3720 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.api.measures;
 
-import org.apache.commons.configuration.Configuration;
 import org.sonar.api.resources.Resource;
 
 /**
@@ -31,10 +30,4 @@ public interface FormulaContext {
 
   Resource getResource();
 
-  /**
-   * @deprecated in 3.7. Use {@link org.sonar.api.config.Settings}.
-   */
-  @Deprecated
-  Configuration getConfiguration();
-
 }
index ac26bc0052122c06832104d0b24ea0fe4bf900bd..daf6a1e12d7556c373ac1a2b5798dcffc7e82c42 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.api.ServerComponent;
 import org.sonar.api.config.PropertyDefinitions;
 
 import javax.annotation.Nullable;
+
 import java.util.Collection;
 import java.util.List;
 
@@ -122,7 +123,6 @@ public class ComponentContainer implements BatchComponent, ServerComponent {
     try {
       pico.stop();
 
-
     } catch (RuntimeException e) {
       if (!swallowException) {
         throw PicoUtils.propagate(e);
@@ -180,11 +180,22 @@ public class ComponentContainer implements BatchComponent, ServerComponent {
 
   public ComponentContainer addExtension(@Nullable PluginMetadata plugin, Object extension) {
     Object key = componentKeys.of(extension);
-    pico.as(Characteristics.CACHE).addComponent(key, extension);
+    try {
+      pico.as(Characteristics.CACHE).addComponent(key, extension);
+    } catch (Throwable t) {
+      throw new IllegalStateException("Unable to register extension " + getName(extension), t);
+    }
     declareExtension(plugin, extension);
     return this;
   }
 
+  private String getName(Object extension) {
+    if (extension instanceof Class) {
+      return ((Class) extension).getName();
+    }
+    return getName(extension.getClass());
+  }
+
   public void declareExtension(@Nullable PluginMetadata plugin, Object extension) {
     propertyDefinitions.addComponent(extension, plugin != null ? plugin.getName() : "");
   }
index 4355838c9e856ec761b89b1ad0c9248ddcf91a30..2bfe7ee4487b016bbc466c1c5d77100f2d29661f 100644 (file)
  */
 package org.sonar.api.resources;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.apache.commons.configuration.Configuration;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.maven.project.MavenProject;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.component.Component;
+import org.sonar.api.config.Settings;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -81,7 +79,6 @@ public class Project extends Resource implements Component {
   private MavenProject pom;
   private String branch;
   private ProjectFileSystem fileSystem;
-  private Configuration configuration;
   private String name;
   private String description;
   private String packaging;
@@ -89,6 +86,7 @@ public class Project extends Resource implements Component {
   private Date analysisDate;
   private AnalysisType analysisType;
   private String analysisVersion;
+  private Settings settings;
 
   // modules tree
   private Project parent;
@@ -269,7 +267,27 @@ public class Project extends Resource implements Component {
    */
   @Deprecated
   public String getLanguageKey() {
-    return configuration.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "");
+    if (settings == null) {
+      throw new IllegalStateException("Project is not yet initialized");
+    }
+    return StringUtils.defaultIfEmpty(settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY), "");
+  }
+
+  /**
+   * Internal use
+   */
+  public Project setSettings(Settings settings) {
+    this.settings = settings;
+    return this;
+  }
+
+  /**
+   * Internal use for backward compatibility. Settings should be retrieved as an IoC dependency.
+   * @deprecated since 5.0
+   */
+  @Deprecated
+  public Settings getSettings() {
+    return settings;
   }
 
   /**
@@ -341,15 +359,6 @@ public class Project extends Resource implements Component {
     return modules;
   }
 
-  /**
-   * @return whether to use external source for rules configuration
-   * @deprecated since 2.5. See discussion from http://jira.codehaus.org/browse/SONAR-1873
-   */
-  @Deprecated
-  public boolean getReuseExistingRulesConfig() {
-    return configuration != null && configuration.getBoolean(CoreProperties.REUSE_RULES_CONFIGURATION_PROPERTY, false);
-  }
-
   /**
    * @return the current version of the project
    */
@@ -364,51 +373,6 @@ public class Project extends Resource implements Component {
     return analysisDate;
   }
 
-  /**
-   * Patterns of resource exclusion as defined in project settings page.
-   *
-   * @since 3.3 also applies exclusions in general settings page and global exclusions.
-   * @deprecated replaced by {@link org.sonar.api.scan.filesystem.FileExclusions} in version 3.5
-   */
-  @Deprecated
-  public String[] getExclusionPatterns() {
-    return trimExclusions(ImmutableList.<String>builder()
-      .add(configuration.getStringArray(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY))
-      .add(configuration.getStringArray(CoreProperties.GLOBAL_EXCLUSIONS_PROPERTY)).build());
-  }
-
-  /**
-   * Patterns of test exclusion as defined in project settings page.
-   * Also applies exclusions in general settings page and global exclusions.
-   *
-   * @since 3.3
-   * @deprecated replaced by {@link org.sonar.api.scan.filesystem.FileExclusions} in version 3.5
-   */
-  @Deprecated
-  public String[] getTestExclusionPatterns() {
-    return trimExclusions(ImmutableList.<String>builder()
-      .add(configuration.getStringArray(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY))
-      .add(configuration.getStringArray(CoreProperties.GLOBAL_TEST_EXCLUSIONS_PROPERTY)).build());
-  }
-
-  // http://jira.codehaus.org/browse/SONAR-2261 - exclusion must be trimmed
-  private static String[] trimExclusions(List<String> exclusions) {
-    List<String> trimmed = Lists.newArrayList();
-    for (String exclusion : exclusions) {
-      trimmed.add(StringUtils.trim(exclusion));
-    }
-    return trimmed.toArray(new String[trimmed.size()]);
-  }
-
-  /**
-   * Set exclusion patterns. Configuration is not saved, so this method must be used ONLY IN UNIT TESTS.
-   * @deprecated replaced by {@link org.sonar.api.scan.filesystem.FileExclusions} in version 3.5
-   */
-  @Deprecated
-  public Project setExclusionPatterns(String[] s) {
-    throw new UnsupportedOperationException("deprecated in 3.5");
-  }
-
   /**
    * Note: it's better to get a reference on ProjectFileSystem as an IoC dependency (constructor parameter)
    * @deprecated replaced by {@link org.sonar.api.scan.filesystem.ModuleFileSystem} in 3.5
@@ -455,31 +419,6 @@ public class Project extends Resource implements Component {
     return pom;
   }
 
-  /**
-   * @return the project configuration
-   * @deprecated since 2.12. The component org.sonar.api.config.Settings must be used.
-   */
-  @Deprecated
-  public Configuration getConfiguration() {
-    return configuration;
-  }
-
-  /**
-   * For internal use only.
-   */
-  public final Project setConfiguration(Configuration configuration) {
-    this.configuration = configuration;
-    return this;
-  }
-
-  /**
-   * @deprecated since 3.6. Replaced by {@link org.sonar.api.config.Settings}.
-   */
-  @Deprecated
-  public Object getProperty(String key) {
-    return configuration != null ? configuration.getProperty(key) : null;
-  }
-
   public static Project createFromMavenIds(String groupId, String artifactId) {
     return new Project(String.format(MAVEN_KEY_FORMAT, groupId, artifactId));
   }
index 7417c61a3e55a7fe1d705f8e2a992ded4c388a4a..b9fe96e849cb8cedaa3fe3a7bc31b480420f6559 100644 (file)
  */
 package org.sonar.api.resources;
 
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.junit.Test;
-import org.sonar.api.CoreProperties;
 import org.sonar.api.test.MavenTestUtils;
 
 import static org.fest.assertions.Assertions.assertThat;
 
 public class ProjectTest {
-  PropertiesConfiguration conf = new PropertiesConfiguration();
 
   @Test
   public void equalsProject() {
@@ -51,47 +48,4 @@ public class ProjectTest {
     assertThat(project.getKey()).isEqualTo("my:artifact");
   }
 
-  /**
-   * See http://jira.codehaus.org/browse/SONAR-2261
-   * Note that several exclusions separated by comma would be correctly trimmed by commons-configuration library.
-   * So issue is only with a single pattern, which contains spaces.
-   */
-  @Test
-  public void shouldTrimExclusionPatterns() {
-    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "  **/*Foo.java   , **/Bar.java    ");
-    conf.setProperty(CoreProperties.GLOBAL_EXCLUSIONS_PROPERTY, "  **/*Test.java   ");
-
-    Project project = new Project("foo").setConfiguration(conf);
-    String[] exclusions = project.getExclusionPatterns();
-
-    assertThat(exclusions).containsOnly("**/*Foo.java", "**/Bar.java", "**/*Test.java");
-  }
-
-  @Test
-  public void testNoExclusionPatterns() {
-    Project project = new Project("key").setConfiguration(conf);
-
-    assertThat(project.getExclusionPatterns()).isEmpty();
-    assertThat(project.getTestExclusionPatterns()).isEmpty();
-  }
-
-  @Test
-  public void should_exclude_many_patterns() {
-    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*,foo,*/bar");
-    conf.setProperty(CoreProperties.GLOBAL_EXCLUSIONS_PROPERTY, "*/exclude");
-
-    Project project = new Project("key").setConfiguration(conf);
-
-    assertThat(project.getExclusionPatterns()).containsOnly("**/*", "foo", "*/bar", "*/exclude");
-  }
-
-  @Test
-  public void should_exclude_test_patterns() {
-    conf.setProperty(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY, "**/*Test.java, **/*IntegrationTest.java");
-    conf.setProperty(CoreProperties.GLOBAL_TEST_EXCLUSIONS_PROPERTY, "**/*FunctionalTest.java");
-
-    Project project = new Project("key").setConfiguration(conf);
-
-    assertThat(project.getTestExclusionPatterns()).containsOnly("**/*Test.java", "**/*IntegrationTest.java", "**/*FunctionalTest.java");
-  }
 }
index 52df195bed521214ff020b1cb0b755da9a41eb35..6050c140bb111d8e5e3847015f663dd00c80dc16 100644 (file)
  */
 package org.sonar.api.test;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.MapConfiguration;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.project.MavenProject;
-import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.maven.MavenUtils;
 import org.sonar.api.resources.InputFile;
 import org.sonar.api.resources.Language;
@@ -77,13 +74,11 @@ public final class MavenTestUtils {
 
   public static Project loadProjectFromPom(Class clazz, String path) {
     MavenProject pom = loadPom(clazz, path);
-    Configuration configuration = new MapConfiguration(pom.getProperties());
     Project project = new Project(pom.getGroupId() + ":" + pom.getArtifactId())
-      .setPom(pom)
-      .setConfiguration(configuration);
-    configuration.setProperty("sonar.java.source", MavenUtils.getJavaSourceVersion(pom));
-    configuration.setProperty("sonar.java.target", MavenUtils.getJavaVersion(pom));
-    configuration.setProperty(CoreProperties.ENCODING_PROPERTY, MavenUtils.getSourceEncoding(pom));
+      .setPom(pom);
+    // configuration.setProperty("sonar.java.source", MavenUtils.getJavaSourceVersion(pom));
+    // configuration.setProperty("sonar.java.target", MavenUtils.getJavaVersion(pom));
+    // configuration.setProperty(CoreProperties.ENCODING_PROPERTY, MavenUtils.getSourceEncoding(pom));
 
     project.setFileSystem(new MavenModuleFileSystem(pom));
     return project;
@@ -153,7 +148,7 @@ public final class MavenTestUtils {
     }
 
     public List<File> getSourceFiles(Language... langs) {
-      return new ArrayList(FileUtils.listFiles(getSourceDirs().get(0), new String[]{"java"}, true));
+      return new ArrayList(FileUtils.listFiles(getSourceDirs().get(0), new String[] {"java"}, true));
     }
 
     public List<File> getJavaSourceFiles() {
@@ -165,7 +160,7 @@ public final class MavenTestUtils {
     }
 
     public List<File> getTestFiles(Language... langs) {
-      return new ArrayList(FileUtils.listFiles(getTestDirs().get(0), new String[]{"java"}, true));
+      return new ArrayList(FileUtils.listFiles(getTestDirs().get(0), new String[] {"java"}, true));
     }
 
     public boolean hasTestFiles(Language lang) {
index 9b84740dde77c5fcfeff2a7f7419ad958699f915..9cb17d171df7cabf14ae662b5304480b8a5fe0bd 100644 (file)
  */
 package org.sonar.api.test;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.MapConfiguration;
 import org.apache.maven.project.MavenProject;
-import static org.mockito.Mockito.when;
 import org.sonar.api.resources.Project;
 
-import java.util.Properties;
+import static org.mockito.Mockito.when;
 
 public class ProjectTestBuilder {
 
   private MavenProject pom = MavenTestUtils.mockPom("jar");
-  private Configuration conf = new MapConfiguration(new Properties());
-
 
   public Project build() {
     when(pom.getGroupId()).thenReturn("mygroup");
     when(pom.getArtifactId()).thenReturn("myartifact");
     when(pom.isExecutionRoot()).thenReturn(true);
-    return new Project("mygroup:myartifact").setPom(pom).setConfiguration(conf);
+    return new Project("mygroup:myartifact").setPom(pom);
   }
 }