Skip to content

Commit ab35199

Browse files
committed
introduce -activetags instruction
this allows us to build backwards compatible filtering of tags e.g. repotags. Signed-off-by: Christoph Rueger <[email protected]>
1 parent 736ab82 commit ab35199

File tree

4 files changed

+7
-45
lines changed

4 files changed

+7
-45
lines changed

biz.aQute.bndlib/src/aQute/bnd/build/Workspace.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,17 @@ public List<RepositoryPlugin> getRepositories(String... tags) {
731731
return data.repositories.get();
732732
}
733733

734+
Tags activeTags = Tags.parse(getProperty(Constants.ACTIVETAGS), Tags.of(Constants.REPOTAGS_RESOLVE));
735+
734736
return data.repositories.get()
735737
.stream()
736738
.filter(repo -> {
737739
Tags repotags = repo.getTags();
738740

739-
if (repotags == null || repotags.includesAny(tags)) {
741+
if (repotags == null || !activeTags.includesAny(tags) || repotags.includesAny(tags)) {
740742
return true;
741743
}
744+
742745
return false;
743746
})
744747
.toList();

biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public interface Constants {
258258

259259
String REMOTEWORKSPACE = "-remoteworkspace";
260260

261+
String ACTIVETAGS = "-activetags";
261262
/**
262263
* tags for repos which should be used for Resolving bundles. This is also
263264
* the default tag for all repos which not have specified tags (also for bc

biz.aQute.bndlib/src/aQute/bnd/service/tags/Tags.java

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,7 @@ public String toString() {
111111
return internalSet.toString();
112112
}
113113

114-
/** Set to {@code false} and delete the whole block in 7.3.0 */
115-
private static final boolean TRANSITION_COMPILE_IMPLIES_RESOLVE = true;
116-
/** Only emit the warning once to avoid log spam. */
117-
private static final java.util.concurrent.atomic.AtomicBoolean WARNED = new java.util.concurrent.atomic.AtomicBoolean(
118-
false);
119-
120-
private static void warnOnceCompileResolveBridge() {
121-
122-
if (WARNED.compareAndSet(false, true)) {
123-
org.slf4j.LoggerFactory.getLogger(Tags.class)
124-
.warn("Tags contain tag \"resolve\" only – "
125-
+ "this still satisfies a request for \"compile\" in 7.2.x "
126-
+ "but will NOT in 7.3. Add the tag \"compile\".");
127-
}
128-
}
114+
129115

130116
/**
131117
* Returns {@code true} if this entity should take part in <i>any</i> of the
@@ -141,11 +127,6 @@ private static void warnOnceCompileResolveBridge() {
141127
* of all other rules (example 'nocompile'.
142128
* 3. **Positive tag match** – if the entity contains a tag that matches a
143129
* requested glob, it is included.
144-
* 4. **7.2 bridge** – while {@link #TRANSITION_COMPILE_IMPLIES_RESOLVE} is
145-
* {@code true}, a request for {@code "compile"} also accepts entities that
146-
* have {@code "resolve"} (and <i>no</i> {@code "noCompile"}).
147-
* The first use logs a deprecation warning; this block will be removed
148-
* in 7.3.
149130
* // @formatter:on
150131
*
151132
* @param tags (globs)
@@ -167,29 +148,9 @@ public boolean includesAny(String... tags) {
167148

168149
for (String tagGlob : tags) {
169150

170-
String phase = tagGlob; // e.g. "compile"
171-
String negativePhase = "no" + phase; // "noCompile"
172-
173-
/* 1. Explicit negative tag blocks this phase --------------- */
174-
if (matchesAny(new Glob(negativePhase))) {
175-
continue; // try next requested tag
176-
}
177-
178-
/* 2. Positive tag match ------------------------------------ */
179151
if (matchesAny(new Glob(tagGlob))) {
180152
return true; // success
181153
}
182-
183-
/* 3. Transitional bridge (compile ⇒ resolve) -------------- */
184-
if (TRANSITION_COMPILE_IMPLIES_RESOLVE && "compile".equalsIgnoreCase(phase)
185-
&& matchesAny(new Glob("resolve")) && !matchesAny(new Glob("noCompile"))) { // negative
186-
// still
187-
// wins
188-
189-
warnOnceCompileResolveBridge(); // log only first time
190-
return true;
191-
}
192-
// ↑↑↑ remove in 7.3
193154
}
194155

195156
return false;

biz.aQute.repository/test/aQute/bnd/repository/maven/provider/WorkspaceTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ public void testTags(SoftAssertions softly) {
169169
softly.assertThat(Tags.of("resolve")
170170
.includesAny("resolve"))
171171
.isTrue();
172-
// only in 7.2.0, will be stop working in 7.3.0
173-
softly.assertThat(Tags.of("resolve")
174-
.includesAny("compile"))
175-
.isTrue();
172+
176173

177174
softly.assertThat(Tags.of("resolve", "compile")
178175
.includesAny("resolve"))

0 commit comments

Comments
 (0)