@@ -61,7 +61,7 @@ public class ScalastyleViolationCheckMojo extends AbstractMojo {
6161
6262 /**
6363 * <p>
64- * Specifies the location of the scalstyle XML configuration file to use .
64+ * Specifies the location of the scalstyle XML configuration file for source directory .
6565 * </p>
6666 * <p>
6767 * Potential values are a filesystem path, a URL, or a classpath resource.
@@ -77,6 +77,24 @@ public class ScalastyleViolationCheckMojo extends AbstractMojo {
7777 @ Parameter (property = "scalastyle.config.location" , required = true , defaultValue = "default_config.xml" )
7878 private String configLocation ;
7979
80+ /**
81+ * <p>
82+ * Specifies the location of the scalstyle XML configuration file for test source directory.
83+ * </p>
84+ * <p>
85+ * Potential values are a filesystem path, a URL, or a classpath resource.
86+ * </p>
87+ * <p>
88+ * This parameter is resolved as file, classpath resource then URL.
89+ * </p>
90+ * <p>
91+ * Source directory config location is used if non is specified in configuration
92+ * </p>
93+ * <p/>
94+ */
95+ @ Parameter (property = "scalastyle.test.config.location" )
96+ private String testConfigLocation ;
97+
8098 /**
8199 * Specifies the path and filename to save the Scalastyle output.
82100 */
@@ -208,12 +226,21 @@ public void execute() throws MojoFailureException, MojoExecutionException {
208226
209227 private void performCheck () throws MojoFailureException , MojoExecutionException {
210228 try {
211- ScalastyleConfiguration configuration = ScalastyleConfiguration .readFromXml (getConfigFile (configLocation ));
229+ ScalastyleConfiguration srcConfiguration = ScalastyleConfiguration .readFromXml (getConfigFile (configLocation ));
230+ ScalastyleConfiguration testConfiguration = srcConfiguration ;
231+
232+ if (testConfigLocation != null ) {
233+ testConfiguration = ScalastyleConfiguration .readFromXml (getConfigFile (testConfigLocation ));
234+ }
235+
212236 long start = now ();
213237 final scala .Option <ClassLoader > none = scala .Option$ .MODULE$ .apply (null );
214238 ScalastyleChecker <FileSpec > sc = new ScalastyleChecker <FileSpec >(none );
215239
216- List <Message <FileSpec >> messages = sc .checkFilesAsJava (configuration , getFilesToProcess ());
240+ List <Message <FileSpec >> messages = new ArrayList <Message <FileSpec >>();
241+ messages .addAll (sc .checkFilesAsJava (srcConfiguration , getSrcFilesToProcess ()));
242+ messages .addAll (sc .checkFilesAsJava (testConfiguration , getTestFilesToProcess ()));
243+
217244
218245 Config config = ConfigFactory .load (sc .getClass ().getClassLoader ());
219246 OutputResult outputResult = new TextOutput <FileSpec >(config , verbose , quiet ).output (messages );
@@ -307,13 +334,12 @@ private URLClassLoader getClassLoaderWithProjectResources() throws MojoFailureEx
307334 return new URLClassLoader (urls .toArray (new URL [urls .size ()]), Thread .currentThread ().getContextClassLoader ());
308335 }
309336
310- private List <FileSpec > getFilesToProcess () {
311- List <FileSpec > all = new ArrayList <FileSpec >();
312-
313- all .addAll (getFiles ("sourceDirectory" , sourceDirectoriesAsList (), inputEncoding ));
314- all .addAll (getFiles ("testSourceDirectory" , testSourceDirectoriesAsList (), inputEncoding ));
337+ private List <FileSpec > getSrcFilesToProcess () {
338+ return getFiles ("sourceDirectory" , sourceDirectoriesAsList (), inputEncoding );
339+ }
315340
316- return all ;
341+ private List <FileSpec > getTestFilesToProcess () {
342+ return getFiles ("testSourceDirectory" , testSourceDirectoriesAsList (), inputEncoding );
317343 }
318344
319345 private List <FileSpec > getFiles (String name , List <File > dirs , String encoding ) {
0 commit comments