diff --git a/biz.aQute.bndlib/src/aQute/bnd/service/Registry.java b/biz.aQute.bndlib/src/aQute/bnd/service/Registry.java index b149d81d09..39e531718c 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/service/Registry.java +++ b/biz.aQute.bndlib/src/aQute/bnd/service/Registry.java @@ -21,8 +21,8 @@ public interface Registry { * @param * @param c * @param tags - * @return all plugins matching the given class and any of the given tags. - * If no tags are given, all plugins are returned without filtering. + * @return All plugins that have a tag that matches at least one of the + * given tags or have no tags. */ default List getPlugins(Class c, String... tags) { @@ -31,8 +31,8 @@ default List getPlugins(Class c, String... tags) { } return getPlugins(c).stream() - .filter(repo -> repo instanceof Tagged taggedRepo && taggedRepo.getTags() - .includesAny(tags)) + .filter(plugin -> (plugin instanceof Tagged taggedPlugin) ? taggedPlugin.getTags() + .includesAny(tags) : true) .collect(Collectors.toList()); } diff --git a/biz.aQute.bndlib/src/aQute/bnd/service/RepositoryPlugin.java b/biz.aQute.bndlib/src/aQute/bnd/service/RepositoryPlugin.java index 36ff3e63b0..433e7ca505 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/service/RepositoryPlugin.java +++ b/biz.aQute.bndlib/src/aQute/bnd/service/RepositoryPlugin.java @@ -28,7 +28,7 @@ public interface RepositoryPlugin extends Tagged { * tags are set at the repo definition in build.bnd That means it is * consider */ - Tags DEFAULT_REPO_TAGS = Tags.of(Constants.REPOTAGS_RESOLVE); + Tags DEFAULT_REPO_TAGS = Tags.NO_TAGS; /** * Options used to steer the put operation diff --git a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java index 367fb6581a..24a4e7c4c1 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java +++ b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java @@ -11,6 +11,8 @@ import java.util.TreeSet; import java.util.stream.Collectors; +import aQute.libg.glob.Glob; + /** * A set of tags. A tag is a string-token which can be attached to an entity for * categorization and filtering. Typically these entities then implement the @@ -110,7 +112,7 @@ public String toString() { } /** - * @param tags + * @param tags (globs) * @return true if any of the given tags is included in the * current set of tags, otherwise returns false. Also * if the current set of tags is empty, also true is @@ -126,13 +128,19 @@ public boolean includesAny(String... tags) { return true; } - for (String tag : tags) { - if (contains(tag)) { + for (String tagGlob : tags) { + if (matchesAny(new Glob(tagGlob))) { return true; } } return false; + + } + + private boolean matchesAny(Glob glob) { + return internalSet.stream() + .anyMatch(s -> glob.matches(s)); } /** diff --git a/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/WorkspaceTest.java b/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/WorkspaceTest.java index 5ba383ac81..6838756b81 100644 --- a/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/WorkspaceTest.java +++ b/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/WorkspaceTest.java @@ -75,9 +75,10 @@ public void testEnv() throws Exception { Repository repo = repos.get(0); assertTrue(repo instanceof Tagged); - assertEquals(1, ((Tagged) repo).getTags() + assertEquals(0, ((Tagged) repo).getTags() .size()); - assertEquals(Constants.REPOTAGS_RESOLVE, new ArrayList<>(((Tagged) repo).getTags()).get(0)); + assertTrue(((Tagged) repo).getTags() + .includesAny(Constants.REPOTAGS_RESOLVE)); }