标签:
序目
在父项目的pom.xml上加入如下配置
<build> <plugins> ...... <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.5.201505241946</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>default-prepare-agent-integration</id> <goals> <goal>prepare-agent-integration</goal> </goals> </execution> <execution> <id>default-report</id> <goals> <goal>report</goal> </goals> </execution> <execution> <id>default-report-integration</id> <goals> <goal>report-integration</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> <runOrder>random</runOrder> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.16</version> <executions> <execution> <id>default-integration-test</id> <goals> <goal>integration-test</goal> </goals> </execution> </executions> </plugin> ...... </plugins> </build>
若需要eclipse 的可显环境下可以看到覆盖情况,可以在eclipse安装个插件:EclEmma
参考:https://www.ibm.com/developerworks/cn/java/j-lo-jacoco/
参考: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins
安装完成后,配置文件在:/etc/sysconfig/jenkins
启动
service jenkins start
官网:http://www.sonarqube.org/
参考:http://sonar-pkg.sourceforge.net/
sudo wget -O /etc/yum.repos.d/sonar.repo http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo yum install sonar
安装默认路径在:/opt/sonar/
配置文件在:/opt/sonar/conf/sonar.properties
(本人用的是mysql, mysql的安装也不多说了 ,因此修改:sonar.properties )
sonar.jdbc.username=sonar sonar.jdbc.password=sonar sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar9?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
启动
service sonar start
Sonar服务是启动了,访问http://192.168.0.240:9000,还需要maven编译配置的支持,在~/.m2/下创建setting.xml内容如下:
<settings> <pluginGroups> <pluginGroup>org.sonarsource.scanner.maven</pluginGroup> </pluginGroups> <profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!-- Optional URL to server. Default value is http://localhost:9000 --> <sonar.host.url>http://192.168.0.240:9000</sonar.host.url> <!-- sonar mysql database : change to your mysql info -->
<sonar.jdbc.url>jdbc:mysql://192.168.0.240:3306/sonar9</sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> </properties> </profile> </profiles> </settings>
maven 编译时如下
mvn clean install sonar:sonar
此时便会进行源代质理分析了并提交报告到sonar服务上去了。可以访问http://192.168.0.240:9000看报表了。
Nexus用来管理开发的底层核心公用库、代理被GFW墙了的一些公开库(比如googlecode的)非常有效。
安装参考:http://blog.csdn.net/shenshen123jun/article/details/9084293
项目的pom.xml配置如下:
在project节点下加入distributionManagement(用于编译打包上传到maven私有仓库),下面地址为参考,勿直直接使用:)
<distributionManagement> <repository> <id>releases</id> <url>http://192.168.0.240:8060/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://192.168.0.240:8060/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement>
maven 打包上传命令:
mvn deploy
上一步其实还是会打包上传不成功,因为没有设置私有仓库的身份授权,私有仓库身份配置参考:http://blog.csdn.net/hualom/article/details/8070320
私有身份的账号密码需要配置到开发机器的~/.m2/settings.xml的文件settings节点下(~在linux/unix下表地当前用户的根目录,windows是C:\users\{当前用户名}):如下
<servers> <server> <id>snapshots</id> <username>sing</username> <password>password</password> </server> <server> <id>releases</id> <username>sing</username> <password>password</password> </server> </servers>
留意上面的颜色对应,再执行mvn deploy应该就没问题了
还在不间断更新中...
标签:
原文地址:http://www.cnblogs.com/singzhong/p/5129412.html