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

Remove duplicated declaration of required OSGi execution environment #2711

Merged

Conversation

HannesWell
Copy link
Contributor

Description

The bnd-maven-plugin used to generate the OSGi metadata can determine the required EE automatically based on the version of the generated class-files. This avoids inconsistencies if the release target is raised in the future.

In general there is no need to declare a Bundle-RequiredExecutionEnvironment together with an osgi.ee requirement. At runtime the former is automatically converted to the later, since the former is deprecated.
Furthermore declaring multiple values for Bundle-RequiredExecutionEnvironment is also not useful since the driving requirement is the highest one.

With the change being applied bnd generates the following header:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"

This matches the minimally required Java version of Java 7 for Gson 2.9 and later and #1601 or #1602 should not be re-introduced.

Checklist

  • New code follows the Google Java Style Guide
    This is automatically checked by mvn verify, but can also be checked on its own using mvn spotless:check.
    Style violations can be fixed using mvn spotless:apply; this can be done in a separate commit to verify that it did not cause undesired changes.
  • If necessary, new public API validates arguments, for example rejects null
  • New public API has Javadoc
    • Javadoc uses @since $next-version$
      ($next-version$ is a special placeholder which is automatically replaced during release)
  • If necessary, new unit tests have been added
    • Assertions in unit tests use Truth, see existing tests
    • No JUnit 3 features are used (such as extending class TestCase)
    • If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
  • mvn clean verify javadoc:jar passes without errors

The bnd-maven-plugin used to generate the OSGi metadata can determine
the required EE automatically based on the version of the generated
class-files. This avoids inconsistencies if the release target is raised
in the future.
Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I don't think any project maintainers have OSGi expertise but it looks as if you have checked that this does the right thing.

@eamonnmcmanus eamonnmcmanus merged commit 73b7781 into google:main Jul 5, 2024
11 checks passed
@HannesWell HannesWell deleted the remove-dublicated-ee-requirements branch July 6, 2024 11:24
@HannesWell
Copy link
Contributor Author

Thanks for submitting this.

but it looks as if you have checked that this does the right thing

I have checked the result of a local mvn clean verify build and yes the result is as expected.
Do you deploy snapshots that can be checked again?

And regarding the bnd-maven-plugin:

@eamonnmcmanus
Copy link
Member

We don't usually deploy snapshots, no. I think it's very likely that the updated configuration works given your local check, and if by chance the configuration doesn't work we can fix it after the next release.

I like the idea of getting rid of bnd.bnd and using Maven configuration instead. It seems more logical for all configuration to be in pom.xml rather than having this one special file in the top-level gson directory.

On the other hand having bnd-maven-plugin generate module-info.class feels backwards to me. I think we do want to have an explicit module-info.java that users can consult.

@HannesWell
Copy link
Contributor Author

Sounds all good.
Please see #2712 for the merge.

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.

2 participants