Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2021-01-05 13:49:17 +0000
committerMickael Istria2021-01-29 20:07:00 +0000
commit5a979f46d4be0110d6e698f56a5befb8b77c5e76 (patch)
tree15a24995cf7fa196090739411e2dfd5b87c347a9
parent22c4079a88a6ea77158effacddd3f0fb97cc5be3 (diff)
downloadrt.equinox.p2-5a979f46d4be0110d6e698f56a5befb8b77c5e76.tar.gz
rt.equinox.p2-5a979f46d4be0110d6e698f56a5befb8b77c5e76.tar.xz
rt.equinox.p2-5a979f46d4be0110d6e698f56a5befb8b77c5e76.zip
Bug 570766 - Allow mapper in artifacts.xml to use all artifact propertieI20210129-1800
Change-Id: I03ae5eb64791ff2e2a9be47de82fa7c58448adbc Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/Mapper.java48
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java9
4 files changed, 35 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
index a0243631d..a4e478736 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.artifact.repository;singleton:=true
-Bundle-Version: 1.3.500.qualifier
+Bundle-Version: 1.4.0.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.artifact.repository.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -62,5 +62,5 @@ Import-Package: javax.xml.parsers,
org.xml.sax;resolution:=optional
Service-Component: OSGI-INF/repositoryManager.xml
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: org.eclipse.equinox.p2.artifact.repository
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml b/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml
index 371c4bb24..f20d0f75f 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/pom.xml
@@ -9,7 +9,7 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId>
- <version>1.3.500-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<profiles>
<profile>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/Mapper.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/Mapper.java
index 3301b48ae..8a07be022 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/Mapper.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/Mapper.java
@@ -16,8 +16,7 @@ package org.eclipse.equinox.internal.p2.artifact.repository.simple;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Dictionary;
-import java.util.Hashtable;
+import java.util.*;
import org.eclipse.core.runtime.URIUtil;
import org.osgi.framework.*;
@@ -54,34 +53,37 @@ public class Mapper {
}
}
- public URI map(URI repositoryLocation, String classifier, String id, String version, String format) {
+ public URI map(URI repositoryLocation, String classifier, String id, String version, String format,
+ Map<String, String> properties) {
String locationString = URIUtil.toUnencodedString(repositoryLocation);
- Dictionary<String, Object> values = new Hashtable<>(5);
- if (repositoryLocation != null)
- values.put(REPOURL, locationString);
-
- if (classifier != null)
- values.put(CLASSIFIER, classifier);
-
- if (id != null)
- values.put(ID, id);
-
- if (version != null)
- values.put(VERSION, version);
-
- if (format != null)
- values.put(FORMAT, format);
+ Dictionary<String, String> allProperties = new Hashtable<>(properties.size() + 4);
+ if (repositoryLocation != null) {
+ allProperties.put(REPOURL, locationString);
+ }
+ if (classifier != null) {
+ allProperties.put(CLASSIFIER, classifier);
+ }
+ if (id != null) {
+ allProperties.put(ID, id);
+ }
+ if (version != null) {
+ allProperties.put(VERSION, version);
+ }
+ if (format != null) {
+ allProperties.put(FORMAT, format);
+ }
for (int i = 0; i < filters.length; i++) {
- if (filters[i].match(values))
- return doReplacement(outputStrings[i], locationString, classifier, id, version, format);
+ if (filters[i].match(allProperties))
+ return doReplacement(outputStrings[i], locationString, classifier, id, version, format, properties);
}
return null;
}
- private URI doReplacement(String pattern, String repoLocation, String classifier, String id, String version, String format) {
+ private URI doReplacement(String pattern, String repoLocation, String classifier, String id, String version,
+ String format, Map<String, String> properties) {
try {
- // currently our mapping rules assume the repo URL is not "/" terminated.
+ // currently our mapping rules assume the repo URL is not "/" terminated.
// This may be the case for repoURLs in the root of a URL space e.g. root of a jar file or file:/c:/
if (repoLocation.endsWith("/")) //$NON-NLS-1$
repoLocation = repoLocation.substring(0, repoLocation.length() - 1);
@@ -109,6 +111,8 @@ public class Mapper {
varValue = repoLocation;
} else if (varName.equalsIgnoreCase(FORMAT)) {
varValue = format;
+ } else if (properties.containsKey(varName)) {
+ varValue = properties.get(varName);
}
if (varValue == null)
varValue = ""; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 992beed7d..492e50667 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -558,7 +558,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
if (descriptor.getProcessingSteps().length == 0) {
descriptor.setProperty(ARTIFACT_UUID, null);
IArtifactKey key = descriptor.getArtifactKey();
- URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(), descriptor.getProperty(IArtifactDescriptor.FORMAT));
+ URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(),
+ descriptor.getProperty(IArtifactDescriptor.FORMAT), descriptor.getProperties());
if (result != null) {
if (isFolderBased(descriptor) && URIUtil.lastSegment(result).endsWith(JAR_EXTENSION)) {
return URIUtil.removeFileExtension(result);
@@ -907,7 +908,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
*/
private URI getLocationForPackedButFlatArtifacts(IArtifactDescriptor descriptor) {
IArtifactKey key = descriptor.getArtifactKey();
- return mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(), descriptor.getProperty(IArtifactDescriptor.FORMAT));
+ return mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(),
+ descriptor.getProperty(IArtifactDescriptor.FORMAT), descriptor.getProperties());
}
public synchronized URI getLocation(IArtifactDescriptor descriptor) {
@@ -936,7 +938,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
// if the descriptor is complete then use the mapping rules...
if (descriptor.getProcessingSteps().length == 0) {
IArtifactKey key = descriptor.getArtifactKey();
- URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(), descriptor.getProperty(IArtifactDescriptor.FORMAT));
+ URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(),
+ descriptor.getProperty(IArtifactDescriptor.FORMAT), descriptor.getProperties());
if (result != null) {
if (isFolderBased(descriptor) && URIUtil.lastSegment(result).endsWith(JAR_EXTENSION))
return URIUtil.removeFileExtension(result);

Back to the top