]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6430 add plugin source revision to JSON response 258/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 24 Apr 2015 15:24:44 +0000 (17:24 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 27 Apr 2015 09:16:46 +0000 (11:16 +0200)
information added to response of WS listing installed pluging and pending operations on plugins

server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/main/java/org/sonar/server/plugins/ws/PluginWSCommons.java
server/sonar-server/src/main/resources/org/sonar/server/plugins/ws/example-installed_plugins.json
server/sonar-server/src/main/resources/org/sonar/server/plugins/ws/example-pending_plugins.json
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/InstalledPluginsWsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PendingPluginsWsActionTest.java
sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginMetadata.java

index e0c14535118d91c3f138bf9c4bbb84f552a4b71d..5cf50dc2bd3ffc211e2de891a567009c99e10bc4 100644 (file)
  */
 package org.sonar.server.platform;
 
-import com.google.common.collect.Lists;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+import javax.annotation.Nullable;
+
 import org.sonar.api.config.EmailSettings;
 import org.sonar.api.issue.action.Actions;
 import org.sonar.api.platform.ComponentContainer;
@@ -387,11 +393,7 @@ import org.sonar.server.view.index.ViewIndexer;
 import org.sonar.server.ws.ListingWs;
 import org.sonar.server.ws.WebServiceEngine;
 
-import javax.annotation.Nullable;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
+import com.google.common.collect.Lists;
 
 class ServerComponents {
 
index e4cfcba045aeb70b643708b4ffe5e3d4c7549e3e..1e694e0ed140dc139b55c1f7ffc10150d52d6263 100644 (file)
@@ -22,6 +22,8 @@ package org.sonar.server.plugins.ws;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.collect.Ordering;
+import java.util.Comparator;
+import javax.annotation.Nonnull;
 import org.sonar.api.platform.PluginMetadata;
 import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.updatecenter.common.Artifact;
@@ -30,9 +32,6 @@ import org.sonar.updatecenter.common.PluginUpdate;
 import org.sonar.updatecenter.common.Release;
 import org.sonar.updatecenter.common.UpdateCenter;
 
-import javax.annotation.Nonnull;
-import java.util.Comparator;
-
 import static com.google.common.collect.Iterables.filter;
 import static com.google.common.collect.Iterables.transform;
 import static java.lang.String.CASE_INSENSITIVE_ORDER;
@@ -57,6 +56,7 @@ public class PluginWSCommons {
   static final String OBJECT_RELEASE = "release";
   static final String ARRAY_REQUIRES = "requires";
   static final String PROPERTY_UPDATE_CENTER_REFRESH = "updateCenterRefresh";
+  static final String PROPERTY_IMPLEMENTATION_BUILD = "implementationBuild";
 
   public static final Ordering<PluginMetadata> NAME_KEY_PLUGIN_METADATA_COMPARATOR = Ordering.natural()
     .onResultOf(PluginMetadataToName.INSTANCE)
@@ -89,6 +89,7 @@ public class PluginWSCommons {
     jsonWriter.prop(PROPERTY_ORGANIZATION_URL, pluginMetadata.getOrganizationUrl());
     jsonWriter.prop(PROPERTY_HOMEPAGE, pluginMetadata.getHomepage());
     jsonWriter.prop(PROPERTY_ISSUE_TRACKER_URL, pluginMetadata.getIssueTrackerUrl());
+    jsonWriter.prop(PROPERTY_IMPLEMENTATION_BUILD, pluginMetadata.getImplementationBuild());
   }
 
   public void writeArtifact(JsonWriter jsonWriter, PluginMetadata pluginMetadata) {
index 4ae7034f0b2966980c6ac6b41822d88e54ebc9be..5c87a337d370f16707c519fa8e91652e6b88aca6 100644 (file)
@@ -10,6 +10,7 @@
       "organizationUrl": "http://www.sonarsource.com",
       "homepage": "http://redirect.sonarsource.com/plugins/scmgit.html",
       "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCGIT",
+      "implementationBuild": "9ce9d330c313c296fab051317cc5ad4b26319e07",
       "artifact": {
         "name": "sonar-scm-git-plugin-1.0.jar"
       }
@@ -24,6 +25,7 @@
       "organizationUrl": "http://www.sonarsource.com",
       "homepage": "http://redirect.sonarsource.com/plugins/java.html",
       "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARJAVA",
+      "implementationBuild": "65396a609ddface8b311a6a665aca92a7da694f1",
       "artifact": {
         "name": "sonar-java-plugin-3.0.jar"
       }
@@ -38,6 +40,7 @@
       "organizationUrl": "http://www.sonarsource.com",
       "homepage": "http://redirect.sonarsource.com/plugins/scmsvn.html",
       "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCSVN",
+      "implementationBuild": "213fc8a8b582ff530b12dd4a59a6512be1071234",
       "artifact": {
         "name": "sonar-scm-svn-plugin-1.0.jar"
       }
index 4e47bfe774bd015d86df674c6725d11a8119d16e..508127f2ff53c483df08c17072ca303df7a51031 100644 (file)
@@ -11,6 +11,7 @@
       "organizationUrl": "http://www.sonarsource.com",
       "homepage": "http://redirect.sonarsource.com/plugins/scmgit.html",
       "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCGIT",
+      "implementationBuild": "9ce9d330c313c296fab051317cc5ad4b26319e07",
       "artifact": {
         "name": "sonar-scm-git-plugin-1.0.jar"
       }
@@ -25,6 +26,7 @@
       "organizationUrl": "http://www.sonarsource.com",
       "homepage": "http://redirect.sonarsource.com/plugins/java.html",
       "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARJAVA",
+      "implementationBuild": "65396a609ddface8b311a6a665aca92a7da694f1",
       "artifact": {
         "name": "sonar-java-plugin-3.0.jar"
       }
@@ -42,6 +44,7 @@
       "organizationUrl": "http://www.sonarsource.com",
       "homepage": "http://redirect.sonarsource.com/plugins/scmsvn.html",
       "issueTrackerUrl": "http://jira.codehaus.org/browse/SONARSCSVN",
+      "implementationBuild": "213fc8a8b582ff530b12dd4a59a6512be1071234",
       "artifact": {
         "name": "sonar-scm-svn-plugin-1.0.jar"
       }
index 6edf1af52644a66323e1a1ac0952373683569e87..3a79c281858f5434b6e4f916de5994e7490816fe 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.plugins.ws;
 
+import java.io.File;
 import org.junit.Test;
 import org.sonar.api.platform.PluginMetadata;
 import org.sonar.api.platform.PluginRepository;
@@ -27,8 +28,6 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.core.plugins.DefaultPluginMetadata;
 import org.sonar.server.ws.WsTester;
 
-import java.io.File;
-
 import static com.google.common.collect.ImmutableList.of;
 import static java.lang.String.valueOf;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -109,6 +108,7 @@ public class InstalledPluginsWsActionTest {
         .setHomepage("homepage_url")
         .setIssueTrackerUrl("issueTracker_url")
         .setFile(new File(getClass().getResource(jarFilename).toURI()))
+        .setImplementationBuild("sou_rev_sha1")
       )
       );
 
@@ -128,6 +128,7 @@ public class InstalledPluginsWsActionTest {
         "      \"organizationUrl\": \"org_url\"," +
         "      \"homepage\": \"homepage_url\"," +
         "      \"issueTrackerUrl\": \"issueTracker_url\"," +
+        "      \"implementationBuild\": \"sou_rev_sha1\"," +
         "      \"artifact\":" +
         "      {" +
         "        \"name\": \"some.jar\"" +
index 9cace284a825fece6242fe21c25d9de16e0f86a2..b865069d99d7826213ce583ec944ee5b36d9af16 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.plugins.ws;
 
+import java.io.File;
 import org.junit.Test;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.WebService;
@@ -27,8 +28,6 @@ import org.sonar.server.plugins.PluginDownloader;
 import org.sonar.server.plugins.ServerPluginJarsInstaller;
 import org.sonar.server.ws.WsTester;
 
-import java.io.File;
-
 import static com.google.common.collect.ImmutableList.of;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -47,7 +46,8 @@ public class PendingPluginsWsActionTest {
     .setOrganizationUrl("http://www.sonarsource.com")
     .setHomepage("http://redirect.sonarsource.com/plugins/scmgit.html")
     .setIssueTrackerUrl("http://jira.codehaus.org/browse/SONARSCGIT")
-    .setFile(new File("/home/user/sonar-scm-git-plugin-1.0.jar"));
+    .setFile(new File("/home/user/sonar-scm-git-plugin-1.0.jar"))
+    .setImplementationBuild("9ce9d330c313c296fab051317cc5ad4b26319e07");
   private static final String DUMMY_CONTROLLER_KEY = "dummy";
   public static final DefaultPluginMetadata PLUGIN_2_2 = create("key2").setName("name2");
   public static final DefaultPluginMetadata PLUGIN_2_1 = create("key1").setName("name2");
@@ -109,6 +109,7 @@ public class PendingPluginsWsActionTest {
         "      \"organizationUrl\": \"http://www.sonarsource.com\"," +
         "      \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
         "      \"issueTrackerUrl\": \"http://jira.codehaus.org/browse/SONARSCGIT\"," +
+        "      \"implementationBuild\": \"9ce9d330c313c296fab051317cc5ad4b26319e07\"," +
         "      \"artifact\": {" +
         "        \"name\": \"sonar-scm-git-plugin-1.0.jar\"" +
         "      }" +
@@ -140,6 +141,7 @@ public class PendingPluginsWsActionTest {
         "      \"organizationUrl\": \"http://www.sonarsource.com\"," +
         "      \"homepage\": \"http://redirect.sonarsource.com/plugins/scmgit.html\"," +
         "      \"issueTrackerUrl\": \"http://jira.codehaus.org/browse/SONARSCGIT\"," +
+        "      \"implementationBuild\": \"9ce9d330c313c296fab051317cc5ad4b26319e07\"," +
         "      \"artifact\": {" +
         "        \"name\": \"sonar-scm-git-plugin-1.0.jar\"" +
         "      }" +
index d9fcf3f02905e2a6309434636c66ab076ff09175..a65036b7d94f81380831f369c694bc8a733b3fe9 100644 (file)
@@ -263,6 +263,7 @@ public class DefaultPluginMetadata implements PluginMetadata, Comparable<PluginM
     return this;
   }
 
+  @Override
   public String getImplementationBuild() {
     return implementationBuild;
   }
index 2afd2312c3c22bd5e9984b5ef93639041837e52c..97ab71bcfc1e67bb319e58e8164bb04300be820e 100644 (file)
@@ -69,4 +69,6 @@ public interface PluginMetadata {
   List<String> getRequiredPlugins();
 
   boolean isCore();
+
+  String getImplementationBuild();
 }