Maven archetype for config subsystem aware bundles 64/5064/3
authorMaros Marsalek <mmarsale@cisco.com>
Fri, 31 Jan 2014 13:35:27 +0000 (14:35 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Tue, 4 Feb 2014 07:57:43 +0000 (08:57 +0100)
Change-Id: I0b109770f03917b923de3d4fd78d91f43eded4e2
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/config/config-module-archetype/pom.xml [new file with mode: 0644]
opendaylight/config/config-module-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml [new file with mode: 0644]
opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/pom.xml [new file with mode: 0644]
opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/src/main/yang/__module-name__-impl.yang [new file with mode: 0644]
opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/src/main/yang/__module-name__.yang [new file with mode: 0644]
opendaylight/config/pom.xml

diff --git a/opendaylight/config/config-module-archetype/pom.xml b/opendaylight/config/config-module-archetype/pom.xml
new file mode 100644 (file)
index 0000000..42c9105
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-subsystem</artifactId>
+    <version>0.2.4-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>config-module-archetype</artifactId>
+  <name>config-module-archetype</name>
+  <description>Archetype for new module managed by configuration subsystem</description>
+
+</project>
diff --git a/opendaylight/config/config-module-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/opendaylight/config/config-module-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644 (file)
index 0000000..fc30b4d
--- /dev/null
@@ -0,0 +1,46 @@
+<archetype>
+    <id>config-module-archetype</id>
+
+    <allowPartial>true</allowPartial>
+
+    <requiredProperties>
+        <requiredProperty key="module-name">
+        </requiredProperty>
+        <requiredProperty key="module-name-java-prefix">
+        </requiredProperty>
+        <requiredProperty key="module-implementation-name">
+            <defaultValue>impl</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="config-api-yang-revision">
+            <defaultValue>2013-04-05</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="config-api-version">
+            <defaultValue>0.2.4-SNAPSHOT</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="yang-maven-plugin-version">
+            <defaultValue>0.6.2-SNAPSHOT</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="revision">
+            <defaultValue>2014-01-31</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="service-java-class">
+            <defaultValue>java.lang.AutoCloseable</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="maven-bundle-plugin-version">
+            <defaultValue>2.4.0</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="yang-namespace-mapping-from">
+            <defaultValue>urn:opendaylight:params:xml:ns:yang:controller</defaultValue>
+        </requiredProperty>
+        <requiredProperty key="yang-namespace-mapping-to">
+            <defaultValue>org.opendaylight.controller.config.yang</defaultValue>
+        </requiredProperty>
+
+    </requiredProperties>
+
+    <fileSets>
+        <fileSet filtered="true" encoding="UTF-8">
+            <directory>src/main/yang</directory>
+        </fileSet>
+    </fileSets>
+</archetype>
diff --git a/opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/pom.xml b/opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/pom.xml
new file mode 100644 (file)
index 0000000..d1c371d
--- /dev/null
@@ -0,0 +1,104 @@
+<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>
+
+  <groupId>${groupId}</groupId>
+  <artifactId>${artifactId}</artifactId>
+  <version>${version}</version>
+  <packaging>bundle</packaging>
+
+    <properties>
+        <jmxGeneratorPath>${project.build.directory}/generated-sources/config</jmxGeneratorPath>
+        <config.version>${config-api-version}</config.version>
+        <maven.bundle.version>${maven-bundle-plugin-version}</maven.bundle.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>${yang-maven-plugin-version}</version>
+                <executions>
+                    <execution>
+                        <id>config</id>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>
+                                            ${yang-namespace-mapping-from}==${yang-namespace-mapping-to}
+                                        </namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>yang-jmx-generator-plugin</artifactId>
+                        <version>${config.version}</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${jmxGeneratorPath}</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${maven.bundle.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            ${yang-namespace-mapping-to}.${module-name},
+                        </Export-Package>
+                        <Import-Package>
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+
+        </plugins>
+    </build>
+</project>
diff --git a/opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/src/main/yang/__module-name__-impl.yang b/opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/src/main/yang/__module-name__-impl.yang
new file mode 100644 (file)
index 0000000..8c1dab1
--- /dev/null
@@ -0,0 +1,54 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module ${module-name}-${module-implementation-name} {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:${module-name}:${module-implementation-name}";
+    prefix "${module-name}-${module-implementation-name}";
+
+    import config { prefix config; revision-date ${config-api-yang-revision}; }
+    import ${module-name} { prefix ${module-name}; revision-date ${revision}; }
+
+    description
+        "This module contains the base YANG definitions for
+        ${module-name} ${module-implementation-name} implementation.";
+
+    revision "${revision}" {
+        description
+            "Initial revision.";
+    }
+
+    // This is the definition of a service implementation
+    identity ${module-name}-${module-implementation-name} {
+            base config:module-type;
+            config:provided-service ${module-name}:${module-name};
+            config:java-name-prefix ${module-name-java-prefix};
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case ${module-name}-${module-implementation-name} {
+            when "/config:modules/config:module/config:type = '${module-name}-${module-implementation-name}'";
+
+            leaf simple-attribute {
+                type uint32;
+            }
+
+            container dto-attribute {
+                leaf inner-attribute {
+                    type string;
+                }
+            }
+
+            // Dependency attribute demonstration, the config:required-identity points to a service type
+            // In this case it is the same service type as this implementation provides: ${module-name}
+            container dependency-attribute {
+                uses config:service-ref {
+                    refine type {
+                        mandatory false;
+                        config:required-identity ${module-name}:${module-name};
+                    }
+                }
+            }
+
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/src/main/yang/__module-name__.yang b/opendaylight/config/config-module-archetype/src/main/resources/archetype-resources/src/main/yang/__module-name__.yang
new file mode 100644 (file)
index 0000000..2afc91e
--- /dev/null
@@ -0,0 +1,27 @@
+// vi: set smarttab et sw=4 tabstop=4:
+module ${module-name} {
+
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:${module-name}";
+    prefix "${module-name}";
+
+    import config { prefix config; revision-date ${config-api-yang-revision}; }
+
+    description
+        "This module contains the base YANG definitions for
+        ${module-name} services.";
+
+    revision "${revision}" {
+        description
+            "Initial revision.";
+    }
+
+    // This is the definition of a service
+    identity ${module-name} {
+
+        base "config:service-type";
+
+        // TODO modify the java class
+        config:java-class " ${service-java-class}";
+    }
+}
\ No newline at end of file
index dbf8654d6e6ea15a3349688b072ce649bc292a58..80621a4d449b0a2ccdee94ec865a8744f437735d 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<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/xsd/maven-4.0.0.xsd">
+<!-- vi: set et smarttab sw=4 tabstop=4: --><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/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -44,6 +43,7 @@
         <module>yang-test-plugin</module>
         <module>shutdown-api</module>
         <module>shutdown-impl</module>
+        <module>config-module-archetype</module>
     </modules>
 
     <profiles>
                                         </goals>
                                     </pluginExecutionFilter>
                                     <action>
-                                        <ignore />
+                                        <ignore/>
                                     </action>
                                 </pluginExecution>
                             </pluginExecutions>
             </plugins>
         </pluginManagement>
     </build>
-</project>
+</project>
\ No newline at end of file