Skip to content

Commit

Permalink
add resolution: optional to try to fix test
Browse files Browse the repository at this point in the history
auto-registered annotations are added with "resolution: optional" directive, in order to fix tests which failed due to Unresolved requirements: osgi.extender; (&(osgi.extender=osgi.serviceloader.registrar)(version>=1.0.0)(!(version>=2.0.0))) which was added by the auto-registed annotations

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
  • Loading branch information
chrisrueger committed Oct 8, 2024
1 parent 462367e commit e351378
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import java.lang.annotation.RetentionPolicy;
import java.util.Map;

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;
import aQute.bnd.header.Attrs;
import aQute.bnd.header.Parameters;
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.Annotation;
import aQute.bnd.osgi.Annotation.ElementType;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Descriptors.TypeRef;
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.metainf.MetaInfService.Implementation;
Expand Down Expand Up @@ -57,7 +59,10 @@ public boolean analyzeJar(Analyzer analyzer) throws Exception {
Parameters annotations = impl.getAnnotations();

if (annotations.isEmpty() && METAINF_SERVICES_STRATEGY_AUTO.equals(strategy)) {
annotations.add(ServiceProvider.class.getName(), Attrs.EMPTY_ATTRS);
Attrs attrs = new Attrs();
attrs.put(Constants.RESOLUTION_DIRECTIVE, Resolution.OPTIONAL);
attrs.addDirectiveAliases();
annotations.add(ServiceProvider.class.getName(), attrs);
}

annotations.forEach((annotationName, attrs) -> {
Expand Down

0 comments on commit e351378

Please sign in to comment.