diff --git a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tagged.java b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tagged.java index e14a1a5e72..16a9fc3358 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tagged.java +++ b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tagged.java @@ -5,11 +5,11 @@ * repositories. */ public interface Tagged { - + /** * Dummy placeholder for "empty tags". */ - String EMPTY_TAGS = "<>"; + String EMPTY_TAGS = "<>"; /** * @return a non-null list of tags. Default is empty (meaning 'no tags'). @@ -18,4 +18,5 @@ default Tags getTags() { return Tags.NO_TAGS; } + } 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 b1ca71a129..367fb6581a 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java +++ b/biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java @@ -160,4 +160,23 @@ public static Tags parse(String csvTags, Tags defaultTags) { .collect(Collectors.toCollection(LinkedHashSet::new))); } + /** + * Helper printing a csv-string of the tags for display purposes. The + * {@link Tagged#EMPTY_TAGS} is treated specially. + * + * @return a comma separated string of tags. If tags contains just 1 tag + * which is {@link Tagged#EMPTY_TAGS} then "-" is returned. If there + * are more than 1 tags, then {@link Tagged#EMPTY_TAGS} is omitted. + */ + public static String print(Tags tags) { + if (tags.internalSet.size() == 1 && tags.internalSet.contains(Tagged.EMPTY_TAGS)) { + return "-"; + } + + return tags.internalSet.stream() + .filter(tag -> !Tagged.EMPTY_TAGS.equals(tag)) + .collect(Collectors.joining(",")); + } + + } 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 dd7667493a..5ba383ac81 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 @@ -19,6 +19,7 @@ import aQute.bnd.build.Workspace; import aQute.bnd.osgi.Constants; import aQute.bnd.service.tags.Tagged; +import aQute.bnd.service.tags.Tags; import aQute.bnd.test.jupiter.InjectTemporaryDirectory; import aQute.http.testservers.HttpTestServer.Config; import aQute.lib.io.IO; @@ -134,4 +135,14 @@ void config(Map override) throws Exception { } } + @Test + public void testTagDisplay() { + assertEquals("", Tags.print(Tags.of())); + assertEquals("", Tags.print(Tags.NO_TAGS)); + assertEquals("foo", Tags.print(Tags.of("foo"))); + assertEquals("bar,foo", Tags.print(Tags.of("foo", "bar"))); + assertEquals("-", Tags.print(Tags.of(Tagged.EMPTY_TAGS))); + assertEquals("foo", Tags.print(Tags.of(Tagged.EMPTY_TAGS, "foo"))); + assertEquals("bar,foo", Tags.print(Tags.of(Tagged.EMPTY_TAGS, "foo", "bar"))); + } } diff --git a/bndtools.core/_plugin.xml b/bndtools.core/_plugin.xml index 24fee29f32..6fab870d28 100644 --- a/bndtools.core/_plugin.xml +++ b/bndtools.core/_plugin.xml @@ -824,7 +824,7 @@ helpUrl="https://bnd.bndtools.org/plugins/filerepo.html"> - + @@ -835,7 +835,7 @@ helpUrl="https://bnd.bndtools.org/plugins/osgirepo.html"> - + - + - + @@ -907,7 +907,7 @@ name="P2Repository" helpUrl="https://bnd.bndtools.org/plugins/p2repo.html"> - + @@ -917,7 +917,7 @@ name="Maven POM Repository" helpUrl="https://bnd.bndtools.org/plugins/pomrepo.html"> - + diff --git a/bndtools.core/src/bndtools/model/repo/RepositoryTreeLabelProvider.java b/bndtools.core/src/bndtools/model/repo/RepositoryTreeLabelProvider.java index 69f1a5bf3d..1f553997b4 100644 --- a/bndtools.core/src/bndtools/model/repo/RepositoryTreeLabelProvider.java +++ b/bndtools.core/src/bndtools/model/repo/RepositoryTreeLabelProvider.java @@ -1,7 +1,5 @@ package bndtools.model.repo; -import java.util.stream.Collectors; - import org.bndtools.core.ui.icons.Icons; import org.bndtools.core.ui.icons.Icons.IconBuilder; import org.bndtools.utils.jface.HyperlinkStyler; @@ -52,8 +50,7 @@ public void update(ViewerCell cell) { Tags tags = repo.getTags(); if (!tags.isEmpty()) { - label.append(" " + tags.stream() - .collect(Collectors.joining(",")), StyledString.QUALIFIER_STYLER); + label.append(" " + Tags.print(tags), StyledString.QUALIFIER_STYLER); } IconBuilder ib = Icons.builder(repo.getIcon()); diff --git a/docs/_plugins/filerepo.md b/docs/_plugins/filerepo.md index 1eed6401c0..4aefd83516 100644 --- a/docs/_plugins/filerepo.md +++ b/docs/_plugins/filerepo.md @@ -14,7 +14,7 @@ The following properties are supported: |`location` | The local filesystem directory. | Yes. | |`readonly` |Whether the repository should be read-only,| No. Default: false | | |i.e. disabled for editing from Bndtools.| | -| `tags` | Comma separated list of tags. (e.g. resolve, baseline, release) Use the <<EMPTY>> placeholder for no tags. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| No +| `tags` | Comma separated list of tags. (e.g. resolve, baseline, release) Use a placeholder like <<EMPTY>> to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| No ## Tagging diff --git a/docs/_plugins/localindexrepo.md b/docs/_plugins/localindexrepo.md index 360dd52668..164f3f9c1d 100644 --- a/docs/_plugins/localindexrepo.md +++ b/docs/_plugins/localindexrepo.md @@ -26,7 +26,7 @@ Merging the information from both tables into one, we get the following comprehe | `timeout` | `integer` | | If there is a cached file, then just use it if the cached file is within the `timeout` period OR `online` is `false`. | | | `online` | `BOOLEAN` | `true` | Specifies if this repository is online. If `false` then cached resources are used. | | | `type` | `STRING` | `R5` | The type (format) of index to generate. See _Note 1_ below. | No. | -| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use the <<EMPTY>> The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction. | No +| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use a placeholder like <<EMPTY>> to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction. | No **Note 1**: The index is generated by default in R5 format. To request alternative format(s), specify a list of format names separated by the "|" (pipe) character. For example, to generate both R5 and OBR formats specify `type=R5|OBR`. diff --git a/docs/_plugins/maven.md b/docs/_plugins/maven.md index fab12313a6..b2763fb7d4 100644 --- a/docs/_plugins/maven.md +++ b/docs/_plugins/maven.md @@ -87,7 +87,7 @@ The class name of the plugin is `aQute.bnd.repository.maven.provider.MavenBndRep | `readOnly` | `true|false` | `false` | If set to _truthy_ then this repository is read only.| | `name` | `NAME`| `Maven` | The name of the repository.| | `index` | `PATH`| `cnf/.mvn` | The path to the _index_ file. The index file is a list of Maven _coordinates_.| -| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use the <<EMPTY>> placeholder for no tags. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| +| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use a placeholder like <<EMPTY>> to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| | `source` | `STRING`| `org.osgi:org.osgi.service.log:1.3.0 org.osgi:org.osgi.service.log:1.2.0` | A space, comma, semicolon, or newline separated GAV string. | | `noupdateOnRelease` | `true|false` | `false` | If set to _truthy_ then this repository will not update the `index` when a non-snapshot artifact is released.| | `poll.time` | `integer` | 5 seconds | Number of seconds between checks for changes to the `index` file. If the value is negative or the workspace is in batch/CI mode, then no polling takes place.| diff --git a/docs/_plugins/osgirepo.md b/docs/_plugins/osgirepo.md index 2e788d3857..41c740839b 100644 --- a/docs/_plugins/osgirepo.md +++ b/docs/_plugins/osgirepo.md @@ -17,7 +17,7 @@ The class name of the plugin is `aQute.bnd.repository.osgi.OSGiRepository`. It c | `cache` | `STRING`| The workspace cache folder | The location, the downloaded bundles are stored. | | `max.stale` | `integer` | one year | Bnd has it's own download cache. `max.stale` configures for how many _seconds_ the downloaded index file stays in the internal download cache. Use _-1_ to always check if there is a newer file on the server. | | `poll.time` | `integer` | 5 seconds | Number of seconds between checks for polls on the `index` file. If the value is negative or the workspace is in batch/CI mode, then no polling takes place. | -| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use the <<EMPTY>> The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction. +| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use a placeholder like <<EMPTY>> to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction. ## Example diff --git a/docs/_plugins/p2repo.md b/docs/_plugins/p2repo.md index b6f50f8a04..0f522f8ac8 100644 --- a/docs/_plugins/p2repo.md +++ b/docs/_plugins/p2repo.md @@ -19,7 +19,7 @@ It can take the following configuration properties: | `name` | `NAME` | p2 + `url` | The name of the repository. | | `url` | `URI` | | The URL to either the P2 repository (a directory) or an Eclipse target platform definition file. | | `location` | `STRING` | | The location to store the _index_ file and where bundles will be downloaded to. | -| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use the <<EMPTY>> placeholder for no tags. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| +| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use a placeholder like <<EMPTY>> to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| ## Example diff --git a/docs/_plugins/pomrepo.md b/docs/_plugins/pomrepo.md index 4d5e5b3714..04a71f9c68 100644 --- a/docs/_plugins/pomrepo.md +++ b/docs/_plugins/pomrepo.md @@ -69,7 +69,7 @@ The query must return a JSON response. | `transitive` | `true|false` | `true` | If set to _truthy_ then dependencies are transitive.| | `poll.time` | `integer`| 5 minutes | Number of seconds between checks for changes to POM files referenced by `pom` or `revision`. If the value is negative or the workspace is in batch/CI mode, then no polling takes place.| | `dependencyManagement` | `boolean`| false | If set to `true`, dependencies in the `dependencyManagement` section will be handled as actual dependencies.| -| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use the <<EMPTY>> The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction. +| `tags` | `STRING`| | Comma separated list of tags. (e.g. resolve, baseline, release) Use a placeholder like <<EMPTY>> to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction. One, and only one, of the `pom`, `revision`, or `query` configurations can be set. If multiple are set then the first in `[pom, revision, query]` is used and the remainders are ignored.