Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2019-02-05 08:54:09 +00:00
parent 31ede13df3
commit 92fcee2f4b
7 changed files with 239 additions and 28 deletions

View File

@@ -0,0 +1,54 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>2.&nbsp;Checkstyle</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="multi_spring-cloud-build.html" title="Spring Cloud Build"><link rel="up" href="multi_spring-cloud-build.html" title="Spring Cloud Build"><link rel="prev" href="multi__building_and_deploying.html" title="1.&nbsp;Building and Deploying"><link rel="next" href="multi__contributing.html" title="3.&nbsp;Contributing"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.&nbsp;Checkstyle</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_and_deploying.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__contributing.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_checkstyle" href="#_checkstyle"></a>2.&nbsp;Checkstyle</h1></div></div></div><p>Spring Cloud Build comes with a set of checkstyle rules. You can find them in the <code class="literal">spring-cloud-build-tools</code> module. The most notable files under the module are:</p><p><b>spring-cloud-build-tools/.&nbsp;</b>
</p><pre class="screen">&#9492;&#9472;&#9472; src
&nbsp;&nbsp; &#9500;&#9472;&#9472; checkstyle
&nbsp;&nbsp; &#9474;&nbsp;&nbsp; &#9492;&#9472;&#9472; checkstyle-suppressions.xml <a name="CO1-1" href="#CO1-1"></a><span><img src="images/callouts/1.png" alt="1" border="0"></span>
&nbsp;&nbsp; &#9492;&#9472;&#9472; main
&nbsp;&nbsp; &#9492;&#9472;&#9472; resources
&nbsp;&nbsp; &#9500;&#9472;&#9472; checkstyle-header.txt <a name="CO1-2" href="#CO1-2"></a><span><img src="images/callouts/2.png" alt="2" border="0"></span>
&nbsp;&nbsp; &#9500;&#9472;&#9472; checkstyle.xml <a name="CO1-3" href="#CO1-3"></a><span><img src="images/callouts/3.png" alt="3" border="0"></span>
&nbsp;&nbsp; &#9492;&#9472;&#9472; intellij
&nbsp;&nbsp; &nbsp;&nbsp; &#9500;&#9472;&#9472; Intellij_Project_Defaults.xml <a name="CO1-4" href="#CO1-4"></a><span><img src="images/callouts/4.png" alt="4" border="0"></span>
&nbsp;&nbsp; &nbsp;&nbsp; &#9492;&#9472;&#9472; Intellij_Spring_Boot_Java_Conventions.xml <a name="CO1-5" href="#CO1-5"></a><span><img src="images/callouts/5.png" alt="5" border="0"></span></pre><p>
</p><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-3"><span><img src="images/callouts/3.png" alt="3" border="0"></span></a> </p></td><td valign="top" align="left"><p>Default Checkstyle rules</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-2"><span><img src="images/callouts/2.png" alt="2" border="0"></span></a> </p></td><td valign="top" align="left"><p>File header setup</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-1"><span><img src="images/callouts/1.png" alt="1" border="0"></span></a> </p></td><td valign="top" align="left"><p>Default suppression rules</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-4"><span><img src="images/callouts/4.png" alt="4" border="0"></span></a> </p></td><td valign="top" align="left"><p>Project defaults for Intellij that apply most of Checkstyle rules</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO1-5"><span><img src="images/callouts/5.png" alt="5" border="0"></span></a> </p></td><td valign="top" align="left"><p>Project style conventions for Intellij that apply most of Checkstyle rules</p></td></tr></table></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_checkstyle_configuration" href="#_checkstyle_configuration"></a>2.1&nbsp;Checkstyle configuration</h2></div></div></div><p>Checkstyle rules are <span class="strong"><strong>disabled by deafult</strong></span>. To add checkstyle to your project just define the following properties and plugins.</p><p><b>pom.xml.&nbsp;</b>
</p><pre class="screen">&lt;properties&gt;
&lt;maven-checkstyle-plugin.failsOnError&gt;true&lt;/maven-checkstyle-plugin.failsOnError&gt; <a name="CO2-1" href="#CO2-1"></a><span><img src="images/callouts/1.png" alt="1" border="0"></span>
&lt;maven-checkstyle-plugin.failsOnViolation&gt;true
&lt;/maven-checkstyle-plugin.failsOnViolation&gt; <a name="CO2-2" href="#CO2-2"></a><span><img src="images/callouts/2.png" alt="2" border="0"></span>
&lt;maven-checkstyle-plugin.includeTestSourceDirectory&gt;true
&lt;/maven-checkstyle-plugin.includeTestSourceDirectory&gt; <a name="CO2-3" href="#CO2-3"></a><span><img src="images/callouts/3.png" alt="3" border="0"></span>
&lt;/properties&gt;
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt; <a name="CO2-4" href="#CO2-4"></a><span><img src="images/callouts/4.png" alt="4" border="0"></span>
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-checkstyle-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;plugin&gt; <a name="CO2-5" href="#CO2-5"></a><span><img src="images/callouts/5.png" alt="5" border="0"></span>
&lt;groupId&gt;io.spring.javaformat&lt;/groupId&gt;
&lt;artifactId&gt;spring-javaformat-maven-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
&lt;reporting&gt;
&lt;plugins&gt;
&lt;plugin&gt; <a name="CO2-6" href="#CO2-6"></a><span><img src="images/callouts/6.png" alt="6" border="0"></span>
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-checkstyle-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/reporting&gt;
&lt;/build&gt;</pre><p>
</p><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><a href="#CO2-1"><span><img src="images/callouts/1.png" alt="1" border="0"></span></a> </p></td><td valign="top" align="left"><p>Fails the build upon Checkstyle errors</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO2-2"><span><img src="images/callouts/2.png" alt="2" border="0"></span></a> </p></td><td valign="top" align="left"><p>Fails the build upon Checkstyle violations</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO2-3"><span><img src="images/callouts/3.png" alt="3" border="0"></span></a> </p></td><td valign="top" align="left"><p>Checkstyle analyzes also the test sources</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO2-4"><span><img src="images/callouts/4.png" alt="4" border="0"></span></a> <a href="#CO2-6"><span><img src="images/callouts/6.png" alt="6" border="0"></span></a> </p></td><td valign="top" align="left"><p>Add checkstyle plugin to your build and reporting phases</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#CO2-5"><span><img src="images/callouts/5.png" alt="5" border="0"></span></a> </p></td><td valign="top" align="left"><p>Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules</p></td></tr></table></div><p>If you need to suppress some rules (e.g. line length needs to be longer), then it&#8217;s enough for you to define a file under <code class="literal">${project.root}/src/checkstyle/checkstyle-suppressions.xml</code> with your suppressions. Example:</p><p><b>projectRoot/src/checkstyle/checkstyle-suppresions.xml.&nbsp;</b>
</p><pre class="screen">&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"&gt;
&lt;suppressions&gt;
&lt;suppress files=".*ConfigServerApplication\.java" checks="HideUtilityClassConstructor"/&gt;
&lt;suppress files=".*ConfigClientWatch\.java" checks="LineLengthCheck"/&gt;
&lt;/suppressions&gt;</pre><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__building_and_deploying.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__contributing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.&nbsp;Building and Deploying&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-build.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;3.&nbsp;Contributing</td></tr></table></div></body></html>