Fix cfgdef not found at runtime for third-party apps built with Maven
onos-maven-plugin stores the file in a package-like resource directory.
Also facilitate debugging by showing properties processed during Maven
build.
Change-Id: Icd4bea411b60ce773191896478a612c7ef1a77b1
diff --git a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
index 2f17447..076ae4b 100644
--- a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
+++ b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
@@ -111,6 +111,10 @@
String componentName = componentClass.getName();
String resourceName = componentClass.getSimpleName() + RESOURCE_EXT;
+ if (componentClass.getResource(resourceName) == null) {
+ // Try looking in my/package/name/MyClass.cfgdef
+ resourceName = componentClass.getCanonicalName().replace('.', '/') + RESOURCE_EXT;
+ }
try (InputStream ris = componentClass.getResourceAsStream(resourceName)) {
checkArgument(ris != null, "Property definitions not found at resource %s",
resourceName);
diff --git a/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java b/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
index f8ea71c..b706f28 100644
--- a/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
+++ b/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosCfgMojo.java
@@ -73,7 +73,7 @@
}
- private static class CfgDefGenerator {
+ private class CfgDefGenerator {
private static final String COMPONENT = "org.osgi.service.component.annotations.Component";
private static final String PROPERTY = "property";
@@ -156,8 +156,9 @@
String desc = description(javaClass, name);
if (desc != null) {
- String line = name + SEP + type + SEP + def + SEP + desc + "\n";
- lines.add(line);
+ String line = name + SEP + type + SEP + def + SEP + desc;
+ getLog().info("Processing property " + line + " ...");
+ lines.add(line + "\n");
}
}
}