Skip to content

How to generate Checkstyle report for Google Guava project

Roman Ivanov edited this page Jan 29, 2017 · 21 revisions
  1. get sources:
git clone https://github.com/google/guava.git
  1. change pom.xml to add Checkstyle plugin config with overridden version of checkstyle library
    <pluginManagement>
      <plugins>
.......
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.17</version>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>6.12</version>
            </dependency>
          </dependencies>
		  <configuration>
		    <configLocation>/google_checks.xml</configLocation>
		    <enableFilesSummary>false</enableFilesSummary>
		  </configuration>
        </plugin>
    ........
    </pluginManagement>
   </plugins>

if config already there , update version: CS_VERSION='7.5' && xmlstarlet ed --ps -N pom=http://maven.apache.org/POM/4.0.0 -u "/pom:project/pom:build/pom:pluginManagement/pom:plugins/pom:plugin[pom:artifactId='maven-checkstyle-plugin']/pom:dependencies/pom:dependency[pom:artifactId='checkstyle']/pom:version" -v "$CS_VERSION" pom.xml > new_pom.xml && mv new_pom.xml pom.xml

Run:

mvn clean jxr:aggregate checkstyle:checkstyle-aggregate
  1. To make report looks good, use css :
mkdir target/site/css
wget http://checkstyle.sourceforge.net/reports/google-style/guava/css/maven-base.css -O target/site/css/maven-base.css
wget http://checkstyle.sourceforge.net/reports/google-style/guava/css/maven-theme.css  -O target/site/css/maven-theme.css
  1. Deploy to http://checkstyle.sourceforge.net/reports/google-style/guava/
CS_VERSION=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -m "/pom:project/pom:build/pom:pluginManagement/pom:plugins/pom:plugin[pom:artifactId='maven-checkstyle-plugin']/pom:dependencies/pom:dependency[pom:artifactId='checkstyle']/pom:version" -v . pom.xml)
echo "VERSION:"$CS_VERSION

tar cfz guava-report-$CS_VERSION.tar.gz target/site/

echo "exit" | ssh -t romanivanov,checkstyle@shell.sourceforge.net create

scp guava-report-$CS_VERSION.tar.gz romanivanov,checkstyle@shell.sourceforge.net:/home/project-web/checkstyle

ssh romanivanov,checkstyle@shell.sourceforge.net << EOF
cd /home/project-web/checkstyle
tar -xf guava-report-$CS_VERSION.tar.gz 
rm -rf reports/google-style/guava/*
mv target/site/* reports/google-style/guava/
cd reports/google-style/guava/
ln -s checkstyle-aggregate.html index.html
cd ../../../
rm -rf target/

EOF
  1. Recheck that content is updated http://checkstyle.sourceforge.net/reports/google-style/guava/
Clone this wiki locally