Skip to content
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

Update bndtools.workspace.min from OSGi R7 to R8 #11

Merged
merged 19 commits into from
Dec 8, 2023

Conversation

chrisrueger
Copy link
Contributor

This relates to #5632 and #5864

As discussed in the call today this is a first attempt to update the template from R7 to R8.

What is this for?

This template should make it easier "Getting started" with bndtools and is basically the minimum a bndtools Eclipse workspace should look like when starting a new project.
Before this change it was based on OSGi R7.
For R8 the repositories need to be updated. It isn't as easy as changing a 7 to an 8 unfortunately.

Current solution

I made use of the bnd command line command, which automatically updates all versions of an .mvn file to the latest version.

bnd mbr update (which is a gem I will add to the docu soon. Thanks @pkriens for telling me)

How to test this?

This is the place where I need support to verify if we are satisfied with result, or what needs to be changed / added.

  • Go to Eclipse Preferences / BndTools / Workspace Template
  • Remove the Github repositories (just for testing)
image
  • Add this current repo to "Raw Git Clone URLs" (https://github.com/chrisrueger/bndtools.workspace.min.git and branch origin/R7-to-R8)
image
  • Click Apply and Close
  • Go to File / New / Bnd OSGi Workspace
image
  • Choose new Workspace or update the current one and Click next
image
  • Select the template from the repo you just entered above
image image
  • when asked to Switch to the Bnd Perpective say "Yes" or manually change there.

This should get you a BnWorkspace which looks lke this:

image
  • only the cnf folder
  • 2 Repositories
  • OSGi R8 - Build (which contains the API bundles... probably should name it API)
  • OSGi R8 - Runtime Distro (a selection of implementation bundles)

The distro term is something I learned from @pkriens today which is just a collection of implementation bundles.
The version in there are just based on the existing cnf/runtime.mvn and applying bnd mbr update

Help wanted

I am not sure if the current status is ok or not. Eclipse Problems view is empty, but I need someone to verify if it is enough.

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Nov 26, 2023

@pkriens Question:

When I do a bnd resolve validate in the current master branch, I get this:

bnd resolve validate
    missing   osgi.ee: &(osgi.ee=JavaSE)(version=10.0.0)
    missing   osgi.ee: &(osgi.ee=JavaSE)(version=[9.0.0,10.0.0))
    missing   Fragment-Host: system.bundle
    missing   Import-Package: jdk.internal.misc
    missing   osgi.ee: &(osgi.ee=JavaSE)(version=9.0.0)
    missing   Import-Package: javax.enterprise.inject
    missing   Import-Package: javax.enterprise.util
    missing   Import-Package: javax.inject
    missing   Contract: &(osgi.contract=JavaCDI)(version=2.0.0)
    missing   Contract: &(osgi.contract=JavaInject)(version=1.0.0)
    missing   osgi.unresolvable: &(must.not.resolve=*)(must.not.resolve!=*)
    missing   osgi.unresolvable: &(must.not.resolve=*)(must.not.resolve!=*)
    missing   osgi.unresolvable: &(must.not.resolve=*)(must.not.resolve!=*)

My current JAVA points to:

java --version
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode)

Could you help me how to interpret this?

I would like to find out, if this is basically the same result I need to achieve after the Update from R7 to R8.

@scottslewis
Copy link
Contributor

@chrisrueger

I'm finally getting around to trying your R7-to-R8 workspace template with the OSGi Service wizard. Here's what I'm getting after setting up the workspace with this template as described above and then in the new bndtools workspace doing:

New->Other...->OSGi Service->Java OSGi Service (api, impl, consumer)

and completing the wizard with project: org.test.hello
and Service Name: HelloService

First the three projects created by the wizard all compile (congrats!)

image

The only issue is that I"m getting a warning in each of the three projects for this annotation usage:

Description Resource Path Location Type
Discouraged access: The type 'Version' is not API (restriction on required library 'C:\Users\slewi.m2\repository\org\osgi\org.osgi.annotation\6.0.0\org.osgi.annotation-6.0.0.jar') package-info.java /org.test.hello.consumer/src/main/java/org/test/hello/consumer line 1 Java Problem
Discouraged access: The type 'Version' is not API (restriction on required library 'C:\Users\slewi.m2\repository\org\osgi\org.osgi.annotation\6.0.0\org.osgi.annotation-6.0.0.jar') package-info.java /org.test.hello.impl/src/main/java/org/test/hello/impl line 1 Java Problem
Discouraged access: The type 'Version' is not API (restriction on required library 'C:\Users\slewi.m2\repository\org\osgi\org.osgi.annotation\6.0.0\org.osgi.annotation-6.0.0.jar') package-info.java /org.test.hello/src/main/java/org/test/hello line 2 Java Problem

I don't understand why this is happening...as isn't Version class exported in org.osgi.annotation\6.0.0 ?

However, when I try to resolve the HelloService.bndrun I get resolver errors

Resolution failed. Capabilities satisfying the following requirements could not be found:
[<>]
⇒ osgi.identity: (osgi.identity=org.apache.felix.gogo.runtime)
⇒ [org.apache.felix.gogo.runtime version=1.1.6]
⇒ osgi.wiring.package: (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0)))
[org.apache.felix.gogo.command version=1.1.2]
⇒ osgi.wiring.package: (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0)))
[org.apache.felix.scr version=2.2.6]
⇒ osgi.wiring.package: (&(osgi.wiring.package=org.osgi.framework)(version>=1.10.0)(!(version>=2.0.0)))

This looks like some issue with gogo.runtime, gogo.command, felix.src for org.osgi.framework expected/required version? This appears strange as the framework version in the runtime repo seems to be == 1.10.0...which I would expect to resolve these three dependencies (?)

BTW, to try this yourself all you have to do is choose File->New->Other...->OSGi Services->Java OSGi Service (api, impl, consumer) and fill out the wizard (project name and service name) with something reasonable (i.e. 'HelloService').

@chrisrueger
Copy link
Contributor Author

Thanks a lot for testing @scottslewis

Discouraged access: The type 'Version' is not API

I fixed this in my recent commit.

However, when I try to resolve the HelloService.bndrun I get resolver errors

I can reproduce it, and looking into it now.

@chrisrueger
Copy link
Contributor Author

Regarding the resolve errors. I get a different resolve error:

@pkriens maybe you have an idea?

Here are my findings and steps.

Resolution failed. Capabilities satisfying the following requirements could not be found:
    [<<INITIAL>>]
      ⇒ osgi.identity: (osgi.identity=servicetest.consumer)
          ⇒ [servicetest.consumer version=1.0.0.202311270738]
              ⇒ osgi.extender: (&(osgi.extender=osgi.component)(version>=1.5.0)(!(version>=2.0.0)))
                  ⇒ [org.apache.felix.scr version=2.2.6]
                      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.osgi.service.component)(version>=1.5.0)(!(version>=1.6.0)))
image

Looks like org.apache.felix.scr 2.2.6 requires org.osgi.service.component [1.5.0,1.6.0)

image

Now I search and filter my respositories who provides this

osgi.wiring.package: (&(osgi.wiring.package=org.osgi.service.component)(version>=1.5.0)(!(version>=1.6.0)))

image

I find this:

image

Which looks like it provides this capability.

What am I missing?

@pkriens
Copy link
Member

pkriens commented Nov 27, 2023

In those nasty cases, I just add the provider of org.osgi.service.component as the sole initial resource and then try to resolve it. There must be something why it can't resolve.

Maybe the changes I made recently to the Resolution Viewer help. Select the scr bundle + the org.osgi.service.component bundle in the Repositories view. The requirements list then shows the unresolved requirements. Adding bundles by selection them in the Resolution Viewer might give you a clue.

If this happens, it tends to suck. That is mostly why the work you do is important. It tends to be work to get this working but a good distro gives very little problems.

@chrisrueger
Copy link
Contributor Author

@scottslewis it should resolve now.

@scottslewis
Copy link
Contributor

I've got two problems now when the Java OSGi Service goes to make a project:

  1. It complains thusly for the wizard creating each of three projects created by wizard

image

This appears to me because this line (39) is in cnf/ext/defaults.bnd

testbin ${target-dir}/test-classes

If I take out this line referring to test-classes, restart the IDE and then run the wizard, all three projects are created just fine, and with no compile errors. Any ideas about this?

  1. When running the wizard-generated HelloService.bndrun I still get resolution errors:

image

Any ideas why this is happening?

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Nov 28, 2023

About 1.

testbin ${target-dir}/test-classes

I could imagine that the spaces at the end may confuse it somehow. I will try to remove them.
image

About 2.

When running the wizard-generated HelloService.bndrun I still get resolution errors:

I think I could reproduce it.
The reason maybe that the generated .bndrun file has an entry for org.apache.felix.framework;version='[7.0.3,7.0.3]' which does not exist, because runtime.mvn containsorg.apache.felix:org.apache.felix.framework:7.0.5 .

image

If you re-select the OSGi Framework again and pick the 7.0.5 , save the file and resolve again, it should resolve successfully.

image image

Solution:
I think to solve this I have two options:
a) use felix 7.0.3 in runtime.mvn
b) update the service-template in bndtools.core to felix 7.0.5

@pkriens What do you think? I think yesterday in Slack you mentioned "updating the templates" which I think is option b).

image

Or could we also specify (force the felix version) in build.bnd for bndtools.workspace.min?

image

Update: e.g.
in build.bnd do
-runfw: org.apache.felix.framework;version='[7.0.5,7.0.5]'

and then remove the -runfw from $serviceName$.bndrun ?

I think the problem we have here is that the service template code in bndtools.core will almost always be out-of-sync with any configured Workspace-templates. The question: who should win?

@pkriens
Copy link
Member

pkriens commented Nov 28, 2023

I think we need to look at the templates, I expect they have more issues.

The resources you point out are very specific for Scott's work? I see the other templates in org.bndtools.templates.osgi and org.bndtools.templates.template? I do not think Scott's templates should be in bndtoosl.core? @scottslewis ?

If we update the templates (and we should) some thinks to consider:

  • Specify the framework without version, let bnd pick one
  • You might want to make the bndrun template use cache. This works great in general and saves lots of problems with git merge.
  • No versions, use default version and let the repositories control the versions avaialble
  • Remove Bundle-Version everywhere, should be defined in build.bnd
  • No specification of java anywhere
  • No Export-Package or Private-Package headers, defaults should be used.
  • Need to update our Junit storyhere. Probably need to work with @kriegfr
  • remove the enroute stuff
  • Might throw out some

Phew. Really grateful you're doing this work!

@scottslewis
Copy link
Contributor

Thanks @chrisrueger we are getting there!

Solution: I think to solve this I have two options: a) use felix 7.0.3 in runtime.mvn b) update the service-template in bndtools.core to felix 7.0.5

@pkriens What do you think? I think yesterday in Slack you mentioned "updating the templates" which I think is option b).

> > Or could we also specify (force the felix version) in `build.bnd` for `bndtools.workspace.min`? > > Update: e.g. in `build.bnd` do `-runfw: org.apache.felix.framework;version='[7.0.5,7.0.5]'` > > and then remove the `-runfw` from `$serviceName$.bndrun` ? > > I think the problem we have here is that the service template code in `bndtools.core` will almost always be out-of-sync with any configured Workspace-templates. The question: who should win?

Is the -runfw required in the bndrun file? If not seems better to just remove it from the bndrun template and default to the value in cnf/build.bnd...as @chrisrueger suggests above.

@scottslewis
Copy link
Contributor

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Nov 28, 2023

The resources you point out are very specific for Scott's work?

No the template in bndtools.core I pointed out where just one of the existing bndtools template.s which Scott mentioned earlier to reproduce the bug he found

New->Other...->OSGi Service->Java OSGi Service (api, impl, consumer)

I think this is not Scott's work, but just a simple hint for me, to reproduce his bug. But this was the starting point of this rabbit hole we are in now :)

I see the other templates in org.bndtools.templates.osgi and org.bndtools.templates.template?

  • Specify the framework without version, let bnd pick one
  • You might want to make the bndrun template use cache. This works great in general and saves lots of problems with git merge.
  • No versions, use default version and let the repositories control the versions avaialble
  • Remove Bundle-Version everywhere, should be defined in build.bnd
  • No specification of java anywhere
  • No Export-Package or Private-Package headers, defaults should be used.
  • Need to update our Junit storyhere. Probably need to work with @kriegfr
  • remove the enroute stuff
  • Might throw out some

I will create another PR next door in bndtools for this.
@scottslewis Not sure how you are testing , but the changes @pkriens proposed are in https://github.com/bndtools/bnd and in my PR branch for the time being. It may make testing of all this more complicated, because I don't really know how you would test this with your own additions, as long as it is not in master.
Or should I fork your branch @scottslewis to make the proposed changes there?

The challange here is that we need to balance things from 2 different repos and 3 different branches. We'll see. Thanks for your feedback.

@scottslewis
Copy link
Contributor

> > > New->Other...->OSGi Service->Java OSGi Service (api, impl, consumer) > > I think this is not Scott's work, but just a simple hint for me, to reproduce his bug. But this was the starting point of this rabbit hole we are in now :)

This is my work (merged to master some time ago), AND I use for testing @chrisrueger work since it's in bndtools 7.*) already.

So if you are on 7.x+ you should be able to test it like I do by using the New->other...->OSGi Service->Java OSGi Service menu items, filling out the Project Name and ServiceName fields and Finish...which should contain three projects projectname.api, .impl, and .consumer. In the new .api project is servicename.bndrun which has got the problematic vals (to be removed presumably) for runframework and runee.

I see the other templates in org.bndtools.templates.osgi and org.bndtools.templates.template?

Those are project templates. Not the same as service templates (the new thing that I introduced in 7.0-REL). I don't think they need to change for the repo changes, but it's possible they might...I haven't tried them yet as I'm focusing on the service templates that I added.

As above, this is the bndrun file serviceTemplate in master at the moment:

https://github.com/bndtools/bnd/blob/master/bndtools.core/resources/unprocessed/serviceTemplates/java-service-api/%24serviceName%24.bndrun

I'm not sure what the final outcome wrt runframework and runee in cnf/build.bnd (workspace template) or in serviceName.bndrun (serviceTemplate), but I assume it's just to remove parts or all of runframework and/or runee from the projectName.bndrun file linked to above so that these are just automatically use the value from the workspace template/build.bnd file...then that's fine with me....i.e. from my point of view as author anyone is welcome to do these updates, and it will be much easier for Peter or someone else with direct access to the bndtools.core repo contents to do so.

  • Specify the framework without version, let bnd pick one
  • You might want to make the bndrun template use cache. This works great in general and saves lots of problems with git merge.
  • No versions, use default version and let the repositories control the versions avaialble
  • Remove Bundle-Version everywhere, should be defined in build.bnd
  • No specification of java anywhere
  • No Export-Package or Private-Package headers, defaults should be used.
  • Need to update our Junit storyhere. Probably need to work with @kriegfr
  • remove the enroute stuff
  • Might throw out some

I will create another PR next door in bndtools for this. @scottslewis Not sure how you are testing , but the changes @pkriens proposed are in https://github.com/bndtools/bnd and in my PR branch for the time being. It may make testing of all this more complicated, because I don't really know how you would test this with your own additions, as long as it is not in master. Or should I fork your branch @scottslewis to make the proposed changes there?

I was using a branch before it was merged to master a few months ago, but haven't been using a branch since then (I haven't made any changes for a while to the serviceTemplate and/or the other bndtools.core stuff [which uses the serviceTemplate content at project creation time].

The challange here is that we need to balance things from 2 different repos and 3 different branches. We'll see. Thanks for your feedback.

Everything that I've worked on (service templates/Java OSGi Service Wizard UI) latest is on master of bndtools.core.

@chrisrueger
Copy link
Contributor Author

Everything that I've worked on (service templates/Java OSGi Service Wizard UI) latest is on master of bndtools.core.

Ah ok thanks for the clarification. Then I think I should have everything.
I keep you updated when I pushed a branch.

@chrisrueger
Copy link
Contributor Author

@scottslewis @pkriens I created PR bndtools/bnd#5907

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Nov 28, 2023

With the changes in this branch here and in bndtools/bnd#5907 I can successfully create the service via New->Other...->OSGi Service->Java OSGi Service (api, impl, consumer) and it resolves right away.

image image image

@pkriens I tried moving defaults.bnd and java.bnd to build.bnd but then the repositories were empty. I guess I screwed up some line breaks or something when copy pasting the files. I reverted this again.
Is there anything I need to be careful with when doing this? Or some order?

@scottslewis
Copy link
Contributor

With the changes in this branch here and in I can successfully create the service via New->Other...->OSGi Service->Java OSGi Service (api, impl, consumer) and it resolves right away.

That's great @chrisrueger ! I'll test myself, but looks from you test like everything is cool now. I'll let you know if I get anything different once I test...I'll probably wait for merge of bndtools/bnd#5907 and try out the next day's snapshot build.

AFAIK, this makes the Java OSGi Service Wizard ready to go with the bndtools.workspace.min/R7-to-R8 workspace template.

For the bndtools.workspace template (the other 'built-in' workspace template) for R7-to-R8: Are you planning to start with this bndtools.workspace.min and add on other bundles or something else? FWIW, as long as you start from bndtools.workspace.min, it should not affect the Java OSGi Service Wizard at all.

@chrisrueger chrisrueger marked this pull request as ready for review November 29, 2023 10:22
@chrisrueger
Copy link
Contributor Author

Thanks @scottslewis .

For the bndtools.workspace template (the other 'built-in' workspace template) for R7-to-R8: Are you planning to start with this bndtools.workspace.min and add on other bundles or something else? FWIW, as long as you start from bndtools.workspace.min, it should not affect the Java OSGi Service Wizard at all.

Good question. I have not looked into the other bndtools.workspace yet. I just remember @pkriens mentioning that there was some discussion about in the past. I also don't really know the purpose of it... is also looks different (e.g. there a .jar ... where is that coming from?). Based on that I guess we should address the other bndtools.workspace in a different PR and maybe discuss it first.

@scottslewis
Copy link
Contributor

scottslewis commented Nov 29, 2023

> > Good question. I have not looked into the other [bndtools.workspace](https://github.com/bndtools/workspace) yet. I just remember @pkriens mentioning that there was some discussion about in the past. I also don't really know the purpose of it... is also looks different (e.g. there a [.jar ](https://github.com/bndtools/workspace/tree/master/cnf/templates/org.bndtools.templates.osgi) ... where is that coming from?). Based on that I guess we should address the other [bndtools.workspace](https://github.com/bndtools/workspace) in a different PR and maybe discuss it first.

My $0.03: For the next release, I think at least that the bndtools.workspace should be updated in exactly the same way that bndtools.workspace.min has been updated...i.e. with the same cnf contents. Yes they would be the same, which is a little strange, but at least they would both be on R8. If bndtools.workspace stays as it is (R7) and bndtools.workspace.min is release on R8 I see disaster...particularly for new bndtools users.

If they are the same, then in the future additional repos/bundles can be added to bndtools.workspace in future...making it more capable. But IMHO it would be better to add onto bndtools.workspace incrementally.

chrisrueger added a commit to chrisrueger/workspace that referenced this pull request Nov 29, 2023
As suggested in bndtools/bndtools.workspace.min#11 (comment)
we up this repo to OSGi R8 and base it on the files of bndtools.workspace.min initially

This may not be the final solution but at least a first step to have an OSGi R8 environment, so that templates may build upon that

Signed-off-by: Christoph Rueger <[email protected]>
@chrisrueger
Copy link
Contributor Author

bndtools.workspace should be updated in exactly the same way that bndtools.workspace.min has been updated...i.e. with the same cnf contents. Yes they would be the same, which is a little strange, but at least they would both be on R8

@scottslewis I created bndtools/workspace#24 based on your suggestion.
We can take it from there. @pkriens

@scottslewis
Copy link
Contributor

Is this going to be merged soon? Once done I want to test end-to-end (the service template wizard anyway) with the nightly build.

@pkriens
Copy link
Member

pkriens commented Dec 1, 2023

you should rebase on master. I've updated gradle + the java vm

chrisrueger and others added 19 commits December 1, 2023 10:19
preparation to run "bnd mbr update"

Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
This gives 404
Signed-off-by: Christoph Rueger <[email protected]>
executed "gradle wrapper --gradle-version 7.3"
this fixes the error Discouraged access: The type 'Version' is not API , because Version is part of osgi-annotation-8.1.0.jar
Signed-off-by: Christoph Rueger <[email protected]>
* this was the reason it could not resolve
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
This reverts commit 0d39c74.
Signed-off-by: Christoph Rueger <[email protected]>
it is referenced in a template
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
@chrisrueger
Copy link
Contributor Author

you should rebase on master. I've updated gradle + the java vm

Done @pkriens

@pkriens pkriens merged commit fedf026 into bndtools:master Dec 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants