VSCode Guide

Documention/guide is now online at https://www.openhab.org/docs/developer/ide/vscode.html

13 Likes

We have a docs page for the development area which includes ide setups and a vscode setup guide is on the todo/needed list, so this is a perfect start for completing that step. :slight_smile:

Thanks - I figured people will probably find whatever errors I have on this. Once it seems stable - Iā€™ll put in a PR on that to include the infoā€¦

1 Like

@Confectrician I have the following in mind for that section:

  • remove the eclipse step by step part and put it on its own page.
  • Have the 3 images of the ideā€™s as clickable large image links in one row. Each link directing to the respective step by step guide. I guess that vuepress allows html tables in markdown.

Regarding this detailed step by step guide:
The eclipse develop guide is also version 0.1, so Iā€™d say if you agree we add this to the page already. More people will see it and weā€™d get more feedback faster.

I will verify on Linux and amend the page on demand and try to get my hands dirty with Intelli.

2 Likes

I have also thought about a separated ide page. The index gets really huge with those informations.

Just let me know if I can be of any more help or if you want me to PR anything. In the mean time, looks like Iā€™ll start converting my sony addon to the new system

I guess we can change our Vscode extension to create the tasks and launch file for us in the future.

Imagine that developer flow:

  • Install openhab. Click ā€œenable debug sessionā€ on a paper UI successor.
  • Install Vscode and the openhab extension.
  • Click on a menu -> Create new binding or > Import existing binding.

That would be super slick. I mean apart from the maven errors that weā€™ll get here and there.

2 Likes

Yeah - that would be really nice. Beyond my pay grade though!

Thanks a lot for these instructions!

I ran through them and everything was fairly self explanatory. Couple of small things:

ā€œSave and closeā€ i would say ā€œSave and close tasks.jsonā€ i wondered if you mean close VS Code or just the file.

Leaving a terminal in ā€˜targetā€™ directory (while doing step 3.c. to check the jar) meant that the build failed while trying to clean the project.

With that said, i followed everything and saw my binding jar copied to the \addons folder, but even after waiting many mins and restarting openhab I still cant find my binding to add. Something im missing?

Thanks again for the instructions. VS Code is great.

Ok i see why its not loading.

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.somfymylink 
[191]
  Unresolved requirement: Import-Package: com.google.gson; version="[2.8.0,3.0.0)"

at org.eclipse.osgi.container.Module.start(Module.java:444) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [10:org.apache.felix.fileinstall:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [10:org.apache.felix.fileinstall:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [10:org.apache.felix.fileinstall:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [10:org.apache.felix.fileinstall:3.6.4]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [10:org.apache.felix.fileinstall:3.6.4]

Iā€™m pretty new to all this so excuse the n00b question, but my build using Eclipse didnā€™t have an issue. Is there something i need to tweak to make sure this reference is included somehow?

I got around this by dropping gson-2.8.0.jar in the \addons folder.

Should this be necessary? Sorry, not really understanding how dependencies are handled.

Updated

Assuming thatā€™s a new binding (since I donā€™t see it in my tree) - you should reask that question in the main development/idebuild forum (not this thread) since it has to do with build rather than in the VSCode stuff. As to why, I personally donā€™t know since I havenā€™t used the new build system yet (and donā€™t know how dependencies are evaluated yet).

Ok thanks. I wasnā€™t sure if it was an issue due to this VS Code build/deploy vs. Eclipse as i didnt get the issue there. But i think its just a OH version difference that is causing it. Thanks again for the instructions ā€¦ really happy you figured this out.

@chrisjohnson
If you are using a plain vanilla instance of openHAB 2.5 (where you havenā€™t installed anything in yet). Dropping bundles into the addons will NOT install dependencies (donā€™t ask me why). Youā€™ll need to either install some existing addon that uses gson (which will install the gson support) or install it yourself. Easiest way - go into the karaf console and do ā€œbundle:list com.google.*ā€ to see what has been installed

1 Like

@David_Graeff
One nice thing would be to have the same code formatting in VSCode (I know thereā€™s another thread kinda discussing this). According to this https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings - we can use the eclipse formatting file if itā€™s available somewhere. I know nothing about the formatting and was hoping you might know if there is a file defining this somewhere on github (or elsewhere). If not, maybe we can have a global .settings/org.eclipse.jdt.core.prefs that shows the formatsā€¦

There is a (broken) link to this in the Developer Guide, but hereā€™s the fileā€¦

Maybe we should separate the User part from the developer part and create a developer extension.

1 Like

The new intro page has been merged with an own page for VScode.

@tmrobert8 Can you issue a PR for adding your VScode instructions? Thatā€™d be sweet. Even more so if you could add some screenshots.

Thanks,
David

1 Like

@David_Graeff

Sure - Iā€™m actually doing a bit more work on it (adding additional tasks [like doing a full compile, starting/stopping an openhab debug instance and making sure it works across platforms]). Once Iā€™m done with those - Iā€™ll run a PR through. Note: I like @Confectrician idea about making a developer extension (as I can see a few more interesting things that can be done) - might tackle that one eventually if there is some interestā€¦

Tim

Tim

2 Likes