From e6abe7b4e8a799c7215898c510726f6509adbf29 Mon Sep 17 00:00:00 2001 From: qxo <49526356@qq.com> Date: Sat, 19 Sep 2020 08:38:16 +0800 Subject: [PATCH] [MCHECKSTYLE-397] support ${config_loc} on checkstyle xml we can use config_loc as: ${config_loc}/suppressions.xml. with this PR, we can use same checkstyle.xml which contains ${config_loc} for eclipsecs ${config_loc} is a variable of Eclipse and it will refer to the same directory where the checkstyle.xml is present. ref: https://checkstyle.org/eclipse-cs/#!/properties --- .../checkstyle/exec/DefaultCheckstyleExecutor.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java index ce7f213d..82d84b82 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java @@ -584,6 +584,20 @@ private Properties getOverridingProperties( CheckstyleExecutorRequest request ) } } + //${config_loc} for the origin dir of the configLocation, just like eclipsecs + // so we config such as `${config_loc}/checkstyle-suppressions.xml` + final String configLocation = request.getConfigLocation(); + final int idx = configLocation.lastIndexOf( '/' ); + final String configLoc; + if ( idx == -1 ) + { + configLoc = ""; + } + else + { + configLoc = configLocation.substring( 0, idx ); + } + p.setProperty( "config_loc", configLoc ); return p; }