Merge "Removed unrequired dependencies of runtime."
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 64e108a..2ffc01f 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -85,11 +85,37 @@
<configuration>
<instructions>
<Export-Package>
- org.onosproject.yang.runtime.*
+ org.onosproject.yang.runtime.*,
+ org.osgi.*,
+ org.onosproject.yang.compiler.datamodel.*
</Export-Package>
</instructions>
</configuration>
</plugin>
+ <!--
+ Cleans up generated test artifacts which get included as a source
+ directory, but which we don't want as part of the bundle.
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <delete>
+ <fileset dir="${project.build.outputDirectory}/org/onosproject/yang/gen" includes="**/*"/>
+ </delete>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/RuntimeHelper.java b/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/RuntimeHelper.java
index 1f2ae25..1cd1dc4 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/RuntimeHelper.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/RuntimeHelper.java
@@ -16,10 +16,10 @@
package org.onosproject.yang.runtime.helperutils;
-import org.onosproject.yang.model.YangModel;
-import org.onosproject.yang.model.YangModule;
import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.model.YangModel;
+import org.onosproject.yang.model.YangModule;
import java.io.IOException;
import java.io.InputStream;
@@ -29,10 +29,6 @@
import java.util.Set;
import static org.onosproject.yang.runtime.helperutils.YangApacheUtils.getYangModel;
-import static org.onosproject.yang.compiler.utils.UtilConstants.OP_PARAM;
-import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
-import static org.onosproject.yang.compiler.utils.UtilConstants.SERVICE;
-import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase;
/**
* Represents utility for runtime. These utilities can be used by application
@@ -41,6 +37,10 @@
*/
public final class RuntimeHelper {
+ public static final String OP_PARAM = "OpParam";
+ public static final String PERIOD = ".";
+ public static final String SERVICE = "Service";
+
// Forbid construction.
private RuntimeHelper() {
}
@@ -124,4 +124,38 @@
public static String getDateInStringFormat(YangNode schemaNode) {
return YangApacheUtils.getDateInStringFormat(schemaNode);
}
+
+ /**
+ * Returns the YANG identifier name as java identifier with first letter
+ * in capital.
+ *
+ * @param yangIdentifier identifier in YANG file
+ * @return corresponding java identifier
+ */
+ public static String getCapitalCase(String yangIdentifier) {
+ yangIdentifier = yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
+ return restrictConsecutiveCapitalCase(yangIdentifier);
+ }
+
+ /**
+ * Restricts consecutive capital cased string as a rule in camel case.
+ *
+ * @param consecCapitalCaseRemover which requires the restriction of consecutive capital case
+ * @return string without consecutive capital case
+ */
+ private static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) {
+
+ for (int k = 0; k < consecCapitalCaseRemover.length(); k++) {
+ if (k + 1 < consecCapitalCaseRemover.length()) {
+ if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k))) {
+ if (Character.isUpperCase(consecCapitalCaseRemover.charAt(k + 1))) {
+ consecCapitalCaseRemover = consecCapitalCaseRemover.substring(0, k + 1)
+ + consecCapitalCaseRemover.substring(k + 1, k + 2).toLowerCase()
+ + consecCapitalCaseRemover.substring(k + 2);
+ }
+ }
+ }
+ }
+ return consecCapitalCaseRemover;
+ }
}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java b/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java
index e039fcf..04823cf 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java
@@ -16,14 +16,14 @@
package org.onosproject.yang.runtime.helperutils;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
import org.onosproject.yang.model.DefaultYangModel;
import org.onosproject.yang.model.DefaultYangModule;
import org.onosproject.yang.model.DefaultYangModuleId;
import org.onosproject.yang.model.YangModel;
import org.onosproject.yang.model.YangModule;
import org.onosproject.yang.model.YangModuleId;
-import org.onosproject.yang.compiler.datamodel.YangNode;
-import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
@@ -37,11 +37,6 @@
import static java.nio.file.Paths.get;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.parseJarFile;
-import static org.onosproject.yang.compiler.utils.UtilConstants.HYPHEN;
-import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
-import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
-import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_META_DATA;
-import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_RESOURCES;
import static org.osgi.framework.FrameworkUtil.getBundle;
import static org.slf4j.LoggerFactory.getLogger;
@@ -50,6 +45,11 @@
*/
public final class YangApacheUtils {
+ public static final String SLASH = File.separator;
+ public static final String HYPHEN = "-";
+ public static final String PERIOD = ".";
+ public static final String YANG_META_DATA = "YangMetaData.ser";
+ public static final String YANG_RESOURCES = "yang/resources";
private static final String SYSTEM = SLASH + "system" + SLASH;
private static final String MAVEN = "mvn:";
private static final String JAR = ".jar";
diff --git a/serializers/xml/pom.xml b/serializers/xml/pom.xml
index fc139e0..164e49b 100644
--- a/serializers/xml/pom.xml
+++ b/serializers/xml/pom.xml
@@ -80,13 +80,11 @@
<goal>run</goal>
</goals>
<configuration>
- <tasks>
+ <target>
<delete>
- <fileset
- dir="${project.build.outputDirectory}/org/onosproject/yang/gen"
- includes="**/*"/>
+ <fileset dir="${project.build.outputDirectory}/org/onosproject/yang/gen" includes="**/*"/>
</delete>
- </tasks>
+ </target>
</configuration>
</execution>
</executions>