public void execute()

in src/main/java/org/apache/sling/cpconverter/maven/mojos/ConvertPMMojo.java [140:209]


    public void execute() throws MojoExecutionException, MojoFailureException {
        if (!inputFolder.isDirectory()) {
            throw new MojoFailureException("Input Folder is not a directory: " + inputFolder);
        }
        if (!inputFolder.canRead()) {
            throw new MojoFailureException("Input Folder is not readable:" + inputFolder);
        }
        String outputFolderPath = project.getBasedir() + "/" + outputFolder;
        File output = new File(outputFolderPath);
        if (!output.exists()) {
            if(!output.mkdirs()) {
                throw new MojoFailureException("Could not create Output Folder: " + outputFolder);
            }
        }
        if (!output.isDirectory()) {
            throw new MojoFailureException("Output Folder is not a directory: " + output);
        }
        if (!output.canWrite()) {
            throw new MojoFailureException("Output Folder is not writable: " + output);
        }
        List<File> provisioningFiles = Arrays.asList(inputFolder.listFiles());
        Map<String, Object> options = new HashMap<>();
        if (groupId != null && !groupId.isEmpty()) {
            groupId = checkForPlaceholder(groupId);
            options.put("groupId", groupId);
        }
        if (version != null && !version.isEmpty()) {
            version = checkForPlaceholder(version);
            options.put("version", version);
        }
        // Todo: do we have a way to check the name?
        if (artifactId != null && !artifactId.isEmpty()) {
            artifactId = checkForPlaceholder(artifactId);
            options.put("name", artifactId);
        }
        options.put("useProvidedVersion", version != null && !version.isEmpty());
        options.put("noProvisioningModelName", noProvisioningModelName);
        frameworkProperties = trimList(frameworkProperties);
        Map<String, Map<String, String>> frameworkPropertiesMap = new HashMap<>();
        for (String value : frameworkProperties) {
            // Separate Model from Property Name Value pair. Create Sub Map if needed and then add
            getLog().info("Check Add Framework Properties Line: " + value);
            Matcher matcher = pattern.matcher(value);
            if (matcher.matches() && matcher.groupCount() == 3) {
                String modelName = matcher.group(1);
                String propName = matcher.group(2);
                String propValue = matcher.group(3);
                getLog().info("Model Name: " + modelName + ", Prop Name: " + propName + ", Value: " + propValue);
                Map<String, String> modelMap = frameworkPropertiesMap.get(modelName);
                if (modelMap == null) {
                    modelMap = new HashMap<>();
                    frameworkPropertiesMap.put(modelName, modelMap);
                }
                modelMap.put(propName, propValue);
            }
        }
        options.put("addFrameworkProperties", frameworkPropertiesMap);
        excludeBundles = trimList(excludeBundles);
        options.put("excludeBundles", excludeBundles);
        getLog().info("Excluded Bundles: " + excludeBundles);
        runModes = trimList(runModes);
        options.put("runModes", runModes);
        getLog().info("Runmodes: " + runModes);

        // Start the Conversion
        for (File file : provisioningFiles) {
            getLog().info("Handle File: " + file.getAbsolutePath());
            ProvisioningToFeature.convert(file, output, options);
        }
    }