fix new project templates not showing up#6191
Conversation
This fixes the problem, that newly created project templates required a Eclipse restart to show up in the new Bnd Project wizard. Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
and do not throw so that wizard works even in case Central.refreshPlugins(); has an Exception. Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
|
@pkriens do youd mind if I merge this? It is a usability fix To summarize:
|
|
|
||
| try { | ||
| // refresh, to not miss recently created project templates. | ||
| Central.refreshPlugins(); |
There was a problem hiding this comment.
hmm. question is why this did not happen. Not keen on having this called in lots of places.
Then again if this fixes the problem now, I am ok. However, it needs to be called in a background job & you need to get the workspace lock.
There was a problem hiding this comment.
Thanks Peter for your reply.
hmm. question is why this did not happen. Not keen on having this called in lots of places.
I can understand that. But I already cut my teeth on it. See my comment above.
I tried debugging it, but without success.
I tracked it down to the following problem:
When you create a new "Template Project" (which you want to see later in the list), then the following needs to happen:
- the new "Template projects" needs to be built (.jar generated)
- then (and only then)
Central.refreshPlugins();needs to be called.
If Central.refreshPlugins(); is called too early (when the .jar of the new "Template project" does not exist yet), then the new Template is not visible the "File / New / New Bnd OSGi Project" Wizard.
Workaround: Manually clicking the "Refresh Repos" button in the UI before doing "File / New / New Bnd OSGi Project" Wizard.

In this case it works 100% of the time. But this is manual, and you need to remember it.
If you could help me find the place in the code where we could do it programmatically after building, I am happy to remove the call to Central.refreshPlugins(); where I have added it now.
Question:
Do we have any mechanism to executed Central.refreshPlugins(); after the new created project has been built?
Then again if this fixes the problem now, I am ok. However, it needs to be called in a background job & you need to get the workspace lock.
Could you elaborate on why? Just want to understand it.
-
background job: I think I would like this to happen synchronously in the current thread, to make sure that it has finished indexing the new project exactly where I added it - at least this is the reason why I have put it there. Will a background job do this too? Or is it async and finishes "sometime" in the future?
-
workspace lock: The "File / New / New Bnd OSGi Project" Wizard is a modal overlay in the foreground. When this is opened I guess nobody could do anything in the workspace at the same time. But maybe I don't understand the purpose of this workspace lock.
But of course I can look into all these things. Just wanted to clarify.
There was a problem hiding this comment.
Just an additional thought:
If Central.refreshPlugins(); is too expensive.
For the purpose of just getting a "fresh view" of the available "Project templates" in the current workspace, it would be maybe enough to just call EclipseWorkspaceRepository.refresh().
Maybe this is cheaper, and fixes the problem too. Central.refreshPlugins(); would be more generic affecting all repos, but maybe too much for the purpose.
There was a problem hiding this comment.
Thinking a bit more about it - Here is a suggestion:
- I remove the problematic code line in
NewBndProjectWizard.java
// refresh, to not miss recently created project templates.
Central.refreshPlugins();
- I keep the other code in
EclipseWorkspaceRepository, because then the Repo-Refresh button works, and you could at least make the "Project template" visible without an Eclipse restart.
We could then document this behavior somewhere. Maybe I add it to the help-text which is displayed in the "Project template project" wizard ("Please make sure to refresh the Repository Browser...").
I just commited this proposal.
There was a problem hiding this comment.
FWIW, my opinion is that any additional required actions by the user is going to make this bndworkspace workspace creation/template-based project/service/etc creation dance even more complicated and error prone...especially for new bndtools users.
I'm not exactly sure whether Christoph's proposal requires user action (if not please ignore), but if it does I would advise against it. Seems to me that another way to deal with this is to either enhance the bnd project/service, etc wizard superclasses to make the necessary calls, or add new bndtools refresh methods to capture the required semantics.
FWIW I believe I struggled with this for some time when introducing the New OSGI Service Wizards (based upon templates).
There was a problem hiding this comment.
Hi @scottslewis ,
FWIW, my opinion is that any additional required actions by the user is going to make this bndworkspace workspace creation/template-based project/service/etc creation dance even more complicated and error prone...especially for new bndtools users.
I'm not exactly sure whether Christoph's proposal requires user action (if not please ignore), but if it does I would advise against it.
Unfortunatelly it does require user action 😞 . The state I merged this afternoon requires user action in the way that I now show a help text that a click on the "Refresh Button of the Repositories" view is required to make the new template show up.
But this is a slight improvement over the situation before which required a Eclipse restart.
My change here fixes the problem, that at least now "Refresh Button of the Repositories" works instead of Eclipse restart.
That being said:
I know this is not ideal and I am glad for any for suggestions and adress and improve it in another issue.
If you have something in mind let's try it in a issue / PR.
During my work in this PR here my goal was to find a way that the new Template shows up automatically.
But i failed to get it working reliably. It was kinda random sometimes. The closes I came was this, but it might be a bit too expensive doing it there.
As stated above somewhere, I was searching for a mechanism to executed Central.refreshPlugins(); after the new created project has been built? (after has been built is important, because the .jar artifact of the new project needs to be generated by bnd before it can be picked up by the refresh of EclipseWorkspaceRepository). If the refresh happens earlier before the .jar is built, then the refresh has no effect.
Long story short: I would appreciate any pointers of how this could be improved. You are totally right that is is not ideal and I would like to improve it too.
Remove refreshPlugins in NewBndProjectWizard and replace it with a hint in the help text of the "Project Template Project". Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
|
@pkriens I took the liberty to merge this, since I removed the expensive call to |


This fixes the problem, that newly created "project template"-projects required a Eclipse restart to show up in the New Bnd Project wizard.
See https://bnd.discourse.group/t/enabling-template-repositories-by-default/460/5
This PR makes sure that new Project templates always / immediately show up in the "New Bnd OSGi Project" wizard, after creation.