0

I need help to configure a dependency as optional,

Using maven-bundle-plugin:3.4.0,

In the Import-packages section, they refereed as resolution:optional

<plugin> 
        <groupId>org.apache.felix</groupId> 
        <artifactId>maven-bundle-plugin</artifactId> 
        <version>3.4.0</version> 
        <extensions>true</extensions> 
        <executions> 
                <execution> 
                <id>bundle-manifest</id> 
                <phase>process-classes</phase> 
                <goals> 
                    <goal>manifest</goal> 
                </goals> 
                <configuration> 
                        <instructions> 
                                <Export-Package>*</Export-Package> 
                                <Import-Package> 
                                        org.junit.*;/resolution=optional/, 
                                        junit.framework.*;/resolution=optional/ 
                                </Import-Package> 
                                <_nouses>true</_nouses> 
                        </instructions> 
                </configuration> 
        </execution> 
   </executions> 
</plugin> 

Expectation is generated OSGI manifest file should contains the resolution:=optional for that library but the changes not reflecting.

Expectation : junit.framework;resolution:=optional

but in generated manifest file junit.framework

Did i miss any configuration to reflect it resolution as optional in the generated manifest file?

On investigation Maven-Bundle-Plugin, BundlePlugin.java File, I realized that if the artifact contains the optional true then reflected in the generated manifest file as resolution:=optional

<dependency> 
   <groupId>junit</groupId> 
   <artifactId>junit</artifactId> 

   <scope>provided</scope> 
   <optional>true</optional> 
</dependency> 

But the previous solution should work according to the BundlePlugin.java source code,

guide me to proceed further.

1 Answers1

2

You just need to remove slashes (/) you have placed around the resolution=optional:

<Import-Package> 
    org.junit.*;resolution=optional,
    junit.framework.*;resolution=optional
</Import-Package>