From: Aurelien Poscia Date: Thu, 28 Sep 2023 13:41:59 +0000 (+0200) Subject: NO-JIRA Automatically remove useless package-info.java files X-Git-Tag: 10.3.0.82913~318 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0db6aa0cdf7e9ec2b8220be9830f10bc02bf5eba;p=sonarqube.git NO-JIRA Automatically remove useless package-info.java files --- diff --git a/build.gradle b/build.gradle index 4ac81f02a38..93ddb002c4a 100644 --- a/build.gradle +++ b/build.gradle @@ -464,6 +464,7 @@ subprojects { fileTree('src/main/java/').matching() { include "*/**/*.java" + exclude "*/**/package-info.java" }.forEach { allPathsContainingJavaFiles << it.toPath().toFile().getParent(); } @@ -478,6 +479,23 @@ subprojects { packageInfoFile << packageInfoContent } } + + def allPackageInfoFiles = [] as Set + + fileTree('src/main/java/').matching() { + include "*/**/package-info.java" + }.forEach { + allPackageInfoFiles << it.toPath().toFile(); + } + + allPackageInfoFiles.forEach { + File packageInfoFile = it; + if (!allPathsContainingJavaFiles.contains(packageInfoFile.getParent())) { + logger.warn("Deleting package info file: " + packageInfoFile) + packageInfoFile.delete(); + } + } + } } build.dependsOn(generatePackageInfo)