You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/03/06 17:46:39 UTC
[karaf] branch master updated: [KARAF-6183] Fix override for
classified artifacts.
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new 2f49475 [KARAF-6183] Fix override for classified artifacts.
new d989cdb Merge pull request #772 from Smasherr/master
2f49475 is described below
commit 2f49475ca45d1c119b9b2df0d2ca70b14c276c1b
Author: Daniel Estermann <d....@seeburger.de>
AuthorDate: Tue Mar 5 17:34:05 2019 +0100
[KARAF-6183] Fix override for classified artifacts.
We take now the pattern from override.properties, which
matches best (i.e. has the biggest length), not the last one
---
.../internal/service/FeaturesProcessorImpl.java | 27 +++++++++++++---------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java
index 518401e..6b759d8 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesProcessorImpl.java
@@ -23,6 +23,7 @@ import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -220,20 +221,24 @@ public class FeaturesProcessorImpl implements FeaturesProcessor {
private void staticOverrideBundle(Bundle bundle) {
bundle.setOverriden(BundleInfo.BundleOverrideMode.NONE);
+ String originalLocation = bundle.getLocation();
+ final List<BundleReplacements.OverrideBundle> candidates = new ArrayList<>();
for (BundleReplacements.OverrideBundle override : this.getInstructions().getBundleReplacements().getOverrideBundles()) {
- String originalLocation = bundle.getLocation();
if (override.getOriginalUriPattern().matches(originalLocation)) {
- LOG.debug("Overriding bundle location \"" + originalLocation + "\" with \"" + override.getReplacement() + "\"");
- bundle.setOriginalLocation(originalLocation);
- if (override.getMode() == BundleReplacements.BundleOverrideMode.MAVEN) {
- bundle.setOverriden(BundleInfo.BundleOverrideMode.MAVEN);
- } else {
- bundle.setOverriden(BundleInfo.BundleOverrideMode.OSGI);
- }
- bundle.setLocation(override.getReplacement());
- // TOCHECK: last rule wins - no break!!!
- //break;
+ candidates.add(override);
+ }
+ }
+ if (!candidates.isEmpty()) {
+ BundleReplacements.OverrideBundle bestMatch = candidates.stream()
+ .max((o1, o2) -> Integer.compare(o1.getReplacement().length(), o2.getReplacement().length())).get();
+ LOG.debug("Overriding bundle location \"" + originalLocation + "\" with \"" + bestMatch.getReplacement() + "\"");
+ bundle.setOriginalLocation(originalLocation);
+ if (bestMatch.getMode() == BundleReplacements.BundleOverrideMode.MAVEN) {
+ bundle.setOverriden(BundleInfo.BundleOverrideMode.MAVEN);
+ } else {
+ bundle.setOverriden(BundleInfo.BundleOverrideMode.OSGI);
}
+ bundle.setLocation(bestMatch.getReplacement());
}
}