protected void processFeature()

in src/main/java/org/apache/sling/feature/maven/mojos/AbstractRepositoryMojo.java [79:123]


    protected void processFeature(final File artifactDir, final Feature f) throws MojoExecutionException {
        for (final org.apache.sling.feature.Artifact artifact : f.getBundles()) {
            copyArtifactToRepository(artifact.getId(), artifactDir);
        }
        for (final Extension ext : f.getExtensions()) {
            if (ext.getType() == ExtensionType.ARTIFACTS) {
                for (final org.apache.sling.feature.Artifact artifact : ext.getArtifacts()) {
                    copyArtifactToRepository(artifact.getId(), artifactDir);
                }
            }
        }

        final ExecutionEnvironmentExtension eee = ExecutionEnvironmentExtension.getExecutionEnvironmentExtension(f);
        if (eee != null && eee.getFramework() != null) {
            copyArtifactToRepository(eee.getFramework().getId(), artifactDir);
        }

        final File featureFile = getRepositoryFile(artifactDir, f.getId());
        featureFile.getParentFile().mkdirs();
        try (final Writer writer = new FileWriter(featureFile)) {
            FeatureJSONWriter.write(writer, f);
        } catch (final IOException e) {
            throw new MojoExecutionException(
                    "Unable to write feature file  :" + f.getId().toMvnId(), e);
        }
        if (f.getPrototype() != null) {
            if (ProjectHelper.isLocalProjectArtifact(
                    this.project, f.getPrototype().getId())) {
                final Feature prototype = this.getLocalFeature(f.getPrototype().getId());
                if (prototype == null) {
                    throw new MojoExecutionException("Unable to find project feature "
                            + f.getPrototype().getId().toMvnId());
                }
                processFeature(artifactDir, prototype);
            } else {
                final Feature prototype = ProjectHelper.getOrResolveFeature(
                        project,
                        mavenSession,
                        artifactHandlerManager,
                        repoSystem,
                        f.getPrototype().getId());
                processFeature(artifactDir, prototype);
            }
        }
    }