Modify Jinja transform to handle a number key in JSON

I’m way beyond my knowledge, but I’m trying to test an unmerged PR at jinjava to handle number keys in a homeassistant JSON to resolve an error that I posted a github OH-addons issue.

I was able to create a jinjava jar locally by copying the proposed PR code. Where I’m stuck is how to get that jar into org.openhab.transform.jinja to satisfy the dependency. The top of the class (JinjaTranformationService) that needs the dependency is

import com.hubspot.jinjava.Jinjava;
import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.interpret.FatalTemplateErrorsException;

What I tried was to make these changes in the POM. I know putting the jar in the {basedir} is a bad idea, but it is just for me at this point and only produces a warning, not an error.

-      <version>2.6.0</version>
-      <scope>compile</scope>
+      <version>2.7.1-SNAPSHOT</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/jinjava-2.7.1-SNAPSHOT.jar</systemPath>

The issue appears to be the local file is not satisfying the requirement
Unable to resolve org.openhab.transform.jinja/ missing requirement [org.openhab.transform.jinja/] osgi.wiring.package; filter:="(osgi.wiring.package=com.hubspot.jinjava)"

It does seem something is being done with the file because in the maven code I extracted these lines;

[DEBUG] (s) projectArtifactMap = {com.hubspot.jinjava:jinjava=com.hubspot.jinjava:jinjava:jar:2.7.1-SNAPSHOT:system
[DEBUG] Adding classpath entry: <C:\Users\Robert\GitHub\openhab-addons\bundles\org.openhab.transform.jinja\lib\jinjava-2.7.1-SNAPSHOT.jar>
[DEBUG] AuxClasspath Elements ->[C:\Users\Robert\GitHub\openhab-addons\bundles\org.openhab.transform.jinja\lib\jinjava-2.7.1-SNAPSHOT.jar,
[DEBUG] Adding to AuxClasspath ->C:\Users\Robert\GitHub\openhab-addons\bundles\org.openhab.transform.jinja\lib\jinjava-2.7.1-SNAPSHOT.jar

and if try the result in OH I get the expected error;

2023-08-08 16:11:02.320 [ERROR] [Events.Framework                    ] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.transform.jinja [264]
  Unresolved requirement: Import-Package: com.hubspot.jinjava

Two questions; Is this possible? and if yes suggestions?

1 Like