ISSUE-2640: BP-43: Gradle integration with RAT plugin (#2683)

Co-authored-by: Prashant <prashantk@splunk.com>
Co-authored-by: Matteo Merli <mmerli@apache.org>
diff --git a/build.gradle b/build.gradle
index 5168769..ec69a09 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,6 +26,7 @@
     id 'com.google.protobuf'
     id 'java'
     id 'checkstyle'
+    id 'org.nosphere.apache.rat'
 }
 
 subprojects {
@@ -43,6 +44,7 @@
         apply plugin: 'java'
         apply plugin: 'maven-publish'
         apply plugin: 'signing'
+        apply plugin: 'org.nosphere.apache.rat'
         apply plugin: "checkstyle"
         checkstyle {
             toolVersion "${checkStyleVersion}"
@@ -61,6 +63,49 @@
             from sourceSets.test.output
         }
 
+        // TODO- Seperate rat plugins and other plugins configuration in seperate files
+        rat {
+            excludes = [
+                    '**/.*/**',
+                    '**/*.ipr',
+                    '**/out/**',
+                    '**/generated/**',
+                    '**/build/**',
+                    '**/.idea/**',
+                    '.git/**/*',
+                    '.github/**/*',
+                    '**/.gitignore',
+                    '**/.svn/**/*',
+                    '**/target/**/*',
+                    '**/README.md',
+                    '**/README.rst',
+                    '**/apidocs/*',
+                    '**/src/main/resources/deps/**',
+                    '**/META-INF/**',
+                    '**/.classpath',
+                    '**/.project',
+                    '**/.checkstyle',
+                    '**/.settings/*',
+                    '**/*.iml',
+                    '**/*.iws',
+                    '**/*.ipr',
+                    'site/**',
+                    'site2/**',
+                    '**/*.log',
+                    'data/**',
+                    'dev/.vagrant/**',
+                    '**/proto/**.py',
+                    '**/keyStoreClientPassword.txt',
+                    '**/keyStoreServerPassword.txt',
+                    '**/proc_cpuinfo.txt',
+                    '**/__pycache__/**',
+                    '**/bookkeeper.egg-info/**',
+                    '**/apache_bookkeeper_client.egg-info/**',
+                    '**/pip-selfcheck.json',
+                    '**/test_conf_2.conf'
+            ]
+        }
+
         configurations {
             testArtifacts.extendsFrom testRuntime
         }
diff --git a/gradle.properties b/gradle.properties
index 6a2b313..6caefd9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -20,6 +20,7 @@
 #
 
 protobufPluginVersion=0.8.15
+apcheRatPluginVersion=0.7.0
 shadowPluginVersion=6.1.0
 licenseGradlePluginVersion=0.15.0
 checkStyleVersion=6.19
diff --git a/settings.gradle b/settings.gradle
index 865d79e..c724835 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -19,6 +19,7 @@
 pluginManagement {
     plugins {
         id "com.google.protobuf" version "${protobufPluginVersion}"
+        id "org.nosphere.apache.rat" version "${apcheRatPluginVersion}"
         id "com.github.johnrengelman.shadow" version "${shadowPluginVersion}"
         id "com.github.hierynomus.license" version "${licenseGradlePluginVersion}"
     }