diff --git a/pom.xml b/pom.xml
index cdfe89c..db01815 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,22 +1,15 @@
-
+
4.0.0
-
- org.sonarsource.parent
- parent
- 29
-
-
org.sonarsource.scm.perforce
sonar-scm-perforce-plugin
- SonarQube :: Plugins :: SCM :: Perforce
- 1.5-SNAPSHOT
+ 1.6-SNAPSHOT
+
+
sonar-plugin
- Perforce SCM Provider.
- http://redirect.sonarsource.com/plugins/scmperforce.html
- 2014
-
-
+
+
+
GNU LGPL 3
http://www.gnu.org/licenses/lgpl.txt
@@ -31,14 +24,12 @@
+1
-
scm:git:git@github.com:SonarQubeCommunity/sonar-scm-perforce.git
scm:git:git@github.com:SonarQubeCommunity/sonar-scm-perforce.git
https://github.com/SonarQubeCommunity/sonar-scm-perforce
HEAD
-
GitHub Issues
https://github.com/SonarQubeCommunity/sonar-scm-perforce/issues
@@ -48,15 +39,14 @@
Travis
https://travis-ci.org/SonarQubeCommunity/sonar-scm-perforce
-
-
- 5.0
- Perforce
- org.sonar.plugins.scm.perforce.PerforcePlugin
- sonar-scm-perforce
-
-
+
+
+ org.sonarsource.sonarqube
+ sonar-plugin-api
+ 7.4
+ provided
+
com.perforce
p4java
@@ -68,13 +58,7 @@
2.0.3
provided
-
- org.codehaus.sonar
- sonar-plugin-api
- ${sonar.buildVersion}
- provided
-
-
+
junit
@@ -94,6 +78,52 @@
1.9.5
test
+
+ org.slf4j
+ slf4j-api
+ 1.7.25
+
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+
+ com.google.guava
+ guava
+ r05
+
+
-
-
+
+
+
+
+ org.sonarsource.sonar-packaging-maven-plugin
+ sonar-packaging-maven-plugin
+ 1.17
+ true
+
+
+ org.sonar.plugins.scm.perforce.PerforcePlugin
+ PerforcePlugin
+
+
+
+
+ maven-site-plugin
+ 3.1
+
+
+ attach-descriptor
+
+ attach-descriptor
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/sonar/plugins/scm/perforce/PerforceBlameCommand.java b/src/main/java/org/sonar/plugins/scm/perforce/PerforceBlameCommand.java
index 660d450..28515f9 100644
--- a/src/main/java/org/sonar/plugins/scm/perforce/PerforceBlameCommand.java
+++ b/src/main/java/org/sonar/plugins/scm/perforce/PerforceBlameCommand.java
@@ -52,8 +52,8 @@ public class PerforceBlameCommand extends BlameCommand {
private static final Logger LOG = LoggerFactory.getLogger(PerforceBlameCommand.class);
private final PerforceConfiguration config;
- private final Map revisionDataByChangelistId = new HashMap<>();
- private final Map changelistCache = new HashMap<>();
+ private final Map revisionDataByChangelistId = new HashMap();
+ private final Map changelistCache = new HashMap();
public PerforceBlameCommand(PerforceConfiguration config) {
this.config = config;
@@ -64,6 +64,7 @@ public void blame(BlameInput input, BlameOutput output) {
FileSystem fs = input.fileSystem();
LOG.debug("Working directory: " + fs.baseDir().getAbsolutePath());
PerforceExecutor executor = new PerforceExecutor(config, fs.baseDir());
+
try {
for (InputFile inputFile : input.filesToBlame()) {
blame(inputFile, executor.getServer(), output);
@@ -116,7 +117,7 @@ void blame(InputFile inputFile, IOptionsServer server, BlameOutput output) throw
*/
private List computeBlame(InputFile inputFile, IOptionsServer server, List fileAnnotations)
throws ConnectionException, RequestException, AccessException {
- List lines = new ArrayList<>();
+ List lines = new ArrayList();
for (IFileAnnotation fileAnnotation : fileAnnotations) {
int lowerChangelistId = fileAnnotation.getLower();
diff --git a/src/main/java/org/sonar/plugins/scm/perforce/PerforceConfiguration.java b/src/main/java/org/sonar/plugins/scm/perforce/PerforceConfiguration.java
index 2939165..4dbc96a 100644
--- a/src/main/java/org/sonar/plugins/scm/perforce/PerforceConfiguration.java
+++ b/src/main/java/org/sonar/plugins/scm/perforce/PerforceConfiguration.java
@@ -19,22 +19,24 @@
*/
package org.sonar.plugins.scm.perforce;
-import com.google.common.collect.ImmutableList;
-import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs;
-import org.sonar.api.BatchComponent;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+
import org.sonar.api.CoreProperties;
import org.sonar.api.PropertyType;
import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.ScannerSide;
+import org.sonar.api.config.Configuration;
import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.config.Settings;
import org.sonar.api.resources.Qualifiers;
-import javax.annotation.CheckForNull;
-
-import java.util.List;
+import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs;
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class PerforceConfiguration implements BatchComponent {
+@ScannerSide
+public class PerforceConfiguration {
private static final String FALSE = "false";
private static final String CATEGORY_PERFORCE = "Perforce";
@@ -47,14 +49,15 @@ public class PerforceConfiguration implements BatchComponent {
private static final String CHARSET_PROP_KEY = "sonar.perforce.charset";
private static final String SOCKSOTIMEOUT_PROP_KEY = "sonar.perforce.sockSoTimeout";
- private final Settings settings;
-
- public PerforceConfiguration(Settings settings) {
+
+ private final Configuration settings;
+
+ public PerforceConfiguration(Configuration settings) {
this.settings = settings;
}
public static List getProperties() {
- return ImmutableList.of(
+ return Arrays.asList(
PropertyDefinition.builder(PORT_PROP_KEY)
.name("Perforce service port")
.description("The host and port number of the Perforce service with which to communicate. Format is host:port.")
@@ -133,40 +136,40 @@ public static List getProperties() {
@CheckForNull
public String port() {
- return settings.getString(PORT_PROP_KEY);
+ return settings.get(PORT_PROP_KEY).orElse(null);
}
@CheckForNull
public String username() {
- return settings.getString(USER_PROP_KEY);
+ return settings.get(USER_PROP_KEY).orElse(null);
}
@CheckForNull
public String password() {
- return settings.getString(PASSWORD_PROP_KEY);
+ return settings.get(PASSWORD_PROP_KEY).orElse(null);
}
@CheckForNull
public String charset() {
- return settings.getString(CHARSET_PROP_KEY);
+ return settings.get(CHARSET_PROP_KEY).orElse(null);
}
- public boolean useSsl() {
- return settings.getBoolean(USESSL_PROP_KEY);
+ public Boolean useSsl() {
+ return settings.getBoolean(USESSL_PROP_KEY).orElse(null);
}
@CheckForNull
public String clientName() {
- return settings.getString(CLIENT_PROP_KEY);
+ return settings.get(CLIENT_PROP_KEY).orElse(null);
}
@CheckForNull
public String clientImpersonatedHostname() {
- return settings.getString(CLIENT_IMPERSONATED_HOST_PROP_KEY);
+ return settings.get(CLIENT_IMPERSONATED_HOST_PROP_KEY).orElse(null);
}
- public int sockSoTimeout() {
- return settings.getInt(SOCKSOTIMEOUT_PROP_KEY);
+ public Integer sockSoTimeout() {
+ return settings.getInt(SOCKSOTIMEOUT_PROP_KEY).orElse(null);
}
}
diff --git a/src/main/java/org/sonar/plugins/scm/perforce/PerforceExecutor.java b/src/main/java/org/sonar/plugins/scm/perforce/PerforceExecutor.java
index 0030223..88be1d5 100644
--- a/src/main/java/org/sonar/plugins/scm/perforce/PerforceExecutor.java
+++ b/src/main/java/org/sonar/plugins/scm/perforce/PerforceExecutor.java
@@ -19,6 +19,20 @@
*/
package org.sonar.plugins.scm.perforce;
+import java.io.File;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Optional;
+import java.util.Properties;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.utils.MessageException;
+
import com.perforce.p4java.client.IClient;
import com.perforce.p4java.client.IClientViewMapping;
import com.perforce.p4java.core.file.FileSpecBuilder;
@@ -34,16 +48,6 @@
import com.perforce.p4java.server.IOptionsServer;
import com.perforce.p4java.server.ServerFactory;
import com.perforce.p4java.server.callback.ICommandCallback;
-import java.io.File;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.Properties;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.utils.MessageException;
public class PerforceExecutor {
diff --git a/src/main/java/org/sonar/plugins/scm/perforce/PerforcePlugin.java b/src/main/java/org/sonar/plugins/scm/perforce/PerforcePlugin.java
index 14f8596..76c6202 100644
--- a/src/main/java/org/sonar/plugins/scm/perforce/PerforcePlugin.java
+++ b/src/main/java/org/sonar/plugins/scm/perforce/PerforcePlugin.java
@@ -19,23 +19,27 @@
*/
package org.sonar.plugins.scm.perforce;
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.SonarPlugin;
-
import java.util.ArrayList;
import java.util.List;
-public final class PerforcePlugin extends SonarPlugin {
+import org.sonar.api.Plugin;
+
+import com.google.common.collect.ImmutableList;
+
+public final class PerforcePlugin implements Plugin {
+
+ @Override
+ public void define(Context context) {
+ context.addExtensions(getExtensions());
- @Override
- public List getExtensions() {
- List result = new ArrayList();
- result.addAll(ImmutableList.of(
- PerforceScmProvider.class,
- PerforceBlameCommand.class,
- PerforceConfiguration.class));
- result.addAll(PerforceConfiguration.getProperties());
- return result;
- }
+ }
+ public List getExtensions() {
+ List result = new ArrayList();
+ result.addAll(
+ ImmutableList.of(PerforceScmProvider.class,
+ PerforceBlameCommand.class, PerforceConfiguration.class, PerforceExecutor.class));
+ result.addAll(PerforceConfiguration.getProperties());
+ return result;
+ }
}
diff --git a/src/test/java/org/sonar/plugins/scm/perforce/PerforceBlameCommandTest.java b/src/test/java/org/sonar/plugins/scm/perforce/PerforceBlameCommandTest.java
index 30513d9..e1928ee 100644
--- a/src/test/java/org/sonar/plugins/scm/perforce/PerforceBlameCommandTest.java
+++ b/src/test/java/org/sonar/plugins/scm/perforce/PerforceBlameCommandTest.java
@@ -97,7 +97,7 @@ public void testBlameSubmittedFile() throws Exception {
when(line5ChangeList4.getDepotPath()).thenReturn("foo/bar/src/Foo.java");
when(line5ChangeList4.getLower()).thenReturn(4);
- Map> result = new HashMap<>();
+ Map> result = new HashMap>();
IFileSpec fileSpecResult = mock(IFileSpec.class);
when(fileSpecResult.getOpStatus()).thenReturn(FileSpecOpStatus.VALID);
IFileRevisionData revision3 = mock(IFileRevisionData.class);
diff --git a/src/test/java/org/sonar/plugins/scm/perforce/PerforceConfigurationTest.java b/src/test/java/org/sonar/plugins/scm/perforce/PerforceConfigurationTest.java
index 6993753..abff53b 100644
--- a/src/test/java/org/sonar/plugins/scm/perforce/PerforceConfigurationTest.java
+++ b/src/test/java/org/sonar/plugins/scm/perforce/PerforceConfigurationTest.java
@@ -19,27 +19,31 @@
*/
package org.sonar.plugins.scm.perforce;
-import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.Test;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.ConfigurationBridge;
+import org.sonar.api.config.internal.MapSettings;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs;
public class PerforceConfigurationTest {
- @Test
- public void checkDefaultValues() {
- Settings settings = new Settings(new PropertyDefinitions(PerforceConfiguration.getProperties()));
+ @Test
+ public void checkDefaultValues() {
+ Settings settings = new MapSettings(new PropertyDefinitions(PerforceConfiguration.getProperties()));
+ ConfigurationBridge bridge = new ConfigurationBridge(settings);
- PerforceConfiguration config = new PerforceConfiguration(settings);
- assertThat(config.charset()).isNull();
- assertThat(config.clientName()).isNull();
- assertThat(config.clientImpersonatedHostname()).isNull();
- assertThat(config.port()).isNull();
- assertThat(config.username()).isNull();
- assertThat(config.password()).isNull();
- assertThat(config.useSsl()).isFalse();
- assertThat(config.sockSoTimeout()).isEqualTo(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_DEFAULT);
- }
+ PerforceConfiguration config = new PerforceConfiguration(bridge);
+ assertThat(config.charset()).isNull();
+ assertThat(config.clientName()).isNull();
+ assertThat(config.clientImpersonatedHostname()).isNull();
+ assertThat(config.port()).isNull();
+ assertThat(config.username()).isNull();
+ assertThat(config.password()).isNull();
+ assertThat(config.useSsl()).isFalse();
+ assertThat(config.sockSoTimeout()).isEqualTo(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_DEFAULT);
+ }
}
diff --git a/src/test/java/org/sonar/plugins/scm/perforce/PerforcePluginTest.java b/src/test/java/org/sonar/plugins/scm/perforce/PerforcePluginTest.java
index 96a5492..29984d7 100644
--- a/src/test/java/org/sonar/plugins/scm/perforce/PerforcePluginTest.java
+++ b/src/test/java/org/sonar/plugins/scm/perforce/PerforcePluginTest.java
@@ -27,6 +27,6 @@ public class PerforcePluginTest {
@Test
public void getExtensions() {
- assertThat(new PerforcePlugin().getExtensions()).hasSize(11);
+ assertThat(new PerforcePlugin().getExtensions()).hasSize(12);
}
}