-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[addonsinfoprovider] Addon for providing addon-info of other addons #15780
Conversation
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Ping @mherwege |
Note that CI build fails because it depends on changes in core openhab/openhab-core#3806 |
@andrewfg Thank you, great work. I am sorry I have not been reactive lately. Work got me occupied. I hope I will be able to test both PR’s in the next few days. One feedback already, I think you should exclude the generated addons.xml from the PR, as it should be created at build. |
Yes that makes sense. I need to read up on gitIgnore I suppose :( |
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to dig deeper into this and trying it out. Looks promising! I have added some quick feedback about the documentation.
|
||
## Addon Developer Notes | ||
|
||
If you want to your addon to scan the user's system then you need to include additional fields in your `src/main/resources/OH-INF/addon.xml` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be documented here, i.e. through the openhab-docs repository:
https://www.openhab.org/docs/developer/addons/addon.html#xml-structure-for-add-on-definitions
A link could be provided here, but probably the contents should be removed to avoid double maintenance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. But let us keep it here for now, until we make more progress on the total package.
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@mherwege I have a question to you: Currently I have the functionality split as follows..
I am thinking that I should shift the functionality 2. from the core to the special addon. There would be two benefits — the core PR becomes smaller and therefore easier for OH core maintainers to overview and approve. The specific scanning and filtering functionality can become more generic. => WDYT? |
@andrewfg I think the separation between core and addons you have right now is the correct separation. If I understand it well, core will base all its suggestions on info it gets from AddonInfo. This info can come from different sources, depending on where the addons are sourced from. E.g. if the AddonInfo received for marketplace addons also contains the discovery info, nothing would stop from these being suggested as well. If an external addon source is configured, it would have a similar effect. Moving the logic to the addons repo would mean this would have to be replicated. |
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
...finder/src/main/java/org/openhab/misc/addonsuggestionfinder/AddonSuggestionInfoProvider.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
...finder/src/main/java/org/openhab/misc/addonsuggestionfinder/AddonSuggestionInfoProvider.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
@kaikreuzer yes please. To be precise.. Currently the Maven build process parses the 'addon.xml' file from the source sub folders in openhab-addons\bundles. So if we move this to core, then I would need to write Java code to extract the 'addon.xml' resource from within the .jar files within the respective .kar file i.e. the 'G:\OH4_TEST\addons\openhab-addons-4.1.0-SNAPSHOT.kar\repository\org\openhab\addons\bundles' file .. wherever it may be located. We have a 'Russian doll' with three levels of stacking, so the questions are..
|
For aggregating XMLs (in this case the openhab-addons BOM), I added
I think you can use something similar for aggregating discovery information from the |
@J-N-K thanks for the feedback. I think what you suggest is similar to what @mherwege suggested, and I implemented, where we use the Maven build process to create an addons.xml file at build time. However I think that @kaikreuzer is suggesting to do it with Java code at runtime. In which case see my post above, where I added some more precise questions. |
I think @kaikreuzer suggests to create the XML at build time and to read that from core instead of implementing an add-on that provides this information. Maybe the |
The addons.xml is already created in the maven addons build. I didn’t know how to get access to an xml generated in the addons repository build process from core. That’s why a special addon in the addons repository has been created. The better place would indeed be in core or distrib, if someone can help us understand how to get access to that xml file created during the addons build from another repository than the addons repository. |
@J-N-K any thoughts about how? |
@kaikreuzer I have been manually digging around inside 'openhab-addons-4.1.0-SNAPSHOT.kar' and I don't see any addons.xml in it. So is it perhaps embedded as a resource in some .jar file inside the .kar file? And if so which jar should I be looking for? |
Current solution is this..
|
I think we can design this actually much simpler. If the file(s) are created at build time, the result can be made available as a Maven artifact (see here for an example. The distro build can then easily pick up these artifacts and package them within the openHAB distro, e.g. within |
Umm. @kaikreuzer that may look simple to you, but unfortunately not to me; I am a simple java programmer; and really have little clue about Karaf, Maven, or features. I shall need more hand holding please.
I think still the issue is that the addons.xml file will be created in the openhab-addons workspace during the openhab-addons build; then the openhab-distro build needs to know the path to the openhab-addons workspace in order to import that file; and then the openhab-core needs to be able to find that file within the distro.. |
@J-N-K (BTW) from the time stamps of the (supposedly overwritten) pom.xml file, and by including some xml comments in the original, that should disappear if the file were overwritten, I am pretty sure that your example code is never actually run; the pom.xml file remains identical before and after the build . |
Correct, that part is only executed if you do |
Actually do mvn create:bom I think.. But anyway it goes to prove that I am not the right person to try to do this work in the way that @kaikreuzer and you @J-N-K are asking for; I simply do not have the time or ability to go over the Maven, Artifact, Feature learning curve; perticularly when there is no useful documentation on those things. I shall have to put this PR into sleep mode unless someone can step in. |
@andrewfg What you can already do is move the code for this AddonInfoProvider to core, whereby you read from an I don't know much about karaf and mvn, but I am willing to try this in the next few weeks starting from the examples @kaikreuzer has provided. I will just need time for it, and time is scarce at the moment. So don't expect me to turn this around quickly. In the mean time, just make the assumption there will be an |
Thanks for volunteering here, @mherwege! I think the examples I linked should give a good starting point as it is fairly standard Maven functionality. Feel free to ping me whenever you feel you get stuck and things do not work as you would expect them to work.
@andrewfg That's really just classical reading a file from the filesystem, see e.g. here how to directly access the openHAB userdata folder. |
@kaikreuzer / @mherwege two things..
|
@mherwege J-N-K@a9a79b0 But this needs to be refined a bit. IMO the XML should be more "standard" and the should be an XSD for that (which should be in core). I'm currently preparing a commit for openhab-distro which installs the file in the correct location. Unfortunately I have to fix a build issue in openhab-addons before :-( |
@J-N-K can you be more precise about "more standard"? In the core PR have already modified the XSD for addon.xml to include the new discovery methods. So I am happy to add another XSD for the over wrapper containing a list of those. |
Currently it looks like
It should probably be something like
The namespace definition should not be added for each element. But this can be done by adjusting the And as I already said: there should be an XSD for the |
With the addons element there is an outer addon-info-list element that contains one instance of an explicit list of addon elements (this is considered the correct way to do lists). Whereas without the addons element, the outer element is both the wrapper and implicitly also the list container (implicit lists are considered to be bad practice). And (therefore) the former is easier to deserialize using standard libraries, whereas the latter would require extra code. |
@J-N-K I am writing the XSD now. =>I will let you know so you can put the schema reference in the header.xml part of your PR. |
@J-N-K I committed the revised schemas here Please note that the schema for Version 1 (without sub schema prefixes)
Version 2 (with sub schema prefixes)
|
This addon provides an AddonInfoProvider service which produces a list of AddonInfo information for all the other addons within the openhab-addons main distribution .kar file.
In particular it provides the AddonInfo 'countries', 'connection' and 'discovery-methods' fields for all addons (even those which have not yet been installed). To give a specific example, this addon is expected to be used by the Addon Suggestion Finder service as described here.
This addon scans the
addon.xml
information of ALL OH addons during the Maven build phase, and it creates an XML file which is built into this addon in the form of a resource file. When this addon is loaded, it reads the resource file and establishes anAddonInfoProvider
service which produces the list of addons AddonInfo information from their respective addon.xml file.Signed-off-by: Andrew Fiddian-Green software@whitebear.ch