In this thread I will try to enable people to develop their addons without the current unstable Eclipse IDE for OH 2.5. Feel free to add some links to relevant articles. Thanks in advance for your help.
Current question: Does it make sense to avoid Eclipse here and use Visual Studio Code? The creation of the jar will be done without Eclipse anyway. What is the most comfortable way in your opinion?
IMHO it should be possible to create a new addon without the help of any IDE. ie do it from a command line.
A beginnerās guide would explain whatās happening in each step. Then there would be links to corresponding guides for doing the same thing in different IDEs, explaining how the IDE is doing some of the work for you that you did manually before.
It would be written is such a a way that it us useful for people like me who want to understand what is happening and also for those who donāt care any just want to get something running.
Iād be happy to test and give you feedback anything you come up with.
But we do have that. Go to the addons2 repo and have a look at the readme. It explains how to build via command line.
If you follow the binding developer guide, it tells you everything you need to know about maven pom files, karaf feature files and whatnot. Those mechanisms are all IDE independent. And that is the huge difference to when I started with openHAB.
Two years ago, you were required to use the Eclipse Installer, you had no ideas what happened behind the scene (I was never able to get an already installed Eclipse ready for OH development) and you could only do certain actions from within the IDE. That is no more since the new buildsystem (bnd+maven). Of course that means that it is now more complicated within Eclipse to get development going.
We actually face a lot of problems with bnd+maven in combination with Eclipse (because the m2e maven 2 eclipse plugin is buggy as hell) and there is not much we can do. The plugin seems unmaintained.
Iād love to start developing at least 2 bindings, Iāve tried with the current docs and never get past even setting it all up.
A few tutorials, from a āhello worldā beginner type step by step would be the way to go, the more people that can understand and get into making and improving bindings the better.
Examples of doing basic things would be a great addition such as:
how to retrieve a json from a cloud api
The best and easiest way to authenticate
How to auto discover items based on a json response
Etc etc
Forget all the error checking and what ifās, once people start to understand the basics they will soon learn how to add this in after.
you are great - thanks a lot for your hints to useful tutorials.
@rlkoshak:
I guess I will give it a try with VSCode and / or IntelliJ CE. Hopefully I do not need to extend anything, if all the necessary advice is still there.
@David_Graeff
I will go through the readme file. Itāll be great if this works and all the people can understand this guide.
@delid4ve, @zephod:
Thanks for telling us, what your expectations and challenges were / are.
Well, yes, there is a line that says āmvn clean installā but that is a bit terse. What gets installed and where? What does install really mean? What if I want to run from the current directory to test local changes? How do you start the system once youāve built it? etc, etcā¦
This information is probably in the docs somewhere but its not easy to find.
True, there is no exhaustive maven tutorial, the reason being that I have written a lot of those readme and developer files and I donāt understand Maven myself tbh. I prefer Gradle. Maven is doing too much behind the scenes and you canāt just look at a pom.xml file to know what will happen. Too much is done in maven via plugins, because maven canāt do much by itself. So you must know a dozen plugins and their maven goals and their behaviour and their quirkiness to get around. The command line interface feels like from the 90ths and Maven is way too verbose.
So I couldnāt write that tutorial because if it ever goes in my preferred direction, we will not use maven for long. Unfortunately a lot of other maintainers are still protecting Maven, because they are probably more familiar with Maven than Gradle.
Thatās where it gets complicated. You canāt āstartā OH easily. You need a full OSGi enviroment started before doing anything, then load required OH bundles and only then somehow inject your addons. Itās not yet fully clear how to archive that easily for the IDEs or the command line.
Iāve setup VSCode on Windows 10. I created a new addon jobatest with the help of the skeleton script. I tried to use mvn clean install -DskipChecks and got the following errors, that the import org.eclipse was not able to be resolve the import of org.eclipse ā¦
@ David_Graeff
I donāt know, call me crazy, but I would have thought clear directions on how to āstartā OH from the command line is fairly important and would be fully documented by now. I also would have thought that there would some kind of start script if it is that complicated.
I was poking around in the repos and I found a start.sh script in the openhab-distro repo that just calls bin/karaf. It looks like there needs to be some setup done to get bin/karaf to run. I also found a script called oh2_dir_layout but Iāve run out of time now.
BTW I completely understand not wanting to spend time figuring out how something that you donāt believe in, ie maven, works. Perhaps you could wake up one of your fellow maintainers to help out here? I have a separate question on why mvn install works but mvn compile does not in the core repo.
The OH distro is nothing more than a Karaf with added repositories to find the add-ons and with all core bundles bundled. Starting OH means starting that Karaf instance.
But thatās still not really possible in one command if you at the same time wanna debug a binding. There is also a group of maintainers that do not use karaf for developing, ie Kai. Because he is bundling the Eclipse setup file, that setup works different to what the story told in the documentation. Need to be resolved at some point.
@Jochen_Bauer: I have succesfully run the skeleton script from VS Code on W10, but on a Linux host (via the Remote-SSH VS Code extension). So I guess it is not the same scenario, only similar. Iāve used @tmrobert8ās tasks.json and launch.json with changed path settings to make the environment variables in tasks.json work on my Linux setup. Nothing moreā¦
Did you already try a fresh start by clearing the Maven repository and as a first step, before running the skeleton, build an existing binding first (I mean run mvn clean install -DskipChecks on it)?
Iām trying to make some local changes on Netatmo binding, but facing errors when I run āmvn clean installā. Iām totally blocked and I cannot find a solution.
Could the issue be related with the migration of Netatmo binding to bnd? Do you know if is there is any guide to compile bindings with bnd?
And an example of error Iām getting:
Unable to resolve org.openhab.binding.netatmo/2.5.0.201907090725: missing requirement [org.openhab.binding.netatmo/2.5.0.201907090725] osgi.wiring.package; filter:="(osgi.wiring.package=android.net)"]]
Unfortunately I am not able to help you here on this one. I guess in a few days or weeks I will get netatmo up and running too, so letās see if itāll work out for me. In the meatime, maybe another member can help?
Anyone knows how to solve that the org.eclipse.xxx packages are not available when opening the addon folder of openHAB with VS code? Thanks in advance.
In my other addon, which builds by maven without any errors, there is a difference: under java dependencies there are all these jars listed, which seems to be non visible.
UPDATE: Oh no, after I tried to build the other addon, the build crashed and now the build of my addon which worked, breaks too - how can that happen?
UPDATE-2: after deleting maven cache under /usersā¦/.m2/repositories/ the new build succeeded!
So the question is: why are the jars not visible in the freshly created addon skeleton? Iāve run the windows create_skeletonā¦ cmd file.