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 2013/01/26 20:04:16 UTC
svn commit: r1438948 - in /maven/plugins/trunk/maven-checkstyle-plugin/src:
it/check-tests-only/ it/check-tests-only/src/ it/check-tests-only/src/test/
it/check-tests-only/src/test/java/
it/check-tests-only/src/test/java/sample/ it/multi-modules-aggreg...
Author: dennisl
Date: Sat Jan 26 19:04:15 2013
New Revision: 1438948
URL: http://svn.apache.org/viewvc?rev=1438948&view=rev
Log:
[MCHECKSTYLE-185] Empty checkstyle-results.xml in a tests-only project
Submitted by: Peter Janes
Reviewed by: Dennis Lundberg
[MCHECKSTYLE-144] If 'src/main/java' does not exist in a project then checkstyle skips the other source folders of the project
The IT that was supposed to catch this multi-modules-aggregate/child-b was incorrectly set up. It had the test class in src/main/java which made the IT pass even though it should have failed.
Added:
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/invoker.properties (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/pom.xml (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/
maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/Example.java (with props)
maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/child-b/src/test/
- copied from r1438926, maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/child-b/src/main/
Removed:
maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/child-b/src/main/
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/pom.xml
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/check-tests-only/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/invoker.properties?rev=1438948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/invoker.properties (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/invoker.properties Sat Jan 26 19:04:15 2013
@@ -0,0 +1,2 @@
+invoker.goals=checkstyle:check
+invoker.buildResult=failure
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/invoker.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/pom.xml?rev=1438948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/pom.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/pom.xml Sat Jan 26 19:04:15 2013
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<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>sample</groupId>
+ <artifactId>sample</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Example project</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <includes>**/*.*</includes>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <consoleOutput>true</consoleOutput>
+ <logViolationsToConsole>true</logViolationsToConsole>
+ <failOnViolation>true</failOnViolation>
+ <failsOnError>true</failsOnError>
+ <violationSeverity>info</violationSeverity>
+ <maxAllowedViolations>4</maxAllowedViolations>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/Example.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/Example.java?rev=1438948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/Example.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/Example.java Sat Jan 26 19:04:15 2013
@@ -0,0 +1,24 @@
+package sample;
+
+/*
+ * 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.
+ */
+
+public class Example {
+ public void UseBadStyle() {}
+}
Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/it/check-tests-only/src/test/java/sample/Example.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/pom.xml?rev=1438948&r1=1438947&r2=1438948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/multi-modules-aggregate/pom.xml Sat Jan 26 19:04:15 2013
@@ -51,7 +51,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>@pom.version@</version>
- </plugin>
+ </plugin>
</plugins>
</build>
@@ -64,6 +64,7 @@
<version>@pom.version@</version>
<configuration>
<configLocation>config/maven_checks.xml</configLocation>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<inherited>false</inherited>
<reportSets>
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=1438948&r1=1438947&r2=1438948&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 Sat Jan 26 19:04:15 2013
@@ -189,7 +189,7 @@ public class DefaultCheckstyleExecutor
for ( MavenProject childProject : request.getReactorProjects() )
{
addSourceDirectory( sinkListener, new File( childProject.getBuild().getSourceDirectory() ),
- new File( childProject.getBuild().getSourceDirectory() ), childProject.getResources(), request);
+ new File( childProject.getBuild().getTestSourceDirectory() ), childProject.getResources(), request);
}
}
else
@@ -350,7 +350,7 @@ public class DefaultCheckstyleExecutor
{
outputDirectories.add( project.getBuild().getOutputDirectory() );
- if ( request.isIncludeTestSourceDirectory() && ( sourceDirectory != null )
+ if ( request.isIncludeTestSourceDirectory() && ( testSourceDirectory != null )
&& ( testSourceDirectory.exists() ) && ( testSourceDirectory.isDirectory() ) )
{
classPathStrings.addAll( project.getTestClasspathElements() );
@@ -502,34 +502,39 @@ public class DefaultCheckstyleExecutor
{
for ( MavenProject project : request.getReactorProjects() )
{
- addFilesToProcess( request, excludesStr, new File( project.getBuild().getSourceDirectory() ), project.getResources(), files);
+ addFilesToProcess( request, excludesStr, new File( project.getBuild().getSourceDirectory() ), project.getResources(), new File( project.getBuild().getTestSourceDirectory() ), files);
}
}
else
{
- addFilesToProcess( request, excludesStr, sourceDirectory, request.getResources(), files);
+ addFilesToProcess( request, excludesStr, sourceDirectory, request.getResources(), request.getTestSourceDirectory(), files);
}
+ getLogger().debug( "Added " + files.size() + " files to process." );
+
return (File[]) files.toArray( EMPTY_FILE_ARRAY );
}
private void addFilesToProcess( CheckstyleExecutorRequest request, StringBuilder excludesStr, File sourceDirectory,
- List<Resource> resources, List<File> files)
+ List<Resource> resources, File testSourceDirectory, List<File> files )
throws IOException
{
- if ( sourceDirectory == null || !sourceDirectory.exists() )
+ if ( sourceDirectory != null && sourceDirectory.exists() )
{
- return;
+ final List sourceFiles = FileUtils.getFiles( sourceDirectory,
+ request.getIncludes(),
+ excludesStr.toString() );
+ files.addAll( sourceFiles );
+ getLogger().debug( "Added " + sourceFiles.size() + " source files found in '" + sourceDirectory.getAbsolutePath() + "'." );
}
- files.addAll(
- FileUtils.getFiles( sourceDirectory, request.getIncludes(), excludesStr.toString() ) );
- File testSourceDirectory = request.getTestSourceDirectory();
if ( request.isIncludeTestSourceDirectory() && ( testSourceDirectory != null )
&& ( testSourceDirectory.exists() ) && ( testSourceDirectory.isDirectory() ) )
{
- files.addAll( FileUtils.getFiles( testSourceDirectory, request.getIncludes(),
- excludesStr.toString() ) );
+ final List testSourceFiles = FileUtils.getFiles( testSourceDirectory, request.getIncludes(),
+ excludesStr.toString() );
+ files.addAll( testSourceFiles );
+ getLogger().debug( "Added " + testSourceFiles.size() + " test source files found in '" + testSourceDirectory.getAbsolutePath() + "'." );
}
// @todo Should we add a check to see if resources should be included or not, similar to request.isIncludeTestSourceDirectory()?