Skip to content

Transformation with ScriptEngine do not have dependecy change and do not recompile on dependency change #5046

@dilyanpalauzov

Description

@dilyanpalauzov

https://community.openhab.org/t/java223-scripting-script-with-java-on-openhab-5-0-1-0-6-0-0-0/159853/28 suggests that the transitive dependencies, fixed by #4922, still do not work, when a ScriptEngine transformation utilizes a library, versus a script utilizing a library:

Changing a lib dependency SHOULD force recompilation of script that declares depending on this library. It works for “standard” script (i.e. I tested a script created from the GUI in the “script” section, and it runs every time with updated lib), but it doesn’t work for a transformation script.
I debugged a little, and I found that transform scripts are not registered in the dependency tracking system, at all.

Steps to reproduce with OH openHAB 5.1.0 Build 4836:

  • I create a very simple npm package with index.js containing just
var a = "A"
module.exports = {
  a
};

and npm pack creates nmod1-1.0.0.tgz - change manually the file extension to tgz, I put .txt so that I can upload tgz file in github

  • I installed it in openhab/automation/js with npm install ~/nmod1-1.0.0.tgz
  • With an item String x I create a file sitemaps/cd.sitemap with content:
sitemap cd label="B3" {
  Text item=x label="Y [JS(|require('nmod1').a + ' E'):%s]"
}

Its value is, correctly, Y: A E.

  • I change in openhab/automation/js/node_modules/nmod1/index.js the first line to var a = "M" and reload the sitemap in the browser. The value does not change, unless I modify the function in the sitemap. That change can mean for instance substituting E with something else, but not modifying Y .

That said, the dependency tracking for ScriptEngines/JSR223 in openhab-core does not work yet, when a transformation is written in a Script/Rule engine. When a file, imported by a transformation is changed, the transformation is not recompiled, until the source code of the transformation is changed, too.

The above is for JavaScript(GraalVM).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions