forked from bndtools/bnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework - repos now have 'resolve' tag by default
- this commit partly reverts previous commit - repos now get the 'resolve' tag by default if not specified - .bndrun: empty -runrepos will be populated with all repos having the 'resolve' tag - .bndrun: resolution consider all repos having the 'resolve' tag. that means you can exclude a repo from resolution by manually assigning it a different tag (e.g. to exclude the baseline repo from resolution, you should give the baseline-repo e.g. the tag 'baseline' and make sure it does NOT have the 'resolve' tag Signed-off-by: Christoph Rueger <[email protected]>
- Loading branch information
1 parent
dd36fe1
commit b9a574f
Showing
13 changed files
with
118 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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,26 @@ | ||
package aQute.bnd.service; | ||
|
||
import static aQute.bnd.service.Tagged.matchesTags; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* A registry for objects. | ||
*/ | ||
public interface Registry { | ||
<T> List<T> getPlugins(Class<T> c); | ||
|
||
default <T> List<T> getPlugins(Class<T> c, String... tags) { | ||
|
||
if (tags == null || tags.length == 0) { | ||
return getPlugins(c); | ||
} | ||
|
||
return getPlugins(c).stream() | ||
.filter(repo -> matchesTags(repo, tags)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
<T> T getPlugin(Class<T> c); | ||
} |
This file contains 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,29 +1,60 @@ | ||
package aQute.bnd.service; | ||
|
||
import static aQute.bnd.service.Tagged.RepoTags.resolve; | ||
import static java.util.stream.Collectors.toCollection; | ||
|
||
import java.util.Arrays; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Allows to add tags to implementing classes. Originally intended for tagging | ||
* repositories. | ||
*/ | ||
public interface Tagged { | ||
|
||
|
||
enum RepoTags { | ||
/** | ||
* tag for repos which should be used for Resolving bundles. This is | ||
* also the default tag for all repos which not have specified tags | ||
* (also for bc reasons) Also see {@link Tagged#DEFAULT_REPO_TAGS} | ||
*/ | ||
resolve | ||
// add more if neded e.g. relase, baseline | ||
} | ||
|
||
/** | ||
* Each repo has by default the tag {@link RepoTags#resolve} if not tags are | ||
* set at the repo definition in build.bnd That means it is consider | ||
*/ | ||
Set<String> DEFAULT_REPO_TAGS = Set.of(resolve.name()); | ||
|
||
/** | ||
* @return a non-null list of tags. | ||
*/ | ||
Set<String> getTags(); | ||
|
||
static Set<String> toTags(String csvTags) { | ||
static Set<String> toTags(String csvTags, Set<String> defaultTags) { | ||
if (csvTags == null || csvTags.isBlank()) { | ||
return Set.of("all"); // default | ||
return defaultTags; // default | ||
} | ||
|
||
return Arrays.stream(csvTags.split(",")) | ||
.map(String::trim) | ||
.collect(Collectors.toCollection(LinkedHashSet::new)); | ||
.collect(toCollection(LinkedHashSet::new)); | ||
} | ||
|
||
static <T> boolean matchesTags(T obj, String... tags) { | ||
if (obj instanceof Tagged tagged) { | ||
Set<String> taggedTags = tagged.getTags(); | ||
for (String tag : tags) { | ||
if (taggedTags.contains(tag)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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 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 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 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 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 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