protected void executeWithArtifacts()

in src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java [60:97]


    protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException {
        Document doc = new Document();

        Element features = new Element("features");
        doc.setRootElement(features);
        features.setAttribute("name", featuresName);

        Element feature = new Element("feature");
        features.addContent(feature);
        feature.setAttribute("name", featureName);
        feature.setAttribute("version", featureVersion);

        BundleList bundleList = getInitializedBundleList();
        for (StartLevel level : bundleList.getStartLevels()) {
            for (Bundle bundle : level.getBundles()) {
                String bundleRef = String.format("mvn:%s/%s/%s", bundle.getGroupId(), bundle.getArtifactId(), bundle
                        .getVersion());
                feature.addContent(new Element("bundle").setText(bundleRef));
            }
        }

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(outputFile);
            new XMLOutputter(Format.getPrettyFormat().setEncoding("UTF-8")).output(doc, out);
            projectHelper.attachArtifact(project, TYPE, CLASSIFIER, outputFile);
        } catch (IOException e) {
            throw new MojoExecutionException("Unable to write features.xml", e);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                }
            }
        }

    }