-
-
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
Migration to a Maven + Bnd based build system #5005
Comments
Migration to a Maven + Bnd based build systemThe build system has been migrated to a Mave + Bnd based build system. BackgroundopenHAB is a java project that is build around the OSGi framework. openHAB add-ons are OSGi bundles. Over the years the bnd software ("bnd is the engine behind a number of popular software development tools that support OSGi") has established itself as the defacto standard for creating OSGi bundles. The openHAB maintainers have decided to move from the very Eclipse centric buildsystem to maven/bnd. A combination that not only allows to develop bindings seamlessly in other IDEs than Eclipse, but Java beginners and intermediates find a commonly known maven buildsystem. Advantages of the new buildsystem
How to migrateThe easiest way to migrate is to use the
Examples
How to build on the command lineEnter Subsequent calls can include the For integration tests you might need to run: Skip checks and tests if you just want to test the compilation process and perform the command from within the directory of the bundle that you want to build:
How to develop in the Eclipse IDE
The demo application runs a slim set of openHAB core bundles including automations (next gen rules) and PaperUI (http://127.0.0.1:8080/paperui/). The startup should only take about 5 seconds and you are greeted by the openHAB console where you can type in console commands. |
It's sure a lot easier to create your own Bintray repo compared to uploading to Maven Central. Isn't it also easier for them being removed one day causing builds to fail? As fallback we'll probably still have such JAR artifacts in stable/milestone/snapshot releases. But IMHO this would be just as problematic as when someone decides to delete their GitHub repo containing all the source code of a library. Since we don't store such sources or source JARs. To mitigate these issues we could also setup an openHAB repo proxy to such 3rd party repos.
I'd like to manage them using dependencies in POMs as well. It would be a good improvement to be able to update libraries and all their dependencies by just updating a version number. :-) |
So, my offer: I try to start the base work:
That's just an offer to help. If another one volunteers to do that job, I am happy, too. |
astro is a perfect match, isn't it? |
I'm OK with Astro as well. The binding itself doesn't really matter as long as it's a bit representative of most projects. If we run into issues while migrating other add-ons we can always ask for more help. 😉 |
Thanks for adding a migration guide @davidgraeff ! |
Can we add that to the developer documentation (esp. the Part about eclipse)? |
One thing regarding the miration guide: "remove '/lib'" is a good idea but will not work out-of-the-box for all bindings, since not all libs are availabe on bintray. And not all of those that are available can easily be used. So this should be checked before migration. |
@J-N-K There was a discussion about this between Markus and Wouter (I think?) and the agreement afaik is to move everything to (if necessary private) bintray/maven repos. For new contributions I also tend to say to either include the source code completely or only allow "established" libraries on maven central. |
The end of this discussion was, that a decision by oh2-maintainers should be made about that. AFAIK this is still pending. Including the source code maybe difficult. For example the Allplay binding includes a lib (Tchaikovsky) that is build with gradle and includes other libs that are not available on bintray (source is available on GitHub, though). Integrating that into our own build would greatly increase build time. |
My long time dream for openHab is Gradle as well, but Markus will slowly poke me to death with a spoon if I suggest that :D (But the speed advantage is real) |
What I was trying to say: other project might use other build systems and integrating those with our own is quite some effort and may not be worth the time (compared to building them and uploading a binary to our own 3rd-party-libs repo). |
The idea is to go to the maintainer of such a library and ask for a maven publish. There is even a maven plugin that uses github pages as a static repository site. We do not depend on their build system. |
I am locked on the last step, that is launching the demo app. When I double-click on the file app.bndrun, it simply opens the file in the Eclipse editor. With what app should I open this file to start the demo app ? |
It's like with pom.xml files: You can edit the source file or have the eclipse UI. The same for bndrun files: The default view might be text for you, but there should be the tab to show the UI (you see the glimpse of this selection in the screenshot above). If not, your eclipse installation is missing bndtools (which is fatal). Please either manually install them or use the eclipse installer for openhab-core development. Let it do whatever it does, remove everything from the workspace again and then perform the steps from above. |
Bndtools is now (manually) installed and I can see the dialog box with run requirements. If I click on the green +, it opens the "Add Bundle Requirement" dialog box but this is empty, I only see at left "Workspace default-ws" with nothing inside. Same for Run Bundles. Project run path dialog box shows an empty workspace. If I drag my project from the project explorer into the run requirements, I get this error: |
Great tutorial. This will help others a lot. I walked through it step by step and want to add the following things:
We have to remove the
Move unit tests from a potential separate Additional changes need to be done in the files |
But I get a 404 error if I try to open the dashboard or Basic UI ! |
The demo only runs paperUI. You see that in the "Run requirements" section. There is only paperUI referenced. Add whatever you need there Btw paperUI can be reached directly via http://openhab-ip/paperui without the dashboard (which is deprecated... next to PaperUI but that's another story.) |
I think this guide is quite universal: http://www.joern-karthaus.de/blog/karaf.html |
I can no more compile a binding in development.
Is it now impossible to compile with the old mechanism ? If I move my binding to the new build system, I assume I will not be able to run it in Eclipse ? |
It will be harder and harder to use the old development workflow as we more and more change all bits to the new system. At the moment for your particular problem you only need to edit your launch configuration and add whatever appears when you enter "EventAdmin" (or "events" not sure). |
I am moving the binding to the new build system ! |
I am also now trying to build my Smartthings binding since I am done making the code review changes but I am getting the same error as @lolodomo is getting:
It seems like the path forward is to convert my binding to use the new build system. Is that the advised solution? If so, do I follow the Setup the Development Environment instructions at https://www.openhab.org/docs/developer/. Or, the instructions above. I'm confused because this issue is closed and the instructions at https://www.openhab.org/docs/developer/ say the instructions will be updated when the the migration is complete. Questions about Eclipse setup
|
The migration is not yet complete, it is only finished for this repository, not for the openhab-distro one. |
I've merged openhab/openhab-distro#905 now, so we should be getting closer again to a working IDE - would be great if everyone could test and provide feedback, which issues are still left (NOTE: It might take a few hours before the Eclipse Installer picks up the new setup file). |
Hm. Could be related to my move of the pom.xml file from poms/bndrun/poms.xml to root. I needed to adapt relative paths. Travis and Jenkins were happy though. Try to build with maven on your Mac (which might behave different to Linux?) |
I am trying to get our IDE setup working again for our developers, so the goal here is to have no errors in the IDE. Yes, Maven headless seems to work as Jenkins confirms. |
@kaikreuzer, please Check l. 704 in the base pom. I assume that will fix your problem. Could you also check if l. 662 needs to be adapted, too? |
@davidgraeff Having moved the pom sounds like a plausible explanation, though. And it seems to hint that using lib folders isn't a good idea anymore... |
@J-N-K Thanks, changing l-704 indeed does the trick! It would be cool if all of you could also try out the new IDE setup as I am really struggling with it a bit... If we want to have it ready for the community again, we should make sure that it works reliable - I think I have now created PRs to have at least all compilation and buildpath errors resolved, so that's a start. |
I agree we should get rid of the lib folders as soon as possible. We could simply upload all those files to bintray and add them as dependencies. |
#5503 is quite important for that reason. Could you create an openhab team on jcenter and share the credentials on the oh2 maintainer GitHub team, so that we can start to OSGi bundle those libs? For new bindings with external libs we should push contributors to ask upstream for OSGi bundled variants. |
All, but marytts as it required a Maven build to be executed. We might be able to add that as a setup task in the Oomph file... |
You cannot directly upload stuff to jcenter, you upload it to Bintray and we have a Maven repo there: https://bintray.com/openhab/mvn I can provide access to the addon maintainers, if you provide me your Bintray account name - but let's first clarify on #5503, where to upload it to exactly. |
I have now changed my development environment to the new build system followed the instructions from here https://www.openhab.org/docs/developer/ Everything works so far, but I can not export the binding as plugin. Any ideas? |
That dialog is for PDE stuff. |
Looking for guidance from the OH core devs before making an IDE setup guide PR. As of 15May19 bndtools does not support latest Eclipse available to download (2019-06) in the Eclipse installer. Latest support is 2019-03. See "Additional Details" in https://marketplace.eclipse.org/content/bndtools Eclipse version compatibility has been a sore point for new devs for a while. |
Is 2019-06 already released? It is not listed in https://projects.eclipse.org/releases |
I've updated the migration steps in the second comment to use the skeleton script. |
We are in the process of changing the build system. We are not accepting new pull requests that are still using the old way from here on.
For further information see: Migration to a Maven + Bnd based build system
The text was updated successfully, but these errors were encountered: