private void execute()

in src/main/java/org/apache/sling/feature/extension/apiregions/analyser/CheckApiRegionsDependencies.java [47:82]


    private void execute(AnalyserTaskContext ctx, ApiRegions apiRegions, ApiRegion exportingApisName,
            ApiRegion hidingApisName) {
        FeatureDescriptor featureDescriptor = ctx.getFeatureDescriptor();
        for (BundleDescriptor bundleDescriptor : featureDescriptor.getBundleDescriptors()) {
            for (PackageInfo packageInfo : bundleDescriptor.getExportedPackages()) {
                String exportedPackage = packageInfo.getName();

                if (exportingApisName.getExportByName(exportedPackage) != null) {
                    if (hidingApisName.getExportByName(exportedPackage) != null) {
                        String errorMessage = String.format(
                                "Bundle '%s' (defined in feature '%s') exports package '%s' that is declared in both visible '%s' and non-visible '%s' APIs regions",
                                bundleDescriptor.getArtifact().getId(),
                                ctx.getFeature().getId(),
                                exportedPackage,
                                exportingApisName.getName(),
                                hidingApisName.getName());
                        ctx.reportArtifactError(bundleDescriptor.getArtifact().getId(), errorMessage);
                    } else {
                        for (String uses : packageInfo.getUses()) {
                            if (hidingApisName.getExportByName(uses) != null) {
                                String errorMessage = String.format(
                                        "Bundle '%s' (defined in feature '%s') exports package '%s' that is declared in the visible '%s' region, which uses package '%s' that is in the non-visible '%s' region",
                                        bundleDescriptor.getArtifact().getId(),
                                        ctx.getFeature().getId(),
                                        exportedPackage,
                                        exportingApisName.getName(),
                                        uses,
                                        hidingApisName.getName());
                                ctx.reportArtifactError(bundleDescriptor.getArtifact().getId(), errorMessage);
                            }
                        }
                    }
                }
            }
        }
    }