bnd icon indicating copy to clipboard operation
bnd copied to clipboard

BndConfiguration.getConfiguration(List<Plugin>) does not take into account global configuration

Open kwin opened this issue 1 year ago • 10 comments

The code at https://github.com/bndtools/bnd/blob/f9b2c857859dd3e46401f2f19aba4b09f308a16e/biz.aQute.bnd.maven/src/aQute/bnd/maven/lib/configuration/BndConfiguration.java#L114 does not take the global configuration into account.

For example if the parent pom has something like

...
<plugin>
    <groupId>biz.aQute.bnd</groupId>
    <artifactId>bnd-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>bnd-process</id>
            <goals>
                <goal>bnd-process</goal>
            </goals>
            <configuration>
                <bnd>Bundle-Category: Something</bnd>
           </configuration>
      </execution>
  </executions>
</plugin>

and the child pom has

<plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <configuration>
                    <bnd>Fragment-Host: some-bsn</bnd>
                </configuration>
            </plugin>

The configuration being returned by https://github.com/bndtools/bnd/blob/f9b2c857859dd3e46401f2f19aba4b09f308a16e/biz.aQute.bnd.maven/src/aQute/bnd/maven/lib/configuration/BndConfiguration.java#L114 for the plugin of the child pom is just containing the configuration of the parent POM.

The logic is missing some merge logic between execution configuration and global configuration (compare also with https://stackoverflow.com/questions/33908315/what-is-the-difference-between-executions-and-configurations-in-a-maven-plugin).

kwin avatar Dec 05 '24 14:12 kwin

Would you be able to do a PR?

stbischof avatar Dec 05 '24 15:12 stbischof

I am still trying to work out the inner Maven logic. We need to reproduce it in bnd due to the bnd instruction inheritance which deviates a bit from the Maven Plugin configuration inheritance

I found https://github.com/apache/maven/blob/maven-3.9.x/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java, but not sure yet when this kicks in.

I opened https://issues.apache.org/jira/browse/MNGSITE-544 to document the status quo a bit better.

kwin avatar Dec 05 '24 16:12 kwin

I think this is actually expected and nothing bnd should/need to handle because maven already merges the configurations appropriately..

In your child you provide a configuration that would apply to all executions but in your specific execution you override this so it is merged with the plugin one and effectively overriding what is configured in the child. This would be different if you specify an additional execution without configuration, then your general configuration will take precedence.

To accomplish what you described your child configuration must look like this:

<plugin>
    <groupId>biz.aQute.bnd</groupId>
    <artifactId>bnd-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>bnd-process</id>
            <configuration>
                <bnd>Fragment-Host: some-bsn</bnd>
           </configuration>
      </execution>
  </executions>
</plugin>

laeubi avatar Dec 11 '24 08:12 laeubi

The merging mechanism in Maven and Bnd differs! bnd-maven-plugin deliberately deviates from Maven standards to allow merging of bnd configurations (which wouldn't be possible in Maven). Therefore also the same kind of merging should happen on all levels.

  1. Parent POMs
  2. Plugin Mgmt -> Plugins
  3. Plugin -> Plugin Executions

Currently the bnd specific merging is only implemented for 2.

kwin avatar Dec 11 '24 09:12 kwin

Currently the bnd specific merging is only implemented for 2.

bnd-maven already considers the parent pom so have you tried my suggestion?

laeubi avatar Dec 11 '24 09:12 laeubi

parent pom is not correctly considered: for example having multiple parent levels with each having bnd plugin parameter will just be merged by Maven logic, i.e. just one value wins. It is not merged one level below (within the bnd instructions)!

kwin avatar Dec 11 '24 10:12 kwin

Can you probably give a runnable example (or even better, provide a testcase here)?

laeubi avatar Dec 11 '24 11:12 laeubi

Where are we on this? Anybody going to make a PR?

pkriens avatar Jan 31 '25 17:01 pkriens

Yes, I will look into this, but it will take some time.

kwin avatar Jan 31 '25 18:01 kwin

@kwin any update?

chrisrueger avatar Jun 06 '25 16:06 chrisrueger