aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-11-06 18:43:55 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-11-06 18:44:07 +0100
commit8162e11b955940fbc620b78ff1551eccfc7005b2 (patch)
treef9d0cfa4beb4a194d65453c21a45665dd7a905af /sonar-plugin-api
parentbadee2ec9a773c5444baa15ca386a85461a4b5b1 (diff)
downloadsonarqube-8162e11b955940fbc620b78ff1551eccfc7005b2.tar.gz
sonarqube-8162e11b955940fbc620b78ff1551eccfc7005b2.zip
SONAR-3895 allow to exclude plugins during dry run mode
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/DryRunIncompatible.java42
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java31
3 files changed, 21 insertions, 57 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index ba1bc433187..88e87de5661 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -343,4 +343,9 @@ public interface CoreProperties {
* @since 3.4
*/
String PASSWORD = "sonar.password";
+
+ /**
+ * @since 3.4
+ */
+ String DRY_RUN = "sonar.dryRun";
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DryRunIncompatible.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DryRunIncompatible.java
deleted file mode 100644
index aa113c4f30a..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DryRunIncompatible.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.batch;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The presence of this annotation on an extension class indicates that the extension
- * may be disabled when the dry-run mode is enabled (-Dsonar.dryRun=true).
- * It's generally used by the extensions that push data to external systems, for example :
- * <ul>
- * <li>Send emails</li>
- * <li>Create a JIRA issue</li>
- * </ul>
- *
- *
- * @since 3.4
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface DryRunIncompatible {
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
index 0f29541dc30..6e9bb112de4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
@@ -47,6 +47,7 @@ import java.net.ProxySelector;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.List;
+import java.util.Map;
/**
* This component downloads HTTP files
@@ -59,11 +60,11 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo
private final BaseHttpDownloader downloader;
public HttpDownloader(Server server, Settings settings) {
- downloader = new BaseHttpDownloader(settings, server.getVersion());
+ downloader = new BaseHttpDownloader(settings.getProperties(), server.getVersion());
}
public HttpDownloader(Settings settings) {
- downloader = new BaseHttpDownloader(settings, null);
+ downloader = new BaseHttpDownloader(settings.getProperties(), null);
}
@Override
@@ -73,7 +74,7 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo
@Override
String[] getSupportedSchemes() {
- return new String[] {"http", "https"};
+ return new String[]{"http", "https"};
}
@Override
@@ -129,17 +130,17 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo
public static class BaseHttpDownloader {
private static final List<String> PROXY_SETTINGS = ImmutableList.of(
- "http.proxyHost", "http.proxyPort", "http.nonProxyHosts",
- "http.auth.ntlm.domain", "socksProxyHost", "socksProxyPort");
+ "http.proxyHost", "http.proxyPort", "http.nonProxyHosts",
+ "http.auth.ntlm.domain", "socksProxyHost", "socksProxyPort");
private String userAgent;
- public BaseHttpDownloader(Settings settings, String userAgent) {
+ public BaseHttpDownloader(Map<String, String> settings, String userAgent) {
initProxy(settings);
initUserAgent(userAgent);
}
- private void initProxy(Settings settings) {
+ private void initProxy(Map<String, String> settings) {
propagateProxySystemProperties(settings);
if (requiresProxyAuthentication(settings)) {
registerProxyCredentials(settings);
@@ -172,20 +173,20 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo
return Joiner.on(", ").join(descriptions);
}
- private void registerProxyCredentials(Settings settings) {
+ private void registerProxyCredentials(Map<String, String> settings) {
Authenticator.setDefault(new ProxyAuthenticator(
- settings.getString("http.proxyUser"),
- settings.getString("http.proxyPassword")));
+ settings.get("http.proxyUser"),
+ settings.get("http.proxyPassword")));
}
- private boolean requiresProxyAuthentication(Settings settings) {
- return settings.getString("http.proxyUser") != null;
+ private boolean requiresProxyAuthentication(Map<String, String> settings) {
+ return settings.containsKey("http.proxyUser");
}
- private void propagateProxySystemProperties(Settings settings) {
+ private void propagateProxySystemProperties(Map<String, String> settings) {
for (String key : PROXY_SETTINGS) {
- if (settings.getString(key) != null) {
- System.setProperty(key, settings.getString(key));
+ if (settings.containsKey(key)) {
+ System.setProperty(key, settings.get(key));
}
}
}