aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@sonarsource.com>2014-10-08 14:01:17 +0200
committerStephane Gamard <stephane.gamard@sonarsource.com>2014-10-08 14:01:17 +0200
commitd5d20d0f777ba89b49575846c8f96afd316829f4 (patch)
tree257a0341add4bf8a00a20af45e623a548b357255
parent0a890a7a3069e79bc1029f17ddc59c8fb4409274 (diff)
parent7eb13c86cafb14b8d7afbb3737a27fb3c6fe9d51 (diff)
downloadsonarqube-d5d20d0f777ba89b49575846c8f96afd316829f4.tar.gz
sonarqube-d5d20d0f777ba89b49575846c8f96afd316829f4.zip
Merge remote-tracking branch 'origin/branch-4.5'
Conflicts: server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java
-rwxr-xr-xdebug-server.sh (renamed from debug.sh)2
-rw-r--r--jacoco-build.sh (renamed from jacoco_build.sh)0
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java4
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java10
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java10
-rw-r--r--server/sonar-web/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee2
-rw-r--r--server/sonar-web/src/main/coffee/component-viewer/main.coffee2
-rw-r--r--server/sonar-web/src/main/js/issues/app.js2
-rw-r--r--sonar-application/src/main/assembly/conf/sonar.properties14
-rw-r--r--sonar-application/src/main/java/org/sonar/application/App.java6
-rw-r--r--sonar-application/src/main/java/org/sonar/application/DefaultSettings.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotIndexedException.java33
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java10
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java11
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java42
-rw-r--r--sonar-core/src/test/java/org/sonar/core/plugins/PluginClassloadersTest.java16
26 files changed, 94 insertions, 113 deletions
diff --git a/debug.sh b/debug-server.sh
index 5dadb3becab..1d1549d9c4d 100755
--- a/debug.sh
+++ b/debug-server.sh
@@ -7,4 +7,4 @@ if ! ls sonarqube-*/bin/sonar-application*.jar &> /dev/null; then
fi
cd sonarqube-*
-java -jar ./lib/sonar-application*.jar -Dsonar.web.javaOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 \ No newline at end of file
+java -jar ./lib/sonar-application*.jar -Dsonar.web.javaAdditionalOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
diff --git a/jacoco_build.sh b/jacoco-build.sh
index 11ceb34f316..11ceb34f316 100644
--- a/jacoco_build.sh
+++ b/jacoco-build.sh
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
index 19d1dd93207..8f54748066f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
@@ -95,10 +95,10 @@ public class VariationDecorator implements Decorator {
private void computeVariation(Resource resource, DecoratorContext context, PastSnapshot pastSnapshot) {
List<Object[]> pastMeasures = pastMeasuresLoader.getPastMeasures(resource, pastSnapshot);
- compareWithPastMeasures(resource, context, pastSnapshot.getIndex(), pastMeasures);
+ compareWithPastMeasures(context, pastSnapshot.getIndex(), pastMeasures);
}
- void compareWithPastMeasures(Resource resource, DecoratorContext context, int index, List<Object[]> pastMeasures) {
+ private void compareWithPastMeasures(DecoratorContext context, int index, List<Object[]> pastMeasures) {
Map<MeasureKey, Object[]> pastMeasuresByKey = Maps.newHashMap();
for (Object[] pastMeasure : pastMeasures) {
pastMeasuresByKey.put(new MeasureKey(pastMeasure), pastMeasure);
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
index 7750b6deb35..76abf52deba 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java
@@ -19,6 +19,8 @@
*/
package org.sonar.process.monitor;
+import org.apache.commons.lang.StringUtils;
+
import javax.annotation.Nullable;
import java.io.File;
@@ -84,12 +86,16 @@ public class JavaCommand {
}
public JavaCommand addJavaOption(String s) {
- javaOptions.add(s);
+ if (StringUtils.isNotBlank(s)) {
+ javaOptions.add(s);
+ }
return this;
}
public JavaCommand addJavaOptions(String s) {
- Collections.addAll(javaOptions, s.split(" "));
+ for (String opt : s.split(" ")) {
+ addJavaOption(opt);
+ }
return this;
}
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
index fbfbad11b54..689f061ff06 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java
@@ -65,8 +65,13 @@ public class JavaCommandTest {
}
@Test
- public void split_java_options() throws Exception {
+ public void add_java_options() throws Exception {
JavaCommand command = new JavaCommand("foo");
+ assertThat(command.getJavaOptions()).isEmpty();
+
+ command.addJavaOptions("");
+ assertThat(command.getJavaOptions()).isEmpty();
+
command.addJavaOptions("-Xmx512m -Xms256m -Dfoo");
assertThat(command.getJavaOptions()).containsOnly("-Xmx512m", "-Xms256m", "-Dfoo");
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java
index e2910b6c4ea..668b072dad9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java
@@ -19,14 +19,12 @@
*/
package org.sonar.server.activity.ws;
-import org.sonar.api.resources.Languages;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.core.activity.Activity;
import org.sonar.server.activity.index.ActivityDoc;
import org.sonar.server.activity.index.ActivityNormalizer;
import org.sonar.server.search.ws.BaseMapping;
import org.sonar.server.search.ws.SearchOptions;
-import org.sonar.server.text.MacroInterpreter;
import java.util.Map;
@@ -35,7 +33,7 @@ import java.util.Map;
*/
public class ActivityMapping extends BaseMapping<ActivityDoc, Object> {
- public ActivityMapping(Languages languages, MacroInterpreter macroInterpreter) {
+ public ActivityMapping() {
map("type", ActivityNormalizer.LogFields.TYPE.field());
map("action", ActivityNormalizer.LogFields.ACTION.field());
mapDateTime("createdAt", ActivityNormalizer.LogFields.CREATED_AT.field());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
index 968c9b46448..c008bd971d0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
@@ -56,7 +56,6 @@ import org.sonar.server.search.Result;
import org.sonar.server.search.SearchClient;
import javax.annotation.CheckForNull;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -158,7 +157,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> {
}
/* Build main query (search based) */
- protected QueryBuilder getQuery(RuleQuery query, QueryContext options) {
+ protected QueryBuilder getQuery(RuleQuery query) {
// No contextual query case
String queryText = query.getQueryText();
@@ -413,7 +412,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> {
esSearch.setScroll(TimeValue.timeValueMinutes(3));
}
- QueryBuilder qb = this.getQuery(query, options);
+ QueryBuilder qb = this.getQuery(query);
HashMap<String, FilterBuilder> filters = this.getFilters(query, options);
if (options.isFacet()) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java b/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java
index 5cf1ba3dc72..de1234cd280 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java
@@ -99,7 +99,7 @@ public class SearchClient extends TransportClient implements Startable {
}
return response;
} catch (Exception e) {
- LOGGER.error("could not execute request: " + response, e);
+ LOGGER.error("could not execute request: {}", request);
throw new IllegalStateException("ES error: ", e);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java
index 0fbabca058e..cc96395bc62 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java
@@ -22,7 +22,9 @@ package org.sonar.server.startup;
import org.apache.commons.io.FileUtils;
import org.hamcrest.core.Is;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import org.sonar.api.platform.PluginMetadata;
import org.sonar.api.platform.PluginRepository;
import org.sonar.core.plugins.DefaultPluginMetadata;
@@ -40,6 +42,9 @@ import static org.mockito.Mockito.when;
public class GeneratePluginIndexTest {
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
+
private DefaultServerFileSystem fileSystem;
private File index;
@@ -65,10 +70,11 @@ public class GeneratePluginIndexTest {
assertThat(lines.get(1), containsString("checkstyle"));
}
- private PluginMetadata newMetadata(String pluginKey) {
+ private PluginMetadata newMetadata(String pluginKey) throws IOException {
PluginMetadata plugin = mock(DefaultPluginMetadata.class);
when(plugin.getKey()).thenReturn(pluginKey);
- when(plugin.getFile()).thenReturn(new File(pluginKey + ".jar"));
+ File pluginFile = temp.newFile(pluginKey + ".jar");
+ when(plugin.getFile()).thenReturn(pluginFile);
return plugin;
}
}
diff --git a/server/sonar-web/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee b/server/sonar-web/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee
index 67776649b39..16ba0bb7925 100644
--- a/server/sonar-web/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee
+++ b/server/sonar-web/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee
@@ -152,7 +152,7 @@ define [
@$(@qualityProfilesRegion.el).show()
@qualityProfilesRegion.show @qualityProfilesView
- if @options.app.getQualityProfile()
+ if @options.app.getQualityProfile() and (@options.app.canWrite or @contextProfile.has('severity'))
@$(@contextRegion.el).show()
@contextRegion.show @contextQualityProfileView
else
diff --git a/server/sonar-web/src/main/coffee/component-viewer/main.coffee b/server/sonar-web/src/main/coffee/component-viewer/main.coffee
index 15e2a13d138..e6da45caa2f 100644
--- a/server/sonar-web/src/main/coffee/component-viewer/main.coffee
+++ b/server/sonar-web/src/main/coffee/component-viewer/main.coffee
@@ -131,7 +131,7 @@ define [
width = @elementToFit.width()
height = @elementToFit.height()
- availableWidth = width - workspace.outerWidth(true)
+ availableWidth = width - workspace.outerWidth(true) - 20
availableHeight = height - @$(@headerRegion.$el).outerHeight(true)
source.removeClass 'overflow'
diff --git a/server/sonar-web/src/main/js/issues/app.js b/server/sonar-web/src/main/js/issues/app.js
index 43411efffb2..861636f8089 100644
--- a/server/sonar-web/src/main/js/issues/app.js
+++ b/server/sonar-web/src/main/js/issues/app.js
@@ -371,7 +371,7 @@ requirejs(
var detailsEl = jQuery('.navigator-details'),
detailsWidth = jQuery(window).width() - detailsEl.offset().left -
- parseInt(detailsEl.css('margin-right'), 10),
+ parseInt(detailsEl.css('margin-right'), 10) - 20,
detailsHeight = jQuery(window).height() - detailsEl.offset().top -
parseInt(detailsEl.css('margin-bottom'), 10) - footerHeight;
detailsEl.width(detailsWidth).height(detailsHeight);
diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties
index 3fa9963d19a..b9bee4266e5 100644
--- a/sonar-application/src/main/assembly/conf/sonar.properties
+++ b/sonar-application/src/main/assembly/conf/sonar.properties
@@ -66,8 +66,11 @@ sonar.jdbc.timeBetweenEvictionRunsMillis=30000
# Use the following property to customize JVM options. Enabling the HotSpot Server VM
# mode (-server) is recommended.
# Note that the option -Dfile.encoding=UTF-8 is mandatory.
-#sonar.web.javaOpts=-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError \
-# -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false
+#sonar.web.javaOpts=-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError
+
+# Same as previous property, but allows to not repeat all other settings
+# like -Djava.awt.headless=true
+#sonar.web.javaAdditionalOpts=
# Binding IP address. For servers with more than one IP address, this property specifies which
# address will be used for listening on the specified ports.
@@ -170,8 +173,11 @@ sonar.jdbc.timeBetweenEvictionRunsMillis=30000
# JVM options. Note that enabling the HotSpot Server VM mode (-server) is recommended.
#sonar.search.javaOpts=-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true \
# -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 \
-# -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError \
-# -Djava.awt.headless=true
+# -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError
+
+# Same as previous property, but allows to not repeat all other settings
+# like -Djava.awt.headless=true
+#sonar.search.javaAdditionalOpts=
# Elasticsearch port. Default is 9001. Use 0 to get a free port.
# This port must be private and must not be exposed to the Internet.
diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java
index 502cf561394..9c027abebdf 100644
--- a/sonar-application/src/main/java/org/sonar/application/App.java
+++ b/sonar-application/src/main/java/org/sonar/application/App.java
@@ -70,7 +70,9 @@ public class App implements Stoppable {
JavaCommand elasticsearch = new JavaCommand("search");
elasticsearch
.setWorkDir(homeDir)
- .addJavaOptions(props.value(DefaultSettings.SEARCH_JAVA_OPTS))
+ .addJavaOptions("-Djava.awt.headless=true")
+ .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_OPTS))
+ .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_ADDITIONAL_OPTS))
.setTempDir(tempDir.getAbsoluteFile())
.setClassName("org.sonar.search.SearchServer")
.setArguments(props.rawProperties())
@@ -82,7 +84,9 @@ public class App implements Stoppable {
if (StringUtils.isEmpty(props.value(DefaultSettings.CLUSTER_MASTER))) {
JavaCommand webServer = new JavaCommand("web")
.setWorkDir(homeDir)
+ .addJavaOptions("-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false")
.addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_OPTS))
+ .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_ADDITIONAL_OPTS))
.setTempDir(tempDir.getAbsoluteFile())
// required for logback tomcat valve
.setEnvVariable("sonar.path.logs", props.nonNullValue("sonar.path.logs"))
diff --git a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java
index 701249f5f63..4a936789499 100644
--- a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java
+++ b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java
@@ -36,7 +36,9 @@ class DefaultSettings {
static final String CLUSTER_NODE_NAME = "sonar.node.name";
static final String SEARCH_PORT = "sonar.search.port";
static final String SEARCH_JAVA_OPTS = "sonar.search.javaOpts";
+ static final String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts";
static final String WEB_JAVA_OPTS = "sonar.web.javaOpts";
+ static final String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts";
static final String JDBC_URL = "sonar.jdbc.url";
static final String JDBC_LOGIN = "sonar.jdbc.username";
static final String JDBC_PASSWORD = "sonar.jdbc.password";
@@ -70,9 +72,11 @@ class DefaultSettings {
defaults.put(SEARCH_JAVA_OPTS, "-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " +
"-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " +
"-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true");
+ defaults.put(SEARCH_JAVA_ADDITIONAL_OPTS, "");
defaults.put(CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis());
defaults.put(WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true " +
"-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false");
+ defaults.put(WEB_JAVA_ADDITIONAL_OPTS, "");
defaults.put(JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar");
defaults.put(JDBC_LOGIN, "sonar");
defaults.put(JDBC_PASSWORD, "sonar");
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotIndexedException.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotIndexedException.java
deleted file mode 100644
index 16b5ee32a90..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotIndexedException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-import org.sonar.api.resources.Resource;
-import org.sonar.api.utils.SonarException;
-
-/**
- * @since 2.6
- */
-public class ResourceNotIndexedException extends SonarException {
-
- public ResourceNotIndexedException(final Resource reference) {
- super(reference.toString());
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
index 437d778b7fd..61a6a062867 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
@@ -96,7 +96,7 @@ public class BatchMediumTester {
public static class BatchMediumTesterBuilder {
private final FakeGlobalReferentialsLoader globalRefProvider = new FakeGlobalReferentialsLoader();
private final FakeProjectReferentialsLoader projectRefProvider = new FakeProjectReferentialsLoader();
- private final FackPluginsReferential pluginsReferential = new FackPluginsReferential();
+ private final FakePluginsReferential pluginsReferential = new FakePluginsReferential();
private final Map<String, String> bootstrapProperties = new HashMap<String, String>();
public BatchMediumTester build() {
@@ -472,7 +472,7 @@ public class BatchMediumTester {
}
}
- private static class FackPluginsReferential implements PluginsReferential {
+ private static class FakePluginsReferential implements PluginsReferential {
private List<RemotePlugin> pluginList = new ArrayList<RemotePlugin>();
private Map<RemotePlugin, File> pluginFiles = new HashMap<RemotePlugin, File>();
@@ -488,15 +488,15 @@ public class BatchMediumTester {
return pluginFiles.get(remote);
}
- public FackPluginsReferential addPlugin(String pluginKey, File location) {
+ public FakePluginsReferential addPlugin(String pluginKey, File location) {
RemotePlugin plugin = new RemotePlugin(pluginKey, false);
pluginList.add(plugin);
pluginFiles.put(plugin, location);
return this;
}
- public FackPluginsReferential addPlugin(String pluginKey, SonarPlugin pluginInstance) {
- localPlugins.put(DefaultPluginMetadata.create(null).setKey(pluginKey), pluginInstance);
+ public FakePluginsReferential addPlugin(String pluginKey, SonarPlugin pluginInstance) {
+ localPlugins.put(DefaultPluginMetadata.create(pluginKey), pluginInstance);
return this;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java
index 772f773cb5f..59f1e667edd 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java
@@ -21,7 +21,6 @@ package org.sonar.batch.scan.filesystem;
import org.sonar.api.BatchComponent;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.resources.Project;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.bootstrap.AnalysisMode;
@@ -33,17 +32,9 @@ public class InputFileBuilderFactory implements BatchComponent {
private final StatusDetectionFactory statusDetectionFactory;
private final AnalysisMode analysisMode;
- public InputFileBuilderFactory(Project module, ProjectDefinition def, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory,
- StatusDetectionFactory statusDetectionFactory, AnalysisMode analysisMode) {
- this(module.getEffectiveKey(), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode);
- }
-
- /**
- * Used by scan2
- */
public InputFileBuilderFactory(ProjectDefinition def, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory,
StatusDetectionFactory statusDetectionFactory, AnalysisMode analysisMode) {
- this(def.getKey(), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode);
+ this(def.getKeyWithBranch(), pathResolver, langDetectionFactory, statusDetectionFactory, analysisMode);
}
private InputFileBuilderFactory(String effectiveKey, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java
index 8b268b14be9..3ea69cad781 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java
@@ -20,7 +20,6 @@
package org.sonar.batch.scan2;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.sensor.SensorStorage;
@@ -36,7 +35,7 @@ public class DefaultFileLinesContextFactory implements FileLinesContextFactory {
private final ProjectDefinition def;
private final InputPathCache fileCache;
- public DefaultFileLinesContextFactory(InputPathCache fileCache, FileSystem fs, MetricFinder metricFinder, SensorStorage sensorStorage,
+ public DefaultFileLinesContextFactory(InputPathCache fileCache, MetricFinder metricFinder, SensorStorage sensorStorage,
ProjectDefinition def) {
this.fileCache = fileCache;
this.metricFinder = metricFinder;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java
index 67e2a37908d..41a2cda0390 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java
@@ -139,7 +139,7 @@ public class ModuleScanContainer extends ComponentContainer {
@Override
protected void doAfterStart() {
- getComponentByType(ModuleScanExecutor.class).execute(moduleDefinition);
+ getComponentByType(ModuleScanExecutor.class).execute();
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java
index 8611bd3b26a..088125818df 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanExecutor.java
@@ -20,7 +20,6 @@
package org.sonar.batch.scan2;
import com.google.common.collect.Lists;
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader;
import org.sonar.batch.rule.QProfileVerifier;
@@ -60,7 +59,7 @@ public final class ModuleScanExecutor {
/**
* Executed on each module
*/
- public void execute(ProjectDefinition moduleDefinition) {
+ public void execute() {
fsLogger.log();
// Index and lock the filesystem
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
index e38081b62be..bb78a170c84 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
@@ -22,7 +22,6 @@ package org.sonar.batch.scan.filesystem;
import org.junit.Test;
import org.mockito.Mockito;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.resources.Project;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.bootstrap.AnalysisMode;
@@ -33,14 +32,12 @@ public class InputFileBuilderFactoryTest {
@Test
public void create_builder() throws Exception {
PathResolver pathResolver = new PathResolver();
- Project project = new Project("struts");
LanguageDetectionFactory langDetectionFactory = mock(LanguageDetectionFactory.class, Mockito.RETURNS_MOCKS);
StatusDetectionFactory statusDetectionFactory = mock(StatusDetectionFactory.class, Mockito.RETURNS_MOCKS);
DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
AnalysisMode analysisMode = mock(AnalysisMode.class);
- InputFileBuilderFactory factory = new InputFileBuilderFactory(
- project, ProjectDefinition.create(), pathResolver, langDetectionFactory,
+ InputFileBuilderFactory factory = new InputFileBuilderFactory(ProjectDefinition.create().setKey("struts"), pathResolver, langDetectionFactory,
statusDetectionFactory, analysisMode);
InputFileBuilder builder = factory.create(fs);
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java b/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
index 55239eb3410..8a4a103cd5a 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
@@ -63,6 +63,10 @@ public class DefaultPluginMetadata implements PluginMetadata, Comparable<PluginM
return new DefaultPluginMetadata().setFile(file);
}
+ public static DefaultPluginMetadata create(String key) {
+ return new DefaultPluginMetadata().setKey(key);
+ }
+
public File getFile() {
return file;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java b/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java
index 50903592616..3bc254a3ff1 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java
@@ -45,7 +45,7 @@ public class RemotePlugin {
RemotePlugin result = new RemotePlugin(fields[0], Boolean.parseBoolean(fields[1]));
if (fields.length > 2) {
String[] nameAndHash = StringUtils.split(fields[2], "|");
- result.setFile(nameAndHash[0], nameAndHash.length > 1 ? nameAndHash[1] : null);
+ result.setFile(nameAndHash[0], nameAndHash[1]);
}
return result;
}
@@ -72,7 +72,7 @@ public class RemotePlugin {
}
public RemotePlugin setFile(File f) {
- return this.setFile(f.getName(), f.exists() ? new FileHashes().of(f) : null);
+ return this.setFile(f.getName(), new FileHashes().of(f));
}
public RemotePluginFile file() {
diff --git a/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java b/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java
index f7d7dea4e59..d3f819392b5 100644
--- a/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java
@@ -36,19 +36,19 @@ public class DefaultPluginMetadataTest {
public void testGettersAndSetters() {
DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"));
metadata.setKey("checkstyle")
- .setParent("java")
- .setLicense("LGPL")
- .setDescription("description")
- .setHomepage("http://home")
- .setIssueTrackerUrl("http://jira.codehuas.org")
- .setMainClass("org.Main")
- .setOrganization("SonarSource")
- .setOrganizationUrl("http://sonarsource.org")
- .setVersion("1.1")
- .setSonarVersion("3.0")
- .setUseChildFirstClassLoader(true)
- .setCore(false)
- .setImplementationBuild("abcdef");
+ .setParent("java")
+ .setLicense("LGPL")
+ .setDescription("description")
+ .setHomepage("http://home")
+ .setIssueTrackerUrl("http://jira.codehuas.org")
+ .setMainClass("org.Main")
+ .setOrganization("SonarSource")
+ .setOrganizationUrl("http://sonarsource.org")
+ .setVersion("1.1")
+ .setSonarVersion("3.0")
+ .setUseChildFirstClassLoader(true)
+ .setCore(false)
+ .setImplementationBuild("abcdef");
assertThat(metadata.getKey()).isEqualTo("checkstyle");
assertThat(metadata.getParent()).isEqualTo("java");
@@ -72,8 +72,8 @@ public class DefaultPluginMetadataTest {
@Test
public void testDeployedFiles() {
DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"))
- .addDeployedFile(new File("foo.jar"))
- .addDeployedFile(new File("bar.jar"));
+ .addDeployedFile(new File("foo.jar"))
+ .addDeployedFile(new File("bar.jar"));
assertThat(metadata.getDeployedFiles()).hasSize(2);
}
@@ -81,7 +81,7 @@ public class DefaultPluginMetadataTest {
@Test
public void testInternalPathToDependencies() {
DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"))
- .setPathsToInternalDeps(newArrayList("META-INF/lib/commons-lang.jar", "META-INF/lib/commons-io.jar"));
+ .setPathsToInternalDeps(newArrayList("META-INF/lib/commons-lang.jar", "META-INF/lib/commons-io.jar"));
assertThat(metadata.getPathsToInternalDeps()).containsOnly("META-INF/lib/commons-lang.jar", "META-INF/lib/commons-io.jar");
}
@@ -99,11 +99,11 @@ public class DefaultPluginMetadataTest {
@Test
public void shouldCompare() {
DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar"))
- .setKey("checkstyle")
- .setName("Checkstyle");
+ .setKey("checkstyle")
+ .setName("Checkstyle");
DefaultPluginMetadata pmd = DefaultPluginMetadata.create(new File("sonar-pmd-plugin.jar"))
- .setKey("pmd")
- .setName("PMD");
+ .setKey("pmd")
+ .setName("PMD");
List<DefaultPluginMetadata> plugins = Arrays.asList(pmd, checkstyle);
assertThat(natural().sortedCopy(plugins)).onProperty("key").containsExactly("checkstyle", "pmd");
@@ -141,6 +141,6 @@ public class DefaultPluginMetadataTest {
}
static DefaultPluginMetadata pluginWithVersion(String version) {
- return DefaultPluginMetadata.create(null).setSonarVersion(version);
+ return DefaultPluginMetadata.create("foo").setSonarVersion(version);
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/plugins/PluginClassloadersTest.java b/sonar-core/src/test/java/org/sonar/core/plugins/PluginClassloadersTest.java
index 95bb9da245c..120680b1998 100644
--- a/sonar-core/src/test/java/org/sonar/core/plugins/PluginClassloadersTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/plugins/PluginClassloadersTest.java
@@ -62,8 +62,8 @@ public class PluginClassloadersTest {
@Test
public void shouldImport() throws Exception {
- classloaders.add(DefaultPluginMetadata.create(null).setKey("foo").addDeployedFile(getFile("PluginClassloadersTest/foo.jar")));
- classloaders.add(DefaultPluginMetadata.create(null).setKey("bar").addDeployedFile(getFile("PluginClassloadersTest/bar.jar")));
+ classloaders.add(DefaultPluginMetadata.create("foo").addDeployedFile(getFile("PluginClassloadersTest/foo.jar")));
+ classloaders.add(DefaultPluginMetadata.create("bar").addDeployedFile(getFile("PluginClassloadersTest/bar.jar")));
classloaders.done();
String resourceName = "org/sonar/plugins/bar/api/resource.txt";
@@ -74,8 +74,7 @@ public class PluginClassloadersTest {
@Test
public void shouldCreateBaseClassloader() {
classloaders = new PluginClassloaders(getClass().getClassLoader());
- DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null)
- .setKey("checkstyle")
+ DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
.setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
.addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));
@@ -90,13 +89,11 @@ public class PluginClassloadersTest {
public void shouldExtendPlugin() {
classloaders = new PluginClassloaders(getClass().getClassLoader());
- DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null)
- .setKey("checkstyle")
+ DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
.setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
.addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));
- DefaultPluginMetadata checkstyleExt = DefaultPluginMetadata.create(null)
- .setKey("checkstyle-ext")
+ DefaultPluginMetadata checkstyleExt = DefaultPluginMetadata.create("checkstyle-ext")
.setBasePlugin("checkstyle")
.setMainClass("com.mycompany.sonar.checkstyle.CheckstyleExtensionsPlugin")
.addDeployedFile(getFile("sonar-checkstyle-extensions-plugin-0.1-SNAPSHOT.jar"));
@@ -119,8 +116,7 @@ public class PluginClassloadersTest {
classloaders = new PluginClassloaders(getClass().getClassLoader(), world);
- DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create(null)
- .setKey("checkstyle")
+ DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
.setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
.addDeployedFile(getFile("sonar-checkstyle-plugin-2.8.jar"));