BUG-2506: split out maven binding 90/13590/2
authorRobert Varga <rovarga@cisco.com>
Fri, 12 Dec 2014 11:07:45 +0000 (12:07 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 12 Dec 2014 11:23:16 +0000 (12:23 +0100)
Maven integration needs to be split out of the runtime implementation,
simply because we do not want to pull the requisite runtime into our
containers. It would never be used there anyway.

Change-Id: Ided36e3b06316739a3829d758889ba523e7e19ad
Signed-off-by: Robert Varga <rovarga@cisco.com>
features/mdsal/pom.xml
opendaylight/md-sal/mdsal-artifacts/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-rest-docgen-maven/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-rest-docgen-maven/src/main/java/org/opendaylight/controller/sal/rest/doc/maven/StaticDocGenerator.java [moved from opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/StaticDocGenerator.java with 86% similarity]
opendaylight/md-sal/sal-rest-docgen/pom.xml

index 371d167..d81da18 100644 (file)
           </dependency>
           <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-rest-docgen</artifactId>
+            <artifactId>sal-rest-docgen-maven</artifactId>
             <version>${mdsal.version}</version>
             <type>jar</type>
           </dependency>
               <yangFilesRootDir>src</yangFilesRootDir>
               <codeGenerators>
                 <generator>
-                  <codeGeneratorClass>org.opendaylight.controller.sal.rest.doc.impl.StaticDocGenerator</codeGeneratorClass>
+                  <codeGeneratorClass>org.opendaylight.controller.sal.rest.doc.maven.StaticDocGenerator</codeGeneratorClass>
                   <outputBaseDir>${project.build.directory}/generated-resources/swagger-api-documentation/explorer/static</outputBaseDir>
                 </generator>
               </codeGenerators>
index c765aa8..01a55e8 100644 (file)
                 <artifactId>sal-rest-docgen</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.controller</groupId>
+                <artifactId>sal-rest-docgen-maven</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- Toaster -->
             <dependency>
index 6c87899..9f342b8 100644 (file)
@@ -63,6 +63,7 @@
 
     <!-- Documentation -->
     <module>sal-rest-docgen</module>
+    <module>sal-rest-docgen-maven</module>
 
     <module>sal-akka-raft</module>
 
diff --git a/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml b/opendaylight/md-sal/sal-rest-docgen-maven/pom.xml
new file mode 100644 (file)
index 0000000..80e43d6
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>sal-parent</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>sal-rest-docgen-maven</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-rest-docgen</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-maven-plugin-spi</artifactId>
+        </dependency>
+    </dependencies>
+</project>
@@ -5,33 +5,31 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.controller.sal.rest.doc.impl;
+package org.opendaylight.controller.sal.rest.doc.maven;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
-
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration;
-import org.opendaylight.controller.sal.rest.doc.swagger.Resource;
-import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
-
-import javax.ws.rs.core.UriInfo;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import javax.ws.rs.core.UriInfo;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.opendaylight.controller.sal.rest.doc.impl.ApiDocGenerator;
+import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration;
+import org.opendaylight.controller.sal.rest.doc.swagger.Resource;
+import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class gathers all yang defined {@link Module}s and generates Swagger compliant documentation.
@@ -41,13 +39,12 @@ public class StaticDocGenerator extends ApiDocGenerator implements CodeGenerator
     private static final String DEFAULT_OUTPUT_BASE_DIR_PATH = "target" + File.separator + "generated-resources"
         + File.separator + "swagger-api-documentation";
 
-    private static Logger _logger = LoggerFactory.getLogger(ApiDocGenerator.class);
+    private static final Logger _logger = LoggerFactory.getLogger(ApiDocGenerator.class);
 
     private MavenProject mavenProject;
     private File projectBaseDir;
     private Map<String, String> additionalConfig;
     private File resourceBaseDir;
-    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 
     /**
      *
@@ -58,15 +55,16 @@ public class StaticDocGenerator extends ApiDocGenerator implements CodeGenerator
      * @throws IOException
      */
     @Override
-    public Collection<File> generateSources(SchemaContext context, File outputDir, Set<Module> yangModules) throws IOException {
+    public Collection<File> generateSources(final SchemaContext context, final File outputDir, final Set<Module> yangModules) throws IOException {
         List<File> result = new ArrayList<>();
 
         // Create Base Directory
         final File outputBaseDir;
         if (outputDir == null) {
             outputBaseDir = new File(DEFAULT_OUTPUT_BASE_DIR_PATH);
+        } else {
+            outputBaseDir = outputDir;
         }
-        else outputBaseDir = outputDir;
         outputBaseDir.mkdirs();
 
         // Create Resources directory
@@ -114,7 +112,7 @@ public class StaticDocGenerator extends ApiDocGenerator implements CodeGenerator
     }
 
     @Override
-    protected String generatePath(UriInfo uriInfo, String name, String revision) {
+    protected String generatePath(final UriInfo uriInfo, final String name, final String revision) {
         if (uriInfo == null) {
             return name + "(" + revision + ")";
         }
@@ -122,7 +120,7 @@ public class StaticDocGenerator extends ApiDocGenerator implements CodeGenerator
     }
 
     @Override
-    protected String createBasePathFromUriInfo(UriInfo uriInfo) {
+    protected String createBasePathFromUriInfo(final UriInfo uriInfo) {
         if (uriInfo == null) {
             return RESTCONF_CONTEXT_ROOT;
         }
@@ -130,21 +128,21 @@ public class StaticDocGenerator extends ApiDocGenerator implements CodeGenerator
     }
 
     @Override
-    public void setLog(Log log) {
+    public void setLog(final Log log) {
     }
 
     @Override
-    public void setAdditionalConfig(Map<String, String> additionalConfig) {
+    public void setAdditionalConfig(final Map<String, String> additionalConfig) {
         this.additionalConfig = additionalConfig;
     }
 
     @Override
-    public void setResourceBaseDir(File resourceBaseDir) {
+    public void setResourceBaseDir(final File resourceBaseDir) {
         this.resourceBaseDir = resourceBaseDir;
     }
 
     @Override
-    public void setMavenProject(MavenProject mavenProject) {
+    public void setMavenProject(final MavenProject mavenProject) {
         this.mavenProject = mavenProject;
         this.projectBaseDir = mavenProject.getBasedir();
     }
index 53f1b2e..22a128c 100644 (file)
       <artifactId>yang-parser-impl</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-maven-plugin-spi</artifactId>
-    </dependency>
-
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>