Skip to content

Switch from bnd:jar to bnd:bnd-process #69

Description

@ppkarwasz

Currently we are using the jar goal of the BND plugin to generate:

  • an OSGi manifest,
  • a JPMS module descriptor,
  • a set of META-INF/services files.

All this happens in the package phase of the Maven Lifecycle and is therefore available only for integration tests.

We should consider using the bnd-process goal, which produces the same files in the process-classes phase and makes them available to unit tests.

Such a change would require:

  • changing the BND goal from jar to bnd-process. Since the bnd-process goal does not require <extension>true</extension>, it would also solve Skip bnd-maven-plugin configuration when bnd.skip is present #34,
  • check the configuration of the Maven Jar Plugin that will automatically activate,
  • check the configuration of the Maven Surefire Plugin: IIRC the plugin detects the presence of module-info.class file (not a module-info.java file as documented), so we might need to use <useModulePath>false</useModulePath,
  • checking how IDEs react to the presence of module-info.class and if they can integrate BND as part of their build (Eclipse M2E can integrate Maven plugins in its build, I am not sure about IDEA).

Remark: switching from jar to bnd-process might have another beneficial effect. Currently if the package phase has multiple plugin executions, BND removes the Maven Jar plugin execution and adds its own at the end (not sure if that is fixable). E.g.: adding spring-boot:repackage in a naive way, causes spring-boot:repackage to be executed before bnd:jar.

Activity

  1. added a commit that references this issue on Dec 1, 2023
  2. self-assigned this
    on Dec 1, 2023
  3. added this to the 10.5.0 milestone on Dec 1, 2023
  4. ppkarwasz commented on Dec 7, 2023

    @ppkarwasz
    MemberAuthor

    This issue seems to be a little bit more complicated: if we simply switch from jar to bnd-process, not only IDEs will be confused by target/classes/module-info.class files, but Maven plugins too.

    For example Maven Compiler Plugin starts using the module path if it finds such a file (and AFAIK this is not switchable). So a ./mvnw compile might fail if it is not used together with clean.

    A solution to this conundrum might be offered by the -plugin instruction in BND. We could run both BND goals:

    • in the bnd-process goal we only activate the SPIDescriptorGenerator plugin,
    • in the jar goal we activate all plugins.
  5. vy commented on Dec 7, 2023

    @vy
    Member

    @ppkarwasz, thanks for the update. I am right now busy with testing various configurations against both 2.x and main branches of Log4j.

  6. added a commit that references this issue on Dec 7, 2023
    a0ac905
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions