This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.4.2 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git
commit 967d25a0bb0336717aca9b4d6a7de3476703fed7 Author: Carsten Ziegeler <cziege...@apache.org> AuthorDate: Fri Nov 27 07:21:10 2015 +0000 SLING-5318 : Sling provisioning model does not propagate Artifact metadata during processing. Apply patch from David Bosschaert git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/provisioning-model@1716803 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/sling/provisioning/model/Artifact.java | 20 +++++++++++++++ .../model/EffectiveModelProcessor.java | 4 +-- .../sling/provisioning/model/ModelUtility.java | 3 ++- .../sling/provisioning/model/package-info.java | 2 +- .../org/apache/sling/provisioning/model/U.java | 30 ++++++++++++++-------- src/test/resources/example.txt | 4 +-- 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/sling/provisioning/model/Artifact.java b/src/main/java/org/apache/sling/provisioning/model/Artifact.java index 9649671..f410066 100644 --- a/src/main/java/org/apache/sling/provisioning/model/Artifact.java +++ b/src/main/java/org/apache/sling/provisioning/model/Artifact.java @@ -16,6 +16,7 @@ */ package org.apache.sling.provisioning.model; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -54,6 +55,24 @@ public class Artifact extends Commentable implements Comparable { final String version, final String classifier, final String type) { + this(gId, aId, version, classifier, type, Collections.<String, String>emptyMap()); + } + + /** + * Create a new artifact object + * @param gId The group id (required) + * @param aId The artifact id (required) + * @param version The version (required) + * @param classifier The classifier (optional) + * @param type The type/extension (optional, defaults to jar) + * @param metadata The metadata associated with the Artifact + */ + public Artifact(final String gId, + final String aId, + final String version, + final String classifier, + final String type, + final Map<String, String> metadata) { this.groupId = (gId != null ? gId.trim() : null); this.artifactId = (aId != null ? aId.trim() : null); this.version = (version != null ? version.trim() : null); @@ -69,6 +88,7 @@ public class Artifact extends Commentable implements Comparable { } else { this.classifier = trimmedClassifier; } + this.metadata.putAll(metadata); } /** diff --git a/src/main/java/org/apache/sling/provisioning/model/EffectiveModelProcessor.java b/src/main/java/org/apache/sling/provisioning/model/EffectiveModelProcessor.java index 8a18d8f..c2efa5c 100644 --- a/src/main/java/org/apache/sling/provisioning/model/EffectiveModelProcessor.java +++ b/src/main/java/org/apache/sling/provisioning/model/EffectiveModelProcessor.java @@ -31,7 +31,7 @@ import org.apache.sling.provisioning.model.ModelUtility.VariableResolver; * Resolves all variables and artifact dependencies for the {@link ModelUtility#getEffectiveModel(Model)} method. */ class EffectiveModelProcessor extends ModelProcessor { - + private final ResolverOptions options; public EffectiveModelProcessor(ResolverOptions options) { @@ -50,7 +50,7 @@ class EffectiveModelProcessor extends ModelProcessor { final String type = replace(newFeature, artifact.getType(), options.getVariableResolver()); final String resolvedVersion = resolveArtifactVersion(groupId, artifactId, version, classifier, type, options.getArtifactVersionResolver()); - return new Artifact(groupId, artifactId, resolvedVersion, classifier, type); + return new Artifact(groupId, artifactId, resolvedVersion, classifier, type, artifact.getMetadata()); } @Override diff --git a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java index f01445d..376a80a 100644 --- a/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java +++ b/src/main/java/org/apache/sling/provisioning/model/ModelUtility.java @@ -310,7 +310,8 @@ public abstract class ModelUtility { artifact.getArtifactId(), newVersion, artifact.getClassifier(), - artifact.getType()); + artifact.getType(), + artifact.getMetadata()); } }; diff --git a/src/main/java/org/apache/sling/provisioning/model/package-info.java b/src/main/java/org/apache/sling/provisioning/model/package-info.java index 656dcb0..a8beffb 100644 --- a/src/main/java/org/apache/sling/provisioning/model/package-info.java +++ b/src/main/java/org/apache/sling/provisioning/model/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("1.4.0") +@Version("1.5.0") package org.apache.sling.provisioning.model; import aQute.bnd.annotation.Version; diff --git a/src/test/java/org/apache/sling/provisioning/model/U.java b/src/test/java/org/apache/sling/provisioning/model/U.java index 45ac79c..064cc0e 100644 --- a/src/test/java/org/apache/sling/provisioning/model/U.java +++ b/src/test/java/org/apache/sling/provisioning/model/U.java @@ -16,22 +16,23 @@ */ package org.apache.sling.provisioning.model; -import static org.apache.sling.provisioning.model.ModelConstants.DEFAULT_RUN_MODE; -import static org.apache.sling.provisioning.model.ModelConstants.DEFAULT_START_LEVEL; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.InputStreamReader; import java.io.Reader; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.sling.provisioning.model.io.ModelReader; +import static org.apache.sling.provisioning.model.ModelConstants.DEFAULT_RUN_MODE; +import static org.apache.sling.provisioning.model.ModelConstants.DEFAULT_START_LEVEL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** Test utilities */ public class U { @@ -39,10 +40,16 @@ public class U { new String[] {"boot.txt", "example.txt", "main.txt", "oak.txt"}; public static void assertArtifact(ArtifactGroup g, String mvnUrl) { + assertArtifact(g, mvnUrl, Collections.<String,String>emptyMap()); + } + + public static void assertArtifact(ArtifactGroup g, String mvnUrl, Map<String, String> metadata) { final Artifact a = Artifact.fromMvnUrl(mvnUrl); - if(!g.items.contains(a)) { + int idx = g.items.indexOf(a); + if(idx < 0) { fail("Expecting ArtifactGroup to contain '" + mvnUrl + "': " + g); } + assertEquals("Incorrect metadata", metadata, g.items.get(idx).getMetadata()); } /** Read our test model by merging our TEST_MODEL_FILENAMES */ @@ -111,7 +118,8 @@ public class U { { final ArtifactGroup g = getGroup(m, "example", DEFAULT_RUN_MODE, DEFAULT_START_LEVEL); - U.assertArtifact(g, "mvn:commons-collections/commons-collections/3.2.1/jar"); + U.assertArtifact(g, "mvn:commons-collections/commons-collections/3.2.1/jar", + Collections.singletonMap("private-packages", "*")); U.assertArtifact(g, "mvn:org.example/jar-is-default/1.2/jar"); } @@ -135,7 +143,7 @@ public class U { final Feature exampleFeature = m.getFeature("example"); final RunMode defaultExampleRM = exampleFeature.getRunMode(); final List<Configuration> configs = assertConfigurationsInRunMode(defaultExampleRM, 3); - assertEquals(FeatureTypes.SUBSYSTEM_FEATURE, exampleFeature.getType()); + assertEquals(FeatureTypes.SUBSYSTEM_COMPOSITE, exampleFeature.getType()); final Configuration cfg = assertConfiguration(configs, "org.apache.sling.another.config"); } diff --git a/src/test/resources/example.txt b/src/test/resources/example.txt index 8dc198b..796ce17 100644 --- a/src/test/resources/example.txt +++ b/src/test/resources/example.txt @@ -20,7 +20,7 @@ # # A feature consists of variables and run mode dependent artifacts. # -[feature name=example type=osgi.subsystem.feature] +[feature name=example type=osgi.subsystem.composite] # The variables are global and can be used within artifact definitions, configurations, # and settings. # @@ -38,7 +38,7 @@ [artifacts] commons-io/commons-io/1.4/jar commons-fileupload/commons-fileupload/1.3.1/jar - commons-collections/commons-collections/3.2.1/jar + commons-collections/commons-collections/3.2.1/jar [private-packages=*] commons-codec/commons-codec/1.9/jar commons-lang/commons-lang/2.6/jar org.apache.commons/commons-math/2.2/jar -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.