pom.xml changes for bundle packaging
Change-Id: I7d4c85b24f79ec526db0cb74bcdf7f0659746163
diff --git a/compiler/api/pom.xml b/compiler/api/pom.xml
index e2398a6..66aa777 100644
--- a/compiler/api/pom.xml
+++ b/compiler/api/pom.xml
@@ -25,24 +25,14 @@
</parent>
<artifactId>onos-yang-compiler-api</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.0.2</version>
- <configuration>
- <skipIfEmpty>true</skipIfEmpty>
- </configuration>
- <executions>
- <execution>
- <id>default</id>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>3.2.0</version>
+ <extensions>true</extensions>
</plugin>
</plugins>
</build>
diff --git a/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModel.java b/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModel.java
deleted file mode 100644
index 18358bc..0000000
--- a/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModel.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents default YANG model implementation.
- */
-public class DefaultYangModel implements YangModel {
-
- private final Map<YangModuleId, YangModule> moduleMap;
-
- /**
- * Creates an instance of YANG model.
- */
- public DefaultYangModel() {
- moduleMap = new LinkedHashMap<>();
- }
-
- @Override
- public Set<YangModule> getYangModules() {
- Set<YangModule> modules = new LinkedHashSet<>();
- for (Map.Entry<YangModuleId, YangModule> entry : moduleMap.entrySet()) {
- modules.add(entry.getValue());
- }
- return modules;
- }
-
- @Override
- public Set<YangModuleId> getYangModulesId() {
- Set<YangModuleId> ids = new LinkedHashSet<>();
- for (Map.Entry<YangModuleId, YangModule> entry : moduleMap.entrySet()) {
- ids.add(entry.getKey());
- }
- return ids;
- }
-
- @Override
- public YangModule getYangModule(YangModuleId id) {
- return moduleMap.get(id);
- }
-
- @Override
- public void addModule(YangModuleId id, YangModule module) {
- moduleMap.put(id, module);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(moduleMap);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- DefaultYangModel that = (DefaultYangModel) obj;
-
- if (moduleMap.size() == that.moduleMap.size()) {
- for (Map.Entry<YangModuleId, YangModule> entry : moduleMap.entrySet()) {
- if (!that.moduleMap.containsKey(entry.getKey()) ||
- !that.moduleMap.containsValue(entry.getValue())) {
- return false;
- }
- }
- } else {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("model", moduleMap)
- .toString();
- }
-}
diff --git a/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModule.java b/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModule.java
deleted file mode 100644
index 3ccbd9c..0000000
--- a/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModule.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang;
-
-import org.onosproject.yang.compiler.api.YangCompilerException;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.nio.file.Path;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents default YANG module.
- */
-public class DefaultYangModule implements YangModule {
-
- private YangModuleId id;
- private Path yangSrc;
- private Path metadata;
-
- /**
- * Creates an instance of default YANG module.
- *
- * @param id YANG module id
- * @param yangSrc YANG source file path
- * @param metadata YANG metadata source file path
- */
- public DefaultYangModule(YangModuleId id, Path yangSrc, Path metadata) {
- checkNotNull(yangSrc);
- checkNotNull(metadata);
- checkNotNull(id);
- this.id = id;
- this.yangSrc = yangSrc;
- this.metadata = metadata;
- }
-
- @Override
- public YangModuleId getYangModuleId() {
- return id;
- }
-
- @Override
- public InputStream getYangSource() {
- try {
- return new FileInputStream(yangSrc.toString());
- } catch (FileNotFoundException e) {
- throw new YangCompilerException("Yang source file not found." +
- yangSrc);
- }
- }
-
- @Override
- public InputStream getMetadata() {
- try {
- return new FileInputStream(metadata.toString());
- } catch (FileNotFoundException e) {
- throw new YangCompilerException("metadata source file not found." +
- metadata);
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, yangSrc, metadata);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- DefaultYangModule that = (DefaultYangModule) obj;
- return Objects.equals(id, that.id) &&
- Objects.equals(yangSrc, that.yangSrc) &&
- Objects.equals(metadata, that.metadata);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("moduleId", id)
- .add("yangSource", yangSrc)
- .add("yangMetadata", metadata)
- .toString();
- }
-}
diff --git a/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModuleId.java b/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModuleId.java
deleted file mode 100644
index 2159990..0000000
--- a/compiler/api/src/main/java/org/onosproject/yang/DefaultYangModuleId.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents default YANG module identifier.
- */
-public class DefaultYangModuleId implements YangModuleId {
-
- private String moduleName;
- private String revision;
-
- /**
- * Creates an instance of default YANG module id.
- *
- * @param name name of module
- * @param rev revision of module
- */
- public DefaultYangModuleId(String name, String rev) {
- checkNotNull(name);
- moduleName = name;
- revision = rev;
- }
-
- @Override
- public String moduleName() {
- return moduleName;
- }
-
- @Override
- public String revision() {
- return revision;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(moduleName, revision);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- DefaultYangModuleId that = (DefaultYangModuleId) obj;
- return Objects.equals(moduleName, that.moduleName) &&
- Objects.equals(revision, that.revision);
- }
-
- @Override
- public String toString() {
- return toStringHelper(getClass())
- .add("moduleName", moduleName)
- .add("revision", revision)
- .toString();
- }
-}
diff --git a/compiler/api/src/main/java/org/onosproject/yang/YangModel.java b/compiler/api/src/main/java/org/onosproject/yang/YangModel.java
deleted file mode 100644
index fb45c27..0000000
--- a/compiler/api/src/main/java/org/onosproject/yang/YangModel.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang;
-
-import java.util.Set;
-
-/**
- * Representation of a compiled YANG model.
- */
-public interface YangModel {
-
- /**
- * Returns set of YANG module with information.
- *
- * @return YANG module info
- */
- Set<YangModule> getYangModules();
-
- /**
- * Returns set of YANG modules identifier.
- *
- * @return YANG module identifier
- */
- Set<YangModuleId> getYangModulesId();
-
- /**
- * Returns YANG module information corresponding to a given module
- * identifier.
- *
- * @param id module identifier
- * @return YANG module information
- */
- YangModule getYangModule(YangModuleId id);
-
- /**
- * Adds YANG module information for a given module identifier.
- *
- * @param id module identifier
- * @param module YANG module information
- */
- void addModule(YangModuleId id, YangModule module);
-}
diff --git a/compiler/api/src/main/java/org/onosproject/yang/YangModule.java b/compiler/api/src/main/java/org/onosproject/yang/YangModule.java
deleted file mode 100644
index 9b170fa..0000000
--- a/compiler/api/src/main/java/org/onosproject/yang/YangModule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang;
-
-import java.io.InputStream;
-
-/**
- * Representation of YANG module information.
- */
-public interface YangModule {
-
- /**
- * Returns YANG module identifier.
- *
- * @return module identifier
- */
- YangModuleId getYangModuleId();
-
- /**
- * Returns input stream corresponding to a given YANG file path.
- *
- * @return stream
- */
- InputStream getYangSource();
-
- /**
- * Returns metadata stream.
- *
- * @return stream
- */
- InputStream getMetadata();
-}
diff --git a/compiler/api/src/main/java/org/onosproject/yang/YangModuleId.java b/compiler/api/src/main/java/org/onosproject/yang/YangModuleId.java
deleted file mode 100644
index 44872df..0000000
--- a/compiler/api/src/main/java/org/onosproject/yang/YangModuleId.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang;
-
-/**
- * Representation of an entity which provides YANG module identifiers.
- * Reference RFC 7895.
- */
-public interface YangModuleId {
-
- /**
- * Returns the name of the YANG module.
- *
- * @return name of the YANG module
- */
- String moduleName();
-
- /**
- * Returns revision of the YANG module.
- * <p>
- * Reference RFC 7895
- * Each YANG module and submodule within the library has a
- * revision. This is derived from the most recent revision statement
- * within the module or submodule. If no such revision statement
- * exists, the module's or submodule's revision is the zero-length
- * string.
- *
- * @return revision of the YANG module
- */
- String revision();
-}
diff --git a/compiler/api/src/main/java/org/onosproject/yang/compiler/api/YangCompiledOutput.java b/compiler/api/src/main/java/org/onosproject/yang/compiler/api/YangCompiledOutput.java
index 4caedb8..a75fa34 100644
--- a/compiler/api/src/main/java/org/onosproject/yang/compiler/api/YangCompiledOutput.java
+++ b/compiler/api/src/main/java/org/onosproject/yang/compiler/api/YangCompiledOutput.java
@@ -16,7 +16,7 @@
package org.onosproject.yang.compiler.api;
-import org.onosproject.yang.YangModel;
+import org.onosproject.yang.model.YangModel;
import java.nio.file.Path;
import java.util.Set;
diff --git a/compiler/api/src/main/java/org/onosproject/yang/compiler/api/package-info.java b/compiler/api/src/main/java/org/onosproject/yang/compiler/api/package-info.java
index 7b88263..072f59b 100644
--- a/compiler/api/src/main/java/org/onosproject/yang/compiler/api/package-info.java
+++ b/compiler/api/src/main/java/org/onosproject/yang/compiler/api/package-info.java
@@ -15,6 +15,6 @@
*/
/**
- * Created by root1 on 10/1/17.
+ * Representation of a compiled YANG model.
*/
package org.onosproject.yang.compiler.api;
\ No newline at end of file
diff --git a/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/DefaultYangCompiledOutput.java b/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/DefaultYangCompiledOutput.java
index 8d8b597..da475fe 100644
--- a/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/DefaultYangCompiledOutput.java
+++ b/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/DefaultYangCompiledOutput.java
@@ -16,7 +16,7 @@
package org.onosproject.yang.compiler.tool.impl;
-import org.onosproject.yang.YangModel;
+import org.onosproject.yang.model.YangModel;
import org.onosproject.yang.compiler.api.YangCompiledOutput;
import java.nio.file.Path;
diff --git a/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/YangCompilerManager.java b/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/YangCompilerManager.java
index 29354e4..357abfe 100644
--- a/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/YangCompilerManager.java
+++ b/compiler/base/tool/src/main/java/org/onosproject/yang/compiler/tool/impl/YangCompilerManager.java
@@ -16,11 +16,12 @@
package org.onosproject.yang.compiler.tool.impl;
-import org.onosproject.yang.DefaultYangModel;
-import org.onosproject.yang.DefaultYangModule;
-import org.onosproject.yang.DefaultYangModuleId;
-import org.onosproject.yang.YangModel;
-import org.onosproject.yang.YangModuleId;
+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.api.YangCompilationParam;
import org.onosproject.yang.compiler.api.YangCompiledOutput;
import org.onosproject.yang.compiler.api.YangCompilerException;
@@ -115,7 +116,7 @@
YangModuleId id;
for (YangNode node : yangNodeSet) {
id = processModuleId(node);
- org.onosproject.yang.YangModule module =
+ YangModule module =
new DefaultYangModule(id, get(node.getFileName()), get(path));
model.addModule(id, module);
}
diff --git a/compiler/plugin/pom.xml b/compiler/plugin/pom.xml
index f34cf1d..bcf0061 100644
--- a/compiler/plugin/pom.xml
+++ b/compiler/plugin/pom.xml
@@ -34,7 +34,6 @@
<modules>
<module>maven</module>
<module>buck</module>
- <module>utils</module>
</modules>
<dependencies>
diff --git a/compiler/plugin/utils/pom.xml b/compiler/plugin/utils/pom.xml
deleted file mode 100644
index edebb59..0000000
--- a/compiler/plugin/utils/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<!--
- ~ Copyright 2016-present Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<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>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-yang-compiler-plugin</artifactId>
- <version>1.12-SNAPSHOT</version>
- </parent>
-
- <artifactId>onos-yang-compiler-plugin-utils</artifactId>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-yang-compiler-tool</artifactId>
- <version>1.12-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>RELEASE</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.0.2</version>
- <configuration>
- <skipIfEmpty>true</skipIfEmpty>
- </configuration>
- <executions>
- <execution>
- <id>default</id>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/YangApacheUtils.java b/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/YangApacheUtils.java
deleted file mode 100644
index c457ec4..0000000
--- a/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/YangApacheUtils.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yang.compiler.plugin.utils;
-
-import org.onosproject.yang.DefaultYangModel;
-import org.onosproject.yang.DefaultYangModule;
-import org.onosproject.yang.DefaultYangModuleId;
-import org.onosproject.yang.YangModel;
-import org.onosproject.yang.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;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
-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;
-
-/**
- * Utilities for runtime to use apache tools.
- */
-public final class YangApacheUtils {
-
- private static final String SYSTEM = SLASH + "system" + SLASH;
- private static final String MAVEN = "mvn:";
- private static final String JAR = ".jar";
- private static final String USER_DIRECTORY = "user.dir";
- private static final String DATE_FORMAT = "yyyy-mm-dd";
- private static final String ONOS = "org.onosproject";
- private static final Logger log = getLogger(YangApacheUtils.class);
-
- // Forbid construction.
- private YangApacheUtils() {
- }
-
- /**
- * Returns YANG model for generated module class.
- *
- * @param modClass generated module class
- * @return YANG model
- */
- public static YangModel getYangModel(Class<?> modClass) {
- BundleContext context = getBundle(modClass).getBundleContext();
- if (context != null) {
- Bundle[] bundles = context.getBundles();
- Bundle bundle;
- int len = bundles.length;
- List<YangNode> curNodes;
- String jarPath;
- String metaPath;
- for (int i = len - 1; i >= 0; i--) {
- bundle = bundles[i];
- if (bundle.getSymbolicName().contains(ONOS)) {
- jarPath = getJarPathFromBundleLocation(
- bundle.getLocation(), context.getProperty(USER_DIRECTORY));
- metaPath = jarPath + SLASH +
- YANG_RESOURCES + SLASH + YANG_META_DATA;
- curNodes = processJarParsingOperations(jarPath);
- // process model creations.
- if (curNodes != null && !curNodes.isEmpty()) {
- return processYangModel(metaPath, curNodes);
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Returns YANG model for application.
- *
- * @param path path for metadata file
- * @param curNodes curNodes YANG nodes
- * @return YANG model
- */
- public static YangModel processYangModel(String path,
- List<YangNode> curNodes) {
- DefaultYangModel model = new DefaultYangModel();
- YangModuleId id;
- Iterator<YangNode> it = curNodes.iterator();
- while (it.hasNext()) {
- YangSchemaNode node = it.next();
- id = processModuleId((YangNode) node);
- org.onosproject.yang.YangModule module =
- new DefaultYangModule(id, get(node.getFileName()), get(path));
- model.addModule(id, module);
- }
- return model;
- }
-
- /**
- * Returns YANG module id for a given YANG module node.
- *
- * @param module YANG module
- * @return YANG module id for a given YANG module node
- */
- public static YangModuleId processModuleId(YangNode module) {
- String rev = getDateInStringFormat(module);
- return new DefaultYangModuleId(module.getName(), rev);
- }
-
- /**
- * Returns date in string format.
- *
- * @param schemaNode schema node
- * @return date in string format
- */
- public static String getDateInStringFormat(YangNode schemaNode) {
- if (schemaNode != null) {
- if (schemaNode.getRevision() != null) {
- return new SimpleDateFormat(DATE_FORMAT)
- .format(schemaNode.getRevision().getRevDate());
- }
- }
- return null;
- }
-
- /**
- * Returns jar path from bundle mvnLocationPath.
- *
- * @param mvnLocationPath mvnLocationPath of bundle
- * @return path of jar
- */
- private static String getJarPathFromBundleLocation(String mvnLocationPath,
- String currentDirectory) {
- String path = currentDirectory + SYSTEM;
- if (mvnLocationPath.contains(MAVEN)) {
- String[] strArray = mvnLocationPath.split(MAVEN);
- if (strArray[1].contains(File.separator)) {
- String[] split = strArray[1].split(File.separator);
- if (split[0].contains(PERIOD)) {
- String[] groupId = split[0].split(Pattern.quote(PERIOD));
- return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] +
- SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2];
- }
- }
- }
- return null;
- }
-
- /**
- * Process jar file for fetching YANG nodes.
- *
- * @param path jar file path
- * @return YANG schema nodes
- */
- private static List<YangNode> processJarParsingOperations(String path) {
- //Deserialize data model and get the YANG node set.
- String jar = path + JAR;
- try {
- File file = new File(jar);
- if (file.exists()) {
- return parseJarFile(path + JAR, path);
- }
- } catch (IOException e) {
- log.error(" failed to parse the jar file in path {} : {} ", path,
- e.getMessage());
- }
- return null;
- }
-}
diff --git a/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/package-info.java b/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/package-info.java
deleted file mode 100644
index 96630b1..0000000
--- a/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Build plugin utilities for compiling YANG models.
- */
-package org.onosproject.yang.compiler.plugin.utils;
\ No newline at end of file