public void generateReport()

in src/main/java/org/apache/sling/feature/maven/mojos/reports/ScriptsImportPackagesReporter.java [53:95]


    public void generateReport(final ReportContext ctx) throws MojoExecutionException {
        final Set<ArtifactId> artifacts = new TreeSet<>();

        for (final Feature feature : ctx.getFeatures()) {
            for (final Extension ext : feature.getExtensions()) {
                if (ext.getType() == ExtensionType.ARTIFACTS
                        && Extension.EXTENSION_NAME_CONTENT_PACKAGES.equals(ext.getName())) {
                    for (final Artifact artifact : ext.getArtifacts()) {
                        if (ctx.matches(artifact.getId())) {
                            artifacts.add(artifact.getId());
                        }
                    }
                }
            }
        }

        final List<String> report = new ArrayList<>();

        for (final ArtifactId id : artifacts) {
            final URL url = ctx.getArtifactProvider().provide(id);
            try (final ZipInputStream zis = new ZipInputStream(url.openStream())) {
                ZipEntry entry = null;
                while ((entry = zis.getNextEntry()) != null) {
                    if (entry.getName().startsWith(PREFIX)) {
                        final String path = entry.getName().substring(PREFIX.length() - 1);
                        if (path.endsWith(".jsp")) {
                            final Set<String> imports = getImports(zis);
                            for (final String imp : imports) {
                                report.add(imp.concat("    ")
                                        .concat(id.toMvnId())
                                        .concat("    ")
                                        .concat(path));
                            }
                        }
                    }
                }
            } catch (final IOException ioe) {
                throw new MojoExecutionException("Unable to read from " + id.toMvnId(), ioe);
            }
        }

        ctx.addReport(this.getName().concat(".txt"), report);
    }