summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-09-05 14:58:03 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-09-05 14:58:03 +0200
commitd0c7a71f3d960cd5c9bf39b1f7fe8341470b06e7 (patch)
tree1d21d9901c613e68f3acab90b78381372f6f4f74
parente1c3a706319c397b436a28b7921b695baf712063 (diff)
downloadsonarqube-d0c7a71f3d960cd5c9bf39b1f7fe8341470b06e7.tar.gz
sonarqube-d0c7a71f3d960cd5c9bf39b1f7fe8341470b06e7.zip
SONAR-2860 Drop commons-configuration
-rw-r--r--plugins/sonar-email-notifications-plugin/pom.xml4
-rw-r--r--pom.xml20
-rw-r--r--server/sonar-server/pom.xml4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java155
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettings.java22
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java17
-rw-r--r--sonar-batch/pom.xml4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java23
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java45
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java1
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java36
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java22
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java23
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java30
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java20
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java14
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java33
-rw-r--r--sonar-core/src/main/java/org/sonar/api/database/configuration/DatabaseConfiguration.java75
-rw-r--r--sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/api/database/configuration/DatabaseConfigurationTest.java40
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java19
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java134
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java47
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java89
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java227
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java69
-rw-r--r--sonar-java-api/pom.xml4
-rw-r--r--sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java4
-rw-r--r--sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java16
-rw-r--r--sonar-plugin-api/pom.xml12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaContext.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/FormulaContext.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java15
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java107
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java46
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/test/MavenTestUtils.java17
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/test/ProjectTestBuilder.java9
43 files changed, 288 insertions, 1169 deletions
diff --git a/plugins/sonar-email-notifications-plugin/pom.xml b/plugins/sonar-email-notifications-plugin/pom.xml
index 792e80179be..3d78b68cc60 100644
--- a/plugins/sonar-email-notifications-plugin/pom.xml
+++ b/plugins/sonar-email-notifications-plugin/pom.xml
@@ -23,6 +23,10 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.3.2</version>
diff --git a/pom.xml b/pom.xml
index 98330ad0ec4..21e3b8b432a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -706,26 +706,6 @@
</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>
<!-- animal-sniffer doesn't work with 2.6.1 -->
diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml
index 47ec2324e26..39af6f5b17e 100644
--- a/server/sonar-server/pom.xml
+++ b/server/sonar-server/pom.xml
@@ -126,10 +126,6 @@
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- </dependency>
- <dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
index 418cba0bcf5..f53f013929a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
@@ -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,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettings.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettings.java
index 21c301b3cfe..cf63e34f87f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettings.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerSettings.java
@@ -19,13 +19,10 @@
*/
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();
- }
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java
index 3612c104526..920853a8463 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java
@@ -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();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java
index af0cc558e8f..ca465ee4097 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerSettingsTest.java
@@ -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();
- }
}
diff --git a/sonar-batch/pom.xml b/sonar-batch/pom.xml
index 41e7ebdc841..8a44063c151 100644
--- a/sonar-batch/pom.xml
+++ b/sonar-batch/pom.xml
@@ -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>
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
index 70d05de7356..2f972a398e6 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
@@ -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.");
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
index d08d78beafb..dd49c4e9a12 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
@@ -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,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java
index 96922f5b93f..befb89563fe 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java
@@ -19,32 +19,26 @@
*/
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();
}
@@ -54,21 +48,6 @@ public class GlobalSettings extends Settings {
}
@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")) {
throw MessageException.of("Access to the secured property '" + key
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
index 541a63a6bd7..56263637b14 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
@@ -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);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
index 7194f548f02..43f557a3c44 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
@@ -41,6 +41,7 @@ public class ProjectInitializer implements BatchComponent {
}
public void execute(Project project) {
+ project.setSettings(settings);
if (project.getLanguage() == null) {
initDeprecatedLanguage(project);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index 733a8237dd8..800210aa1c9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -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);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
index 72063cc1541..f7c2d9fa27d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
@@ -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);
}
@@ -87,21 +82,6 @@ public class ModuleSettings extends Settings {
}
@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")) {
throw MessageException.of("Access to the secured property '" + key
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
index e404ad07527..c2749ba0099 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
@@ -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);
}
@@ -65,21 +59,6 @@ public class ProjectSettings extends Settings {
}
@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")) {
throw MessageException.of("Access to the secured property '" + key
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java
index 34bd571d7ce..da6d442ec39 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java
@@ -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();
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
index 95bfb40be3d..7f914256695 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
@@ -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;
@@ -96,30 +94,6 @@ public class PastSnapshotFinderTest {
}
@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());
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
index c9ae930855b..d90d4e1a24c 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
@@ -19,11 +19,12 @@
*/
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 {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java
index d3710e64488..e91b5596101 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java
@@ -19,16 +19,17 @@
*/
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);
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
index 3bbed76aa17..a7a12f16e2c 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
@@ -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");
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
index c40d9456ce3..a66f7f1378f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
@@ -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
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
index 4f7726f6695..8cede90928b 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
@@ -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
index c1663192a34..00000000000
--- a/sonar-core/src/main/java/org/sonar/api/database/configuration/DatabaseConfiguration.java
+++ /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();
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java b/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java
index 59d7a9ceda3..568e97b35d7 100644
--- a/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java
+++ b/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java
@@ -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
index e6c11e07cb5..00000000000
--- a/sonar-core/src/test/java/org/sonar/api/database/configuration/DatabaseConfigurationTest.java
+++ /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"));
- }
-}
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
index b754732e01b..d852edd82d6 100644
--- a/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/ProjectUtils.java
@@ -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;
@@ -37,24 +36,6 @@ public final class ProjectUtils {
}
/**
- * @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
index 45ee16dc594..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/api/utils/CoberturaReportParserUtils.java
+++ /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
index c653ea92923..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/AbstractCoberturaParser.java
+++ /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
index e1baa0dce95..00000000000
--- a/sonar-deprecated/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
+++ /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
index 60b63e84de1..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java
+++ /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
index f8f1348645a..00000000000
--- a/sonar-deprecated/src/test/java/org/sonar/plugins/cobertura/api/CoberturaUtilsTest.java
+++ /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());
- }
-}
diff --git a/sonar-java-api/pom.xml b/sonar-java-api/pom.xml
index 7c18701b2f2..321e44fbc93 100644
--- a/sonar-java-api/pom.xml
+++ b/sonar-java-api/pom.xml
@@ -17,6 +17,10 @@
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-deprecated</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
<!-- unit tests -->
<dependency>
diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
index fd8c163ef6d..53596792273 100644
--- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
+++ b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java
@@ -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;
}
}
diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java
index 5ec3d97a2a4..1c2eb29753b 100644
--- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java
+++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java
@@ -19,13 +19,13 @@
*/
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");
diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml
index 9dd9d279942..06f98e88d24 100644
--- a/sonar-plugin-api/pom.xml
+++ b/sonar-plugin-api/pom.xml
@@ -77,14 +77,18 @@
</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>
</dependency>
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaContext.java
index c226befb1b5..c1565281ef1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaContext.java
@@ -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;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/FormulaContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FormulaContext.java
index 59a375cad00..b3c2fcb524b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/FormulaContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/FormulaContext.java
@@ -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();
-
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java b/sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java
index ac26bc00521..daf6a1e12d7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/platform/ComponentContainer.java
@@ -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() : "");
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
index 4355838c9e8..2bfe7ee4487 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java
@@ -19,14 +19,12 @@
*/
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;
}
/**
@@ -342,15 +360,6 @@ public class Project extends Resource implements Component {
}
/**
- * @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
*/
public String getAnalysisVersion() {
@@ -365,51 +374,6 @@ public class Project extends Resource implements Component {
}
/**
- * 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));
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java
index 7417c61a3e5..b9fe96e849c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java
@@ -19,15 +19,12 @@
*/
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");
- }
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/MavenTestUtils.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/MavenTestUtils.java
index 52df195bed5..6050c140bb1 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/test/MavenTestUtils.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/MavenTestUtils.java
@@ -19,14 +19,11 @@
*/
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) {
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/ProjectTestBuilder.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/ProjectTestBuilder.java
index 9b84740dde7..9cb17d171df 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/test/ProjectTestBuilder.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/ProjectTestBuilder.java
@@ -19,24 +19,19 @@
*/
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);
}
}