]> source.dussan.org Git - sonarqube.git/commitdiff
Exclude some WS from code generation
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 23 Nov 2017 16:19:32 +0000 (17:19 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 29 Nov 2017 19:24:11 +0000 (20:24 +0100)
sonar-ws-generator/pom.xml
sonar-ws-generator/src/main/java/org/sonarqube/wsgenerator/CodeFormatter.java

index b52b94a7c959aa23703cffd77f1a5bb9e08f319e..daa9340183335d7216a3a88c10a09f802adc720e 100644 (file)
     </dependency>
   </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>add-source</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>target/generated-sources/results</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>assemble-all</id>
-            <phase>package</phase>
-            <goals>
-              <goal>single</goal>
-            </goals>
-            <configuration>
-              <descriptorRefs>
-                <descriptorRef>jar-with-dependencies</descriptorRef>
-              </descriptorRefs>
-              <archive>
-                <manifest>
-                  <mainClass>org.sonarqube.wsgenerator.Generator</mainClass>
-                </manifest>
-              </archive>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
+  <profiles>
+    <profile>
+      <id>run-ws-generator</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-assembly-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>assemble-all</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>single</goal>
+                </goals>
+                <configuration>
+                  <descriptorRefs>
+                    <descriptorRef>jar-with-dependencies</descriptorRef>
+                  </descriptorRefs>
+                  <archive>
+                    <manifest>
+                      <mainClass>org.sonarqube.wsgenerator.Generator</mainClass>
+                    </manifest>
+                  </archive>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 
 </project>
index 8a610263887e1440fb899ed996be93abe8446773..1d062a2f9aab916b9ed080fb9e80563adc620103 100644 (file)
@@ -30,7 +30,10 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Properties;
+import java.util.Set;
 import org.apache.commons.io.FileUtils;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
@@ -39,6 +42,10 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 
 public class CodeFormatter {
 
+  private static final Set<String> PATH_EXCLUSIONS = new HashSet<>(Arrays.asList(
+    "api/components", "api/issues", "api/measures", "api/organizations", "api/permissions", "api/projects",
+    "api/project_analyses", "api/qualityprofiles", "api/rules", "api/settings", "api/users", "api/user_groups"));
+
   public static void format(String json) {
     JsonObject jsonElement = new Gson().fromJson(json, JsonObject.class);
     JsonArray webServices = (JsonArray) jsonElement.get("webServices");
@@ -47,13 +54,17 @@ public class CodeFormatter {
 
     for (JsonElement webServiceElement : webServices) {
       JsonObject webService = (JsonObject) webServiceElement;
+      String webServicePath = webService.get("path").getAsString();
+
+      if (PATH_EXCLUSIONS.contains(webServicePath)) {
+        continue;
+      }
 
       VelocityContext webServiceContext = new VelocityContext();
       webServiceContext.put("webService", webServiceElement);
       webServiceContext.put("helper", helper);
 
       String webServiceCode = applyTemplate("webService.vm", webServiceContext);
-      String webServicePath = webService.get("path").getAsString();
       writeSourceFile(helper.file(webServicePath), webServiceCode);
       writeSourceFile(helper.packageInfoFile(webServicePath), applyTemplate("package-info.vm", webServiceContext));