-
-
Notifications
You must be signed in to change notification settings - Fork 305
Add support for repository tags #6116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
52af186
allow tagging of repositories
chrisrueger ea7740d
use Set
chrisrueger 359a405
add tagged support to more repos and edit dialog
chrisrueger dd36fe1
allow to use tag in -runrepos in .bndrun
chrisrueger b9a574f
rework - repos now have 'resolve' tag by default
chrisrueger 34091a8
Merge remote-tracking branch 'upstream/master' into add-repository-tags
chrisrueger c08cce3
implement suggestions
chrisrueger e990f07
move matchesTags back to Tagged
chrisrueger 7857d51
Tags implement Set using an internal sorted set
chrisrueger 53cb0dc
improve tag matching
chrisrueger e46fd43
mention <<EMPTY>> placeholderin repo plugin UI
chrisrueger 7f04909
make tags a combobox in Plugins UI
chrisrueger 7313fbc
rename to Tags.includesAny
chrisrueger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| version 3.1 | ||
| version 3.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,40 @@ | ||
| package aQute.bnd.service; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import aQute.bnd.service.tags.Tagged; | ||
|
|
||
| /** | ||
| * A registry for objects. | ||
| */ | ||
| public interface Registry { | ||
|
|
||
| /** | ||
| * @param <T> | ||
| * @param c | ||
| * @return all plugins matching the given class | ||
| */ | ||
| <T> List<T> getPlugins(Class<T> c); | ||
|
|
||
| /** | ||
| * @param <T> | ||
| * @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. | ||
| */ | ||
| default <T> List<T> getPlugins(Class<T> c, String... tags) { | ||
|
|
||
| if (tags.length == 0) { | ||
| return getPlugins(c); | ||
| } | ||
|
|
||
| return getPlugins(c).stream() | ||
| .filter(repo -> repo instanceof Tagged taggedRepo && taggedRepo.getTags() | ||
| .includesAny(tags)) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| <T> T getPlugin(Class<T> c); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| @Version("4.8.0") | ||
| @Version("4.9.0") | ||
| package aQute.bnd.service; | ||
|
|
||
| import org.osgi.annotation.versioning.Version; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| version 1.6 | ||
| version 1.7.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package aQute.bnd.service.tags; | ||
|
|
||
| /** | ||
| * Allows to add tags to implementing classes. Originally intended for tagging | ||
| * repositories. | ||
| */ | ||
| public interface Tagged { | ||
|
|
||
| /** | ||
| * Dummy placeholder for "empty tags". | ||
| */ | ||
| String EMPTY_TAGS = "<<EMPTY>>"; | ||
|
|
||
| /** | ||
| * @return a non-null list of tags. Default is empty (meaning 'no tags'). | ||
| */ | ||
| default Tags getTags() { | ||
| return Tags.NO_TAGS; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| package aQute.bnd.service.tags; | ||
|
|
||
| import static java.util.Collections.unmodifiableSortedSet; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Iterator; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.Set; | ||
| import java.util.SortedSet; | ||
| import java.util.TreeSet; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * 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 | ||
| * {@link Tagged} interface. | ||
| */ | ||
| public class Tags implements Set<String> { | ||
| private final SortedSet<String> internalSet; | ||
|
|
||
| public final static Tags NO_TAGS = of(); | ||
|
|
||
| private Tags() { | ||
| this.internalSet = unmodifiableSortedSet(new TreeSet<>()); | ||
| } | ||
|
|
||
| private Tags(Collection<? extends String> c) { | ||
| this.internalSet = unmodifiableSortedSet(new TreeSet<>(c)); | ||
| } | ||
|
|
||
| @Override | ||
| public int size() { | ||
| return internalSet.size(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isEmpty() { | ||
| return internalSet.isEmpty(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean contains(Object o) { | ||
| return internalSet.contains(o); | ||
| } | ||
|
|
||
| @Override | ||
| public Iterator<String> iterator() { | ||
| return internalSet.iterator(); | ||
| } | ||
|
|
||
| @Override | ||
| public Object[] toArray() { | ||
| return internalSet.toArray(); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> T[] toArray(T[] a) { | ||
| return internalSet.toArray(a); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean add(String s) { | ||
| return internalSet.add(s); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean remove(Object o) { | ||
| return internalSet.remove(o); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean containsAll(Collection<?> c) { | ||
| return internalSet.containsAll(c); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean addAll(Collection<? extends String> c) { | ||
| return internalSet.addAll(c); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean retainAll(Collection<?> c) { | ||
| return internalSet.retainAll(c); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean removeAll(Collection<?> c) { | ||
| return internalSet.removeAll(c); | ||
| } | ||
|
|
||
| @Override | ||
| public void clear() { | ||
| internalSet.clear(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| return internalSet.equals(o); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return internalSet.hashCode(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return internalSet.toString(); | ||
| } | ||
|
|
||
| /** | ||
| * @param tags | ||
| * @return <code>true</code> if any of the given tags is included in the | ||
| * current set of tags, otherwise returns <code>false</code>. Also | ||
| * if the current set of tags is empty, also <code>true</code> is | ||
| * returned. | ||
| */ | ||
| public boolean includesAny(String... tags) { | ||
|
|
||
| if (isEmpty()) { | ||
| // this is on purpose to maintain backwards compatibility for | ||
| // entities which do not handle tags yet and return an empty set. In | ||
| // other words: if the current set is | ||
| // empty that means "yes I match any of what you passed". | ||
| return true; | ||
| } | ||
|
|
||
| for (String tag : tags) { | ||
| if (contains(tag)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * @param name | ||
| * @return a Tags instance with the given tags. | ||
| */ | ||
| public static Tags of(String... name) { | ||
| return new Tags(Set.of(name)); | ||
| } | ||
|
|
||
| /** | ||
| * Parses a comma-separated string of tags into a Tags object. | ||
| * | ||
| * @param csvTags | ||
| * @param defaultTags a default used when csvTags is null or blank | ||
| * @return populated Tags or the passed defaultTags. | ||
| */ | ||
| public static Tags parse(String csvTags, Tags defaultTags) { | ||
| if (csvTags == null || csvTags.isBlank()) { | ||
| return defaultTags; // default | ||
| } | ||
|
|
||
| return new Tags(Arrays.stream(csvTags.split(",")) | ||
| .map(String::trim) | ||
| .collect(Collectors.toCollection(LinkedHashSet::new))); | ||
| } | ||
|
|
||
| } |
4 changes: 4 additions & 0 deletions
4
biz.aQute.bndlib/src/aQute/bnd/service/tags/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @Version("1.0.0") | ||
| package aQute.bnd.service.tags; | ||
|
|
||
| import org.osgi.annotation.versioning.Version; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.