然后,就给项目命名和选择项目类型:
点击[OK]之后,就到了如下页面:
save完之后,项目就新建好了。
接下来讲讲配置checkstyle,要支持checkstyle就要在pom文件里添加checkstyle的支持。
先看一下pom.xml
<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>css</groupId> <artifactId>hw</artifactId> <version>1.0</version> <packaging>jar</packaging> <name>hw</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.16</version> <configuration> <consoleOutput>false</consoleOutput> <outputFileFormat>xml</outputFileFormat> <configLocation>fcm-cs-check.xml</configLocation> <linkXRef>false</linkXRef> </configuration> <dependencies> <dependency> <groupId>com.puppycrawl.tools</groupId> <artifactId>checkstyle</artifactId> <version>6.9</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
这样子就可以支持mvn checkstyle:checkstyle命令了
指定checkstyle 文件的位置有两种方式。
第一种就是刚刚在上面的pom.xml中提到的。
<configLocation>fcm-cs-check.xml</configLocation>
必须把文件的配置放在<build>元素里面。参考阅读: http://stackoverflow.com/questions/8975096/maven-checkstyle-configlocation-ignored
并且fcm-cs-check.xml 必须要跟pom.xml是同一层目录的。
如下图:
这样子就可以report出checkstyle了。
第二种方法是:
在mvn 命令中指定checkstyle.config.location,参考: https://dustplanet.de/howto-use-your-own-checkstyle-rules-in-your-jenkinsmaven-job/
两种方式只要支持一种就可以了。
贴最后一张成果图:
--EOF--