You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2021/09/07 05:12:50 UTC

[ranger] branch ranger-2.2 updated: RANGER-3398: Duplicate JAVA patch suffix should not be allowed

This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a commit to branch ranger-2.2
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/ranger-2.2 by this push:
     new f636ad0  RANGER-3398: Duplicate JAVA patch suffix should not be allowed
f636ad0 is described below

commit f636ad05ba32cc3f11d924330376a0a5a4c88323
Author: Kishor Gollapalliwar <ki...@gmail.com>
AuthorDate: Mon Sep 6 13:08:14 2021 +0530

    RANGER-3398: Duplicate JAVA patch suffix should not be allowed
    
    Signed-off-by: pradeep <pr...@apache.org>
---
 security-admin/pom.xml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 47d40c2..bbafed2 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -838,14 +838,14 @@
                 </executions>
             </plugin>
 
-            <!-- duplicate SQL prefix validator plugin -->
+            <!-- duplicate SQL patch file version validator plugin -->
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-enforcer-plugin</artifactId>
                 <version>1.4.1</version>
                 <executions>
                     <execution>
-                        <id>duplicate-sql-file-prefix-validator</id>
+                        <id>duplicate-sql-patch-file-version-validator</id>
                         <goals>
                             <goal>enforce</goal>
                         </goals>
@@ -893,6 +893,56 @@
                     </execution>
                 </executions>
             </plugin>
+
+            <!-- duplicate JAVA patch file version validator plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <version>1.4.1</version>
+                <executions>
+                    <execution>
+                        <id>duplicate-java-patch-file-version-validator</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                        <phase>validate</phase>
+                        <configuration>
+                            <rules>
+                                <evaluateBeanshell>
+                                    <message>Looks like there are multiple JAVA files with same version number suffix. Update suffix and build again.</message>
+                                    <condition>
+                                        List javaFilePaths  = org.codehaus.plexus.util.FileUtils.getFileNames(new File("security-admin/src/main/java/org/apache/ranger/patch"), "**/*.java", null, false);
+                                        Map javaFileMap     = new HashMap();
+                                        Boolean noDupSuffix = true;
+
+                                        for (Iterator it = javaFilePaths.iterator(); it.hasNext();) {
+                                            String currentJavaFilePath = it.next();
+
+                                            if (currentJavaFilePath.startsWith("Patch")) {
+                                                String versionSuffix = currentJavaFilePath.split("_J")[1];
+                                                String javaFile      = javaFileMap.get(versionSuffix);
+
+                                                if (javaFile == null) {
+                                                    javaFileMap.put(versionSuffix, currentJavaFilePath);
+                                                } else {
+                                                    print("Multiple JAVA files with suffix: " + versionSuffix + " found, hence triggering build failure.");
+                                                    print("Review suffixes for following files.");
+                                                    print("1. " + javaFile);
+                                                    print("2. " + currentJavaFilePath);
+                                                    noDupSuffix = false;
+                                                };
+                                            };
+                                        };
+
+                                        noDupSuffix
+                                    </condition>
+                                </evaluateBeanshell>
+                            </rules>
+                            <fail>true</fail>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
         <resources>
             <resource>