You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2018/11/21 14:01:20 UTC

[sling-org-apache-sling-feature] branch master updated: Move extension constants to Extension class

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a7a0cc  Move extension constants to Extension class
2a7a0cc is described below

commit 2a7a0ccdf79d3e850e13144c408052f3bffc84ae
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Nov 21 15:01:11 2018 +0100

    Move extension constants to Extension class
---
 .../java/org/apache/sling/feature/Extension.java   | 23 ++++++++++-
 .../org/apache/sling/feature/FeatureConstants.java | 44 ----------------------
 .../sling/feature/builder/FeatureBuilder.java      | 22 +++++------
 .../sling/feature/builder/FeatureBuilderTest.java  | 35 +++++++++--------
 4 files changed, 50 insertions(+), 74 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/Extension.java b/src/main/java/org/apache/sling/feature/Extension.java
index 577c0bb..b9b513c 100644
--- a/src/main/java/org/apache/sling/feature/Extension.java
+++ b/src/main/java/org/apache/sling/feature/Extension.java
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.feature;
 
+import org.apache.sling.feature.builder.BuilderContext;
+
 /**
  * An Extension can either be of type
  * <ul>
@@ -25,11 +27,30 @@ package org.apache.sling.feature;
  * </ul>
  *
  * This class is not thread-safe.
- * 
+ *
  * @see ExtensionType
  */
 public class Extension {
 
+    /**
+     * Common extension name to specify the repoinit part for Apache Sling. This
+     * extension is of type {@link ExtensionType#TEXT} and is required.
+     */
+    public static final String EXTENSION_NAME_REPOINIT = "repoinit";
+
+    /**
+     * Common extension name to specify the content packages for Apache Sling. This
+     * extension is of type {@link ExtensionType#ARTIFACTS} and is required.
+     */
+    public static final String EXTENSION_NAME_CONTENT_PACKAGES = "content-packages";
+
+    /**
+     * Extension name containing the assembled features as produced by
+     * {@link org.apache.sling.feature.builder.FeatureBuilder#assemble(ArtifactId, BuilderContext, Feature...)}.
+     * This extension is of type {@link ExtensionType#ARTIFACTS} and is optional.
+     */
+    public static final String EXTENSION_NAME_ASSEMBLED_FEATURES = "assembled-features";
+
     /** The extension type */
     private final ExtensionType type;
 
diff --git a/src/main/java/org/apache/sling/feature/FeatureConstants.java b/src/main/java/org/apache/sling/feature/FeatureConstants.java
deleted file mode 100644
index 3072711..0000000
--- a/src/main/java/org/apache/sling/feature/FeatureConstants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.sling.feature;
-
-import org.apache.sling.feature.builder.BuilderContext;
-
-public abstract class FeatureConstants {
-
-    /**
-     * Common extension name to specify the repoinit part for Apache Sling.
-     * This extension is of type {@link ExtensionType#TEXT} and is
-     * required.
-     */
-    public static final String EXTENSION_NAME_REPOINIT = "repoinit";
-
-    /**
-     * Common extension name to specify the content packages for Apache Sling.
-     * This extension is of type {@link ExtensionType#ARTIFACTS} and is
-     * required.
-     */
-    public static final String EXTENSION_NAME_CONTENT_PACKAGES = "content-packages";
-
-    /**
-     * Extension name containing the assembled features as produced
-     * by {@link org.apache.sling.feature.builder.FeatureBuilder#assemble(ArtifactId, BuilderContext, Feature...)}.
-     * This extension is of type {@link ExtensionType#ARTIFACTS} and is
-     * optional.
-     */
-    public static final String EXTENSION_NAME_ASSEMBLED_FEATURES = "assembled-features";
-}
diff --git a/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java b/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
index 0cf02ca..beb4173 100644
--- a/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
+++ b/src/main/java/org/apache/sling/feature/builder/FeatureBuilder.java
@@ -16,16 +16,6 @@
  */
 package org.apache.sling.feature.builder;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.ExtensionType;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.FeatureConstants;
-import org.apache.sling.feature.Include;
-import org.osgi.framework.Version;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -36,6 +26,15 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Configuration;
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.ExtensionType;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.Include;
+import org.osgi.framework.Version;
+
 public abstract class FeatureBuilder {
     /** This key is used to track origins while includes are merged in */
     private static final String TRACKING_KEY = "tracking-key";
@@ -201,7 +200,8 @@ public abstract class FeatureBuilder {
         }
 
         // append feature list in extension
-        final Extension list = new Extension(ExtensionType.ARTIFACTS, FeatureConstants.EXTENSION_NAME_ASSEMBLED_FEATURES, false);
+        final Extension list = new Extension(ExtensionType.ARTIFACTS, Extension.EXTENSION_NAME_ASSEMBLED_FEATURES,
+                false);
         for(final ArtifactId id : usedFeatures) {
             list.getArtifacts().add(new Artifact(id));
         }
diff --git a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
index b81a7f2..0526266 100644
--- a/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
+++ b/src/test/java/org/apache/sling/feature/builder/FeatureBuilderTest.java
@@ -16,6 +16,22 @@
  */
 package org.apache.sling.feature.builder;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.felix.utils.resource.CapabilityImpl;
 import org.apache.felix.utils.resource.RequirementImpl;
 import org.apache.sling.feature.Artifact;
@@ -24,28 +40,11 @@ import org.apache.sling.feature.Configuration;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.Include;
 import org.junit.Test;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 public class FeatureBuilderTest {
 
     private static final Map<String, Feature> FEATURES = new HashMap<>();
@@ -687,7 +686,7 @@ public class FeatureBuilderTest {
                 return null;
             }
                 }), a, b);
-        final Extension list = target.getExtensions().getByName(FeatureConstants.EXTENSION_NAME_ASSEMBLED_FEATURES);
+        final Extension list = target.getExtensions().getByName(Extension.EXTENSION_NAME_ASSEMBLED_FEATURES);
         assertNotNull(list);
         assertEquals(1, list.getArtifacts().size());
         assertEquals(idB, list.getArtifacts().get(0).getId());