Skip to content

Commit

Permalink
Merge pull request #6171 from chrisrueger/rename-empty-repo-tag
Browse files Browse the repository at this point in the history
Hide <<EMPTY>> repo tag in Repo Browser
  • Loading branch information
chrisrueger authored Jul 5, 2024
2 parents a58a37f + cc84d3e commit 28c3ff3
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 18 deletions.
5 changes: 3 additions & 2 deletions biz.aQute.bndlib/src/aQute/bnd/service/tags/Tagged.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* repositories.
*/
public interface Tagged {

/**
* Dummy placeholder for "empty tags".
*/
String EMPTY_TAGS = "<<EMPTY>>";
String EMPTY_TAGS = "<<EMPTY>>";

/**
* @return a non-null list of tags. Default is empty (meaning 'no tags').
Expand All @@ -18,4 +18,5 @@ default Tags getTags() {
return Tags.NO_TAGS;
}


}
19 changes: 19 additions & 0 deletions biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(","));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -134,4 +135,14 @@ void config(Map<String, String> 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")));
}
}
12 changes: 6 additions & 6 deletions bndtools.core/_plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@
helpUrl="https://bnd.bndtools.org/plugins/filerepo.html">
<property name="name" type="string"
description="Name of the repository" />
<property name="tags" type="combo" description="Comma separated list of tags. (e.g. resolve, baseline, release) Use the &lt;&lt;EMPTY&gt;&gt; placeholder for no tags." options="&lt;&lt;EMPTY&gt;&gt;,resolve" />
<property name="tags" type="combo" description="Comma separated list ('resolve' used for resolution. See -runrepos instruction for details). Use &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution." options="resolve,&lt;&lt;EMPTY&gt;&gt;" />
<property name="location" type="string"
description="Local directory path" />
<property name="readonly" type="boolean" default="false" />
Expand All @@ -835,7 +835,7 @@
helpUrl="https://bnd.bndtools.org/plugins/osgirepo.html">
<property name="name" type="string"
description="Name of the repository" />
<property name="tags" type="combo" description="Comma separated list of tags. (e.g. resolve, baseline, release) Use the &lt;&lt;EMPTY&gt;&gt; placeholder for no tags." options="&lt;&lt;EMPTY&gt;&gt;,resolve" />
<property name="tags" type="combo" description="Comma separated list ('resolve' used for resolution. See -runrepos instruction for details). Use &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution." options="resolve,&lt;&lt;EMPTY&gt;&gt;" />
<property name="locations" type="string"
description="Index locations (comma-separated list of URLs)" />
<property name="cache" type="string"
Expand All @@ -848,7 +848,7 @@
helpUrl="https://bnd.bndtools.org/plugins/localindexrepo.html">
<property name="name" type="string"
description="Name of the repository" />
<property name="tags" type="combo" description="Comma separated list of tags. (e.g. resolve, baseline, release) Use the &lt;&lt;EMPTY&gt;&gt; placeholder for no tags." options="&lt;&lt;EMPTY&gt;&gt;,resolve" />
<property name="tags" type="combo" description="Comma separated list ('resolve' used for resolution. See -runrepos instruction for details). Use &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution." options="resolve,&lt;&lt;EMPTY&gt;&gt;" />
<property name="local" type="string"
description="Local directory path" />
<property name="phase" type="string"
Expand Down Expand Up @@ -887,7 +887,7 @@
helpUrl="https://bnd.bndtools.org/plugins/maven.html"
rank="10">
<property name="name" type="string" description="The name of this repository" default="Maven Repository" />
<property name="tags" type="combo" description="Comma separated list of tags. (e.g. resolve, baseline, release) Use the &lt;&lt;EMPTY&gt;&gt; placeholder for no tags." options="&lt;&lt;EMPTY&gt;&gt;,resolve" />
<property name="tags" type="combo" description="Comma separated list ('resolve' used for resolution. See -runrepos instruction for details). Use &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution." options="resolve,&lt;&lt;EMPTY&gt;&gt;" />
<property name="releaseUrl" type="string" description="The urls to the remote release repository." default="https://repo.maven.apache.org/maven2/" />
<property name="stagingUrl" type="string" description="The url of the staging release repository." />
<property name="snapshotUrl" type="string" description="The urls to the remote snapshot repository." default="https://repository.apache.org/snapshots/" />
Expand All @@ -907,7 +907,7 @@
name="P2Repository"
helpUrl="https://bnd.bndtools.org/plugins/p2repo.html">
<property name="name" type="string" description="The name of this repository" default="P2Repository" />
<property name="tags" type="combo" description="Comma separated list of tags. (e.g. resolve, baseline, release) Use the &lt;&lt;EMPTY&gt;&gt; placeholder for no tags." options="&lt;&lt;EMPTY&gt;&gt;,resolve" />
<property name="tags" type="combo" description="Comma separated list ('resolve' used for resolution. See -runrepos instruction for details). Use &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution." options="resolve,&lt;&lt;EMPTY&gt;&gt;" />
<property name="url" type="string" description="The URL to either the P2 repository (a directory) or an Eclipse target platform. Required." />
<property name="location" type="string" description="The location to store the index file. Default: 'cnf/cache/p2-index-reponame/index.xml.gz'" />
</plugin>
Expand All @@ -917,7 +917,7 @@
name="Maven POM Repository"
helpUrl="https://bnd.bndtools.org/plugins/pomrepo.html">
<property name="name" type="string" description="The name of the repo. Required." default="Maven POM Repository" />
<property name="tags" type="combo" description="Comma separated list of tags. (e.g. resolve, baseline, release) Use the &lt;&lt;EMPTY&gt;&gt; placeholder for no tags." options="&lt;&lt;EMPTY&gt;&gt;,resolve" />
<property name="tags" type="combo" description="Comma separated list ('resolve' used for resolution. See -runrepos instruction for details). Use &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution." options="resolve,&lt;&lt;EMPTY&gt;&gt;" />
<property name="releaseUrl" type="string" description="The url to the remote release repository. Can be a comma separated list of urls." default="https://repo.maven.apache.org/maven2/" />
<property name="snapshotUrl" type="string" description="The url to the remote snapshot repository. If this is not specified, it falls back to the release repository or just local if this is also not specified. Can be a comma separated list of urls." default="https://repository.apache.org/snapshots/" />
<property name="local" type="string" description="The path to the local repository" default="~/.m2/repository" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion docs/_plugins/filerepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;&lt;EMPTY&gt;&gt; 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 &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.| No


## Tagging
Expand Down
2 changes: 1 addition & 1 deletion docs/_plugins/localindexrepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;&lt;EMPTY&gt;&gt; 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 &lt;&lt;EMPTY&gt;&gt; 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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/_plugins/maven.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>.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 &lt;&lt;EMPTY&gt;&gt; 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 &lt;&lt;EMPTY&gt;&gt; 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.|
Expand Down
2 changes: 1 addition & 1 deletion docs/_plugins/osgirepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;&lt;EMPTY&gt;&gt; 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 &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.

## Example

Expand Down
2 changes: 1 addition & 1 deletion docs/_plugins/p2repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;&lt;EMPTY&gt;&gt; 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 &lt;&lt;EMPTY&gt;&gt; to exclude the repo from resolution. The `resolve` tag is picked up by the [-runrepos](/instructions/runrepos.html) instruction.|

## Example

Expand Down
2 changes: 1 addition & 1 deletion docs/_plugins/pomrepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 &lt;&lt;EMPTY&gt;&gt; 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 &lt;&lt;EMPTY&gt;&gt; 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.
Expand Down

0 comments on commit 28c3ff3

Please sign in to comment.