You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2014/02/21 23:25:59 UTC
svn commit: r1570730 - in /maven/plugins/trunk/maven-checkstyle-plugin/src:
it/MCHECKSTYLE-169/ it/MCHECKSTYLE-169/build-tools/
it/MCHECKSTYLE-169/build-tools/src/ it/MCHECKSTYLE-169/build-tools/src/main/
it/MCHECKSTYLE-169/build-tools/src/main/resourc...
Author: dennisl
Date: Fri Feb 21 22:25:59 2014
New Revision: 1570730
URL: http://svn.apache.org/r1570730
Log:
[MCHECKSTYLE-169] Suppressions property is incorrectly set if suppressions file is on classpath
Submitted by: Sergei Ivanov
Reviewed by: Dennis Lundberg
Added:
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy (with props)
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml Fri Feb 21 22:25:59 2014
@@ -0,0 +1,13 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.company</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>build-tools</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0.0</version>
+</project>
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml Fri Feb 21 22:25:59 2014
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+<suppressions>
+ <suppress checks="LeftCurly" files="Suppressed\.java"/>
+ <suppress checks="EmptyBlock" files="Suppressed\.java"/>
+</suppressions>
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle-suppressions.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml Fri Feb 21 22:25:59 2014
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+<module name="Checker">
+ <module name="NewlineAtEndOfFile"/>
+ <module name="SuppressionFilter">
+ <property name="file" value="${checkstyle.suppressions.file}"/>
+ </module>
+ <module name="TreeWalker">
+ <property name="cacheFile" value="${checkstyle.cache.file}"/>
+ <module name="LeftCurly">
+ <property name="option" value="nl"/>
+ </module>
+ </module>
+</module>
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/build-tools/src/main/resources/com/company/build-tools/checkstyle.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties Fri Feb 21 22:25:59 2014
@@ -0,0 +1 @@
+invoker.goals=verify
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/invoker.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml Fri Feb 21 22:25:59 2014
@@ -0,0 +1,45 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.company</groupId>
+ <artifactId>parent</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0</version>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <checkstyleVersion>@pom.version@</checkstyleVersion>
+ </properties>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyleVersion}</version>
+ </plugin>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <modules>
+ <module>build-tools</module>
+ <module>test</module>
+ </modules>
+</project>
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml Fri Feb 21 22:25:59 2014
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.company</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>test</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0</version>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>build-tools</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>checkstyle-default</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <!-- Bound to 'verify' phase by default -->
+ <configuration>
+ <configLocation>
+ com/company/build-tools/checkstyle.xml
+ </configLocation>
+ <suppressionsLocation>
+ com/company/build-tools/checkstyle-suppressions.xml
+ </suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <logViolationsToConsole>true</logViolationsToConsole>
+ <failOnViolation>true</failOnViolation>
+ <failsOnError>true</failsOnError>
+ <violationSeverity>info</violationSeverity>
+ <includeTestSourceDirectory>false</includeTestSourceDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyleVersion}</version>
+ <configuration>
+ <configLocation>
+ com/company/build-tools/checkstyle.xml
+ </configLocation>
+ <suppressionsLocation>
+ com/company/build-tools/checkstyle-suppressions.xml
+ </suppressionsLocation>
+ <!--<enableRulesSummary>false</enableRulesSummary>-->
+ <includeTestSourceDirectory>false</includeTestSourceDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java Fri Feb 21 22:25:59 2014
@@ -0,0 +1,8 @@
+package com.company.example;
+
+public class Suppressed
+{
+
+ public void test() { // Wrong brace alignment
+ }
+}
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/Suppressed.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java Fri Feb 21 22:25:59 2014
@@ -0,0 +1,4 @@
+/**
+ * Nothing very important here, only a file for checkstyle rule PackageInfo.
+ */
+package com.company.example;
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/test/src/main/java/com/company/example/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy?rev=1570730&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy Fri Feb 21 22:25:59 2014
@@ -0,0 +1,27 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+assert new File(basedir, 'test/target/checkstyle-cachefile').exists();
+assert new File(basedir, 'test/target/checkstyle-checker.xml').exists();
+assert new File(basedir, 'test/target/checkstyle-suppressions.xml').exists();
+assert new File(basedir, 'test/target/checkstyle-header.txt').exists();
+assert new File(basedir, 'test/target/checkstyle-result.xml').exists();
+
+return true;
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/MCHECKSTYLE-169/verify.groovy
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java?rev=1570730&r1=1570729&r2=1570730&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java Fri Feb 21 22:25:59 2014
@@ -85,8 +85,11 @@ public class DefaultCheckstyleExecutor
{
getLogger().debug( "executeCheckstyle start headerLocation : " + request.getHeaderLocation() );
}
+
MavenProject project = request.getProject();
- locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
+
+ configureResourceLocator(request);
+
File[] files;
try
{
@@ -97,7 +100,8 @@ public class DefaultCheckstyleExecutor
throw new CheckstyleExecutorException( "Error getting files to process", e );
}
- FilterSet filterSet = getSuppressions( request );
+ final String suppressionsFilePath = getSuppressionsFilePath( request );
+ FilterSet filterSet = getSuppressionsFilterSet( suppressionsFilePath );
Checker checker = new Checker();
@@ -465,11 +469,11 @@ public class DefaultCheckstyleExecutor
}
if ( request.getSuppressionsFileExpression() != null )
{
- String suppresionFile = request.getSuppressionsLocation();
+ String suppressionsFilePath = getSuppressionsFilePath( request );
- if ( suppresionFile != null )
+ if ( suppressionsFilePath != null )
{
- p.setProperty( request.getSuppressionsFileExpression(), suppresionFile );
+ p.setProperty( request.getSuppressionsFileExpression(), suppressionsFilePath );
}
}
@@ -590,30 +594,48 @@ public class DefaultCheckstyleExecutor
}
}
- private FilterSet getSuppressions( CheckstyleExecutorRequest request )
+ private FilterSet getSuppressionsFilterSet( final String suppressionsFilePath )
throws CheckstyleExecutorException
{
- try
- {
- File suppressionsFile = locator.resolveLocation( request.getSuppressionsLocation(),
- "checkstyle-suppressions.xml" );
- if ( suppressionsFile == null )
- {
- return null;
- }
+ if ( suppressionsFilePath == null )
+ {
+ return null;
+ }
- return SuppressionsLoader.loadSuppressions( suppressionsFile.getAbsolutePath() );
+ try
+ {
+ return SuppressionsLoader.loadSuppressions( suppressionsFilePath );
}
catch ( CheckstyleException ce )
{
- throw new CheckstyleExecutorException( "failed to load suppressions location: "
- + request.getSuppressionsLocation(), ce );
+ throw new CheckstyleExecutorException( "Failed to load suppressions file from: "
+ + suppressionsFilePath, ce );
}
- catch ( IOException e )
+ }
+
+ private String getSuppressionsFilePath( final CheckstyleExecutorRequest request ) throws CheckstyleExecutorException
+ {
+ final String suppressionsLocation = request.getSuppressionsLocation();
+ if (StringUtils.isEmpty( suppressionsLocation ) )
+ {
+ return null;
+ }
+
+ try
{
- throw new CheckstyleExecutorException( "Failed to process supressions location: "
- + request.getSuppressionsLocation(), e );
+ File suppressionsFile = locator.getResourceAsFile( suppressionsLocation, "checkstyle-suppressions.xml" );
+ return suppressionsFile == null ? null : suppressionsFile.getAbsolutePath();
+ }
+ catch ( ResourceNotFoundException e )
+ {
+ throw new CheckstyleExecutorException( "Unable to find suppressions file at location: "
+ + suppressionsLocation, e );
+ }
+ catch ( FileResourceCreationException e )
+ {
+ throw new CheckstyleExecutorException( "Unable to process suppressions file location: "
+ + suppressionsLocation, e );
}
}
@@ -627,18 +649,6 @@ public class DefaultCheckstyleExecutor
getLogger().debug( "request.getConfigLocation() " + request.getConfigLocation() );
}
- MavenProject parent = request.getProject();
- while ( parent != null && parent.getFile() != null )
- {
- // MCHECKSTYLE-131 ( olamy ) I don't like this hack.
- // (dkulp) Me either. It really pollutes the location stuff
- // by allowing searches of stuff outside the current module.
- File dir = parent.getFile().getParentFile();
- locator.addSearchPath( FileResourceLoader.ID, dir.getAbsolutePath() );
- parent = parent.getParent();
- }
- locator.addSearchPath( "url", "" );
-
File configFile = locator.getResourceAsFile( request.getConfigLocation(), "checkstyle-checker.xml" );
if ( configFile == null )
{
@@ -647,16 +657,42 @@ public class DefaultCheckstyleExecutor
}
return configFile.getAbsolutePath();
}
- catch ( org.codehaus.plexus.resource.loader.ResourceNotFoundException e )
+ catch ( ResourceNotFoundException e )
{
- throw new CheckstyleExecutorException( "Unable to find configuration file at location "
+ throw new CheckstyleExecutorException( "Unable to find configuration file at location: "
+ request.getConfigLocation(), e );
}
catch ( FileResourceCreationException e )
{
- throw new CheckstyleExecutorException( "Unable to process configuration file location "
+ throw new CheckstyleExecutorException( "Unable to process configuration file at location: "
+ request.getConfigLocation(), e );
}
}
+
+ /**
+ * Configures search paths in the resource locator.
+ * This method should only be called once per execution.
+ *
+ * @param request executor request data.
+ */
+ private void configureResourceLocator( final CheckstyleExecutorRequest request )
+ {
+ final MavenProject project = request.getProject();
+ locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
+
+ // Recurse up the parent hierarchy and add project directories to the search roots
+ MavenProject parent = project;
+ while ( parent != null && parent.getFile() != null )
+ {
+ // MCHECKSTYLE-131 ( olamy ) I don't like this hack.
+ // (dkulp) Me either. It really pollutes the location stuff
+ // by allowing searches of stuff outside the current module.
+ File dir = parent.getFile().getParentFile();
+ locator.addSearchPath( FileResourceLoader.ID, dir.getAbsolutePath() );
+ parent = parent.getParent();
+ }
+
+ locator.addSearchPath( "url", "" );
+ }
}