]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA Automatically remove useless package-info.java files
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Thu, 28 Sep 2023 13:41:59 +0000 (15:41 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 28 Sep 2023 20:03:13 +0000 (20:03 +0000)
build.gradle

index 4ac81f02a386e0ec70021bdd6c1d24d59118cefc..93ddb002c4a88a476f16a5e4884ec6ec0e57f0f5 100644 (file)
@@ -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)