Discussion:
How can the checkstyle plugin be configured to fail the build?
Andrew Moores
2007-06-21 14:41:12 UTC
Permalink
Hello

I want to make my build fail if there are any checkstyle errors in my code. I have added the following to my pom:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>

When I execute mvn checkstyle:check my build fails when I have a checkstyle error.

When I execute mvn install the build does not fail. Reading the plugin pages I expected my build to fail for the intall goal as well, what else do I need to add to the POM to make the build fail?

I am running Maven 2.0.5.

Thanks
Andrew
Guillaume Boucherie
2007-06-21 15:39:23 UTC
Permalink
try something like this.

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins<groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

by default the check goal is link to verify phase

CletteBou
Post by Andrew Moores
Hello
I want to make my build fail if there are any checkstyle errors in my
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
When I execute mvn checkstyle:check my build fails when I have a checkstyle error.
When I execute mvn install the build does not fail. Reading the plugin
pages I expected my build to fail for the intall goal as well, what else do
I need to add to the POM to make the build fail?
I am running Maven 2.0.5.
Thanks
Andrew
nitinaggarwal
2007-06-22 03:35:34 UTC
Permalink
Hi

I am facing a similiar issue in my project.
But additionally i want the a checkstyle file FC-CheckStyle.xml
customized to my project be invoked in order to find out if there are
checkstyle errors .

how do i do that?

Additionally can some one tell me how can i refer to this file as this is
located in my root directory
and i want to invoke the file in a directory fc
to be more clear i will provide a brief about my project.

FC-4.0 Source-->application-->fc (my pom is here)
-->er (and here)

-->portal
--> components-->pom
--> pom


Can some one suggest me how to perform this checkstyle validation.
would you suggest me the validation to be at the top level or at every level
as i am having a multli project build.

but the issue with this approach is that all the developers would have to
build the entire project rather than a sub project for finding out check
style errors.

any comments how we can extend something from the top level pom.

Nitin
Post by Guillaume Boucherie
try something like this.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins<groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
by default the check goal is link to verify phase
CletteBou
Post by Andrew Moores
Hello
I want to make my build fail if there are any checkstyle errors in my
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
When I execute mvn checkstyle:check my build fails when I have a checkstyle error.
When I execute mvn install the build does not fail. Reading the plugin
pages I expected my build to fail for the intall goal as well, what else do
I need to add to the POM to make the build fail?
I am running Maven 2.0.5.
Thanks
Andrew
--
View this message in context: http://www.nabble.com/How-can-the-checkstyle-plugin-be-configured-to-fail-the-build--tf3959401s177.html#a11245727
Sent from the Maven - Users mailing list archive at Nabble.com.
Wayne Fay
2007-06-22 15:59:34 UTC
Permalink
Here's two "best practice" approaches generally suggested to solve
this problem on this list:

1. Put the checkstyle.xml file in a location that can be accessed
using HTTP. This may be a particular file on a Webserver or just
reference a file in a Subversion repository.

2. Create a new Maven package to contain these kinds of configuration
files etc across your organization/projects. Package the
checkstyle.xml file in a Jar, deploy it to your Maven repo, and then
add a dependency to this new config jar to the checkstyle plugin
declaration.

Wayne
Post by nitinaggarwal
Hi
I am facing a similiar issue in my project.
But additionally i want the a checkstyle file FC-CheckStyle.xml
customized to my project be invoked in order to find out if there are
checkstyle errors .
how do i do that?
Additionally can some one tell me how can i refer to this file as this is
located in my root directory
and i want to invoke the file in a directory fc
to be more clear i will provide a brief about my project.
FC-4.0 Source-->application-->fc (my pom is here)
-->er (and here)
-->portal
--> components-->pom
--> pom
Can some one suggest me how to perform this checkstyle validation.
would you suggest me the validation to be at the top level or at every level
as i am having a multli project build.
but the issue with this approach is that all the developers would have to
build the entire project rather than a sub project for finding out check
style errors.
any comments how we can extend something from the top level pom.
Nitin
Post by Guillaume Boucherie
try something like this.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins<groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
by default the check goal is link to verify phase
CletteBou
Post by Andrew Moores
Hello
I want to make my build fail if there are any checkstyle errors in my
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
When I execute mvn checkstyle:check my build fails when I have a checkstyle error.
When I execute mvn install the build does not fail. Reading the plugin
pages I expected my build to fail for the intall goal as well, what else do
I need to add to the POM to make the build fail?
I am running Maven 2.0.5.
Thanks
Andrew
--
View this message in context: http://www.nabble.com/How-can-the-checkstyle-plugin-be-configured-to-fail-the-build--tf3959401s177.html#a11245727
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
teja007
2009-02-10 15:38:49 UTC
Permalink
Post by nitinaggarwal
Hi
I am facing a similiar issue in my project.
But additionally i want the a checkstyle file FC-CheckStyle.xml
customized to my project be invoked in order to find out if there are
checkstyle errors .
how do i do that?
Additionally can some one tell me how can i refer to this file as this is
located in my root directory
and i want to invoke the file in a directory fc
to be more clear i will provide a brief about my project.
FC-4.0 Source-->application-->fc (my pom is here)
-->er (and here)
-->portal
--> components-->pom
--> pom
Can some one suggest me how to perform this checkstyle validation.
would you suggest me the validation to be at the top level or at every
level as i am having a multli project build.
but the issue with this approach is that all the developers would have to
build the entire project rather than a sub project for finding out check
style errors.
any comments how we can extend something from the top level pom.
Nitin
Post by Guillaume Boucherie
try something like this.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins<groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
by default the check goal is link to verify phase
CletteBou
Post by Andrew Moores
Hello
I want to make my build fail if there are any checkstyle errors in my
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
When I execute mvn checkstyle:check my build fails when I have a checkstyle error.
When I execute mvn install the build does not fail. Reading the plugin
pages I expected my build to fail for the intall goal as well, what else do
I need to add to the POM to make the build fail?
I am running Maven 2.0.5.
Thanks
Andrew
This would be more apt:
<build>

…..

<plugins>



<plugin>


<groupId>org.apache.maven.plugins</groupId>


<artifactId>maven-checkstyle-plugin</artifactId>

<executions>

<execution>


<phase>install</phase>

<goals>


<goal>checkstyle</goal> <!—checkstyle : generates the reports in a site
folder in HTML format-->


<!— check: can be used if only the errors have to be checked-->

</goals>

</execution>

</executions>

<configuration>


<failOnViolation>true</failOnViolation> <!—will fail the build if
checkstyle violated -->


<enableRulesSummary>false</enableRulesSummary>


<configLocation>checkstyle-checker1.xml</configLocation> <!—Customized
checker xml located in the location of the pom.xml-->

</configuration>

</plugin>

</plugins>

</build>




If checkstyle doesn't work then use check
--
View this message in context: http://www.nabble.com/How-can-the-checkstyle-plugin-be-configured-to-fail-the-build--tp11235269p21936262.html
Sent from the Maven - Users mailing list archive at Nabble.com.
Loading...