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