This is an automated email from the ASF dual-hosted git repository. simonetripodi pushed a commit to branch SLING-8078_double-check in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-analyser.git
commit e6109c83e7f9fa0a2f98abc65d7fa779a9be2bd7 Author: Simo Tripodi <strip...@adobe.com> AuthorDate: Mon Nov 12 12:19:41 2018 +0100 SLING-8078 - New Analyser task which is able to detect Export-Package dependencies between regions handling the error case where the same package is listed in both the exporting and hiding regions --- .../task/impl/CheckApiRegionsDependencies.java | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java index 59332b2..fa35b39 100644 --- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java +++ b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java @@ -58,18 +58,30 @@ public class CheckApiRegionsDependencies extends AbstractApiRegionsAnalyserTask String exportedPackage = packageInfo.getName(); if (exportingApis.contains(exportedPackage)) { - for (String uses : packageInfo.getUses()) { - if (hidingApis.contains(uses)) { - String errorMessage = String.format( - "Bundle '%s' (defined in feature '%s') declares '%s' in the '%s' header, enlisted in the '%s' region, which requires '%s' package that is in the '%s' region", - bundleDescriptor.getArtifact().getId(), - ctx.getFeature().getId(), - exportedPackage, - Constants.EXPORT_PACKAGE, - exportingApisName, - uses, - hidingApisName); - ctx.reportError(errorMessage); + if (hidingApis.contains(exportedPackage)) { + String errorMessage = String.format( + "Bundle '%s' (defined in feature '%s') declares '%s' in the '%s' header that is enlisted in both exporting '%s' and hiding '%s' APIs regions, please adjust Feature settings", + bundleDescriptor.getArtifact().getId(), + ctx.getFeature().getId(), + exportedPackage, + Constants.EXPORT_PACKAGE, + exportingApisName, + hidingApisName); + ctx.reportError(errorMessage); + } else { + for (String uses : packageInfo.getUses()) { + if (hidingApis.contains(uses)) { + String errorMessage = String.format( + "Bundle '%s' (defined in feature '%s') declares '%s' in the '%s' header, enlisted in the '%s' region, which requires '%s' package that is in the '%s' region", + bundleDescriptor.getArtifact().getId(), + ctx.getFeature().getId(), + exportedPackage, + Constants.EXPORT_PACKAGE, + exportingApisName, + uses, + hidingApisName); + ctx.reportError(errorMessage); + } } } }