昨天看到阿里的 <阿里巴巴Java开发手册> 出Eclipse/IDEA的插件了,立即决定今天到公司就把这个集成到项目用.以方便规范代码.
废话不多说:
P3C交友地址–>戳<–
项目还需要Gradle3.x如果没有的话.可以这里下载.
我这里以IDEA为例,Eclipse应该是相同的.
我们项目拿到,环境变量准备的好就可以开始了.
先来到
cd *\p3c\idea-plugin\p3c-idea\
gradle clean buildPlugin
gradle runIde
之后发现问题. 默认的IDEA版本是14.1.7
所以我们需要
gradle runIde -Pidea_version=<你的版本>
例如我这里是
gradle runIde -Pidea_version=2016.1
之后遇到问题
$ gradle runIdea -Pidea_version=2016.1
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use –statu s for details
FAILURE: Build failed with an exception.
* Where:
Build file ‘*\p3c\idea-plugin\p3c-common\build.gradle’ line: 49
* What went wrong:
A problem occurred evaluating project ‘:p3c-common’.
Could not get unknown property ‘ossrhUsername’ for object of type org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.
然后我们打开
p3c-common\build.gradle
来到49行
repository(url: https://oss.sonatype.org/service/local/staging/deploy/maven2/“) {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
发现这里在上传.我们没必要的啊.所以就把 uploadArchives 这一整段注释掉吧
(就算可以上传也没必要塞一堆东西到他们服务器上徒添麻烦.对吧!?)
然后重新跑一次
ok 没有报错了.应该是成功了.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=250m; support was removed in 8.0
‘runIdea’ task is deprecated and will be removed in 0.3.0. Use ‘runIde’ task instead
BUILD SUCCESSFUL
Total time: 18 mins 12.001 secs
成功了,18分钟.可能是我的电脑比较垃圾的原因.
然后打开你IDEA,
Settings >> Plugins >> Browse repositories…
Browse repositories…
-> alibaba
安装,大功告成.