private static List buildFeatures()

in src/main/java/org/apache/sling/feature/modelconverter/ProvisioningToFeature.java [462:525]


    private static List<org.apache.sling.feature.Feature> buildFeatures(Model model, String bareFileName, Map<String, Object> options) {
        final List<org.apache.sling.feature.Feature> features = new ArrayList<>();

        String groupId = getOption(options, "groupId", "generated");
        String version = getOption(options, "version", "1.0.0");
        String nameOption = getOption(options, "name", "");
        boolean useProvidedVersion = getOption(options, "useProvidedVersion", false);
        List<String> dropVariables = getOption(options, "dropVariables", new ArrayList<>());
        List<String> excludeBundles = getOption(options, "excludeBundles", new ArrayList<>());
        Map<String,Map<String,String>> addFrameworkProperties = getOption(options, "addFrameworkProperties", new HashMap<String,Map<String, String>>());
        List<String> runModes = getOption(options, "runModes", new ArrayList<>());

        for(final Feature feature : model.getFeatures() ) {
            final String idString;
            String name = feature.getName();
            if (name == null) { name = "feature"; }
            name = name.replaceAll("[:]", "");

            if (!"feature".equals(name) && !name.equals(bareFileName)) {
                name = bareFileName + "_" + name;
            }

            // Todo: shouldn't a provided Version overwrite the Feature Version ?
            if ( feature.getVersion() != null && !useProvidedVersion ) {
                version = feature.getVersion();
            }

            // When providing a classifier a type must be provided and so we set it to 'slingosgifeature'
            idString =
                groupId + "/" +
                (nameOption.isEmpty() ? name : nameOption) + "/" +
                version +
                (nameOption.isEmpty() ? "" :
                    "/" + Main.PACKAGING_FEATURE + "/" + name );
            final org.apache.sling.feature.Feature f = new org.apache.sling.feature.Feature(ArtifactId.parse(idString));
            features.add(f);

            Map<String,String> variables = f.getVariables();
            if(dropVariables != null) {
                for (String variableName : dropVariables) {
                    if (variables.containsKey(variableName)) {
                        variables.remove(variableName);
                    }
                }
            }
            Map<String,String> frameworkProperties = f.getFrameworkProperties();
            String simpleName = feature.getName().replaceAll("[:]", "");
            if(addFrameworkProperties.containsKey(simpleName)) {
                Map<String,String> modelFeatureProperties = addFrameworkProperties.get(simpleName);
                if(modelFeatureProperties != null) {
                    for(Entry<String,String> entry: modelFeatureProperties.entrySet()) {
                        frameworkProperties.put(entry.getKey(), entry.getValue());
                    }
                }
            }
            buildFromFeature(feature, variables, dropVariables, f.getBundles(), excludeBundles, f.getConfigurations(), runModes, f.getExtensions(), frameworkProperties);

            if (!f.getId().getArtifactId().equals(feature.getName())) {
                f.getVariables().put(FeatureToProvisioning.PROVISIONING_MODEL_NAME_VARIABLE, feature.getName());
            }
        }

        return features;
    }