diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-10-05 00:44:37 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-10-07 13:36:25 +0200 |
commit | ef5bf7fdece84e5a52c8d478c8a733ecdf4d57f1 (patch) | |
tree | c64a8a041183379e92fbc81becc77af07c9b38e3 /plugins | |
parent | 3174a29201e922db758b51f4b693ca131e7037ec (diff) | |
download | sonarqube-ef5bf7fdece84e5a52c8d478c8a733ecdf4d57f1.tar.gz sonarqube-ef5bf7fdece84e5a52c8d478c8a733ecdf4d57f1.zip |
SONAR-2861 New Configuration API
The component org.apache.commons.Configuration is still available but plugins should use org.sonar.api.config.Settings.
It also implies the following issues :
SONAR-2870 do not rebuild the WAR file when editing sonar.properties
SONAR-2869 allow to use the annotations @Properties/@Property on extensions
Diffstat (limited to 'plugins')
4 files changed, 45 insertions, 15 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java index 7461fe4cc60..de9d5d5ce7a 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java @@ -23,13 +23,14 @@ import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.PropertiesExpander; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; -import org.apache.commons.configuration.Configuration; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.CharEncoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.BatchExtension; import org.sonar.api.CoreProperties; +import org.sonar.api.Property; +import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Java; import org.sonar.api.resources.ProjectFileSystem; @@ -41,16 +42,22 @@ import java.util.List; import java.util.Locale; import java.util.Properties; +@org.sonar.api.Properties({ + @Property(key = CheckstyleConfiguration.PROPERTY_GENERATE_XML, + defaultValue = "false", + name = "Generate XML Report", + project = false, global = false)}) public class CheckstyleConfiguration implements BatchExtension { private static final Logger LOG = LoggerFactory.getLogger(CheckstyleConfiguration.class); + public static final String PROPERTY_GENERATE_XML = "sonar.checkstyle.generateXml"; private CheckstyleProfileExporter confExporter; private RulesProfile profile; - private Configuration conf; + private Settings conf; private ProjectFileSystem fileSystem; - public CheckstyleConfiguration(Configuration conf, CheckstyleProfileExporter confExporter, RulesProfile profile, ProjectFileSystem fileSystem) { + public CheckstyleConfiguration(Settings conf, CheckstyleProfileExporter confExporter, RulesProfile profile, ProjectFileSystem fileSystem) { this.conf = conf; this.confExporter = confExporter; this.profile = profile; @@ -79,7 +86,7 @@ public class CheckstyleConfiguration implements BatchExtension { } public File getTargetXMLReport() { - if (conf.getBoolean(CheckstyleConstants.GENERATE_XML_KEY, CheckstyleConstants.GENERATE_XML_DEFAULT_VALUE)) { + if (conf.getBoolean(PROPERTY_GENERATE_XML)) { return new File(fileSystem.getSonarWorkingDirectory(), "checkstyle-result.xml"); } return null; @@ -112,7 +119,7 @@ public class CheckstyleConfiguration implements BatchExtension { } public Locale getLocale() { - return new Locale(conf.getString(CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY, CoreProperties.CORE_VIOLATION_LOCALE_DEFAULT_VALUE)); + return new Locale(conf.getString(CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY)); } public Charset getCharset() { diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConstants.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConstants.java index e110efcba84..5299f047598 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConstants.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConstants.java @@ -30,8 +30,6 @@ public final class CheckstyleConstants { public static final String FILTERS_KEY = "sonar.checkstyle.filters"; public static final String FILTERS_DEFAULT_VALUE = "<module name=\"SuppressionCommentFilter\"/>"; - public static final String GENERATE_XML_KEY = "sonar.checkstyle.generateXml"; - public static final boolean GENERATE_XML_DEFAULT_VALUE = false; private CheckstyleConstants() { } diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java index dac37703a98..e14bac06bb8 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java @@ -19,9 +19,9 @@ */ package org.sonar.plugins.checkstyle; -import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.io.FileUtils; import org.junit.Test; +import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; import org.sonar.api.test.MavenTestUtils; @@ -48,12 +48,6 @@ public class CheckstyleConfigurationTest { assertThat(FileUtils.readFileToString(xmlFile), is("<conf/>")); } - @Test - public void shouldGetDefaultLocaleForMessages() { - CheckstyleConfiguration configuration = new CheckstyleConfiguration(new PropertiesConfiguration(), null, null, null); - assertThat(configuration.getLocale(), is(Locale.ENGLISH)); - } - public class FakeExporter extends CheckstyleProfileExporter { @Override public void exportProfile(RulesProfile profile, Writer writer) { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 354e00c9e37..75f70be23f0 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -176,7 +176,38 @@ import java.util.List; project = true, global = false, defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5, - category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS) + category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS), + + + // SERVER-SIDE TECHNICAL PROPERTIES + + @Property( + key = "sonar.useStructureDump", + name = "Use Structure Dump", + description = "Used when creating database schema", + project = false, + global = false, + defaultValue = "true"), + @Property( + key = "sonar.authenticator.downcase", + name = "Downcase login", + description = "Downcase login during user authentication, typically for Active Directory", + project = false, + global = false, + defaultValue = "false"), + @Property( + key = CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS, + name = "Create user accounts", + description = "Create accounts when authenticating users via an external system", + project = false, + global = false, + defaultValue = "false"), + @Property( + key = CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE, + name = "Ignore failures during authenticator startup", + defaultValue = "false", + project = false, + global = false) }) public class CorePlugin extends SonarPlugin { |