如何强制code样式格式作为构建的一部分? [英] How to force code style formatting as part of the build?

查看:146
本文介绍了如何强制code样式格式作为构建的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有(使用ANT)的方式,能够自动地重新格式化code键遵循一定的约定?

Is there a way (using ANT), it is possible to automatically reformat code to follow certain conventions?

我有几个开发上的程序工作,想保证code格式成为横跨在构建时所有类一致,提交之前

I have several developers working on a program and would like to guarantee that code formatting becomes consistent across all classes at build time, prior to commit

推荐答案

要做到这一点,最好的方法pre-承诺是使用pre-commit钩子源代码控制服务器上。这样,您就可以强制执行,没有code使得它变成分支不符合code标准。

The best way to do it pre-commit is to use a pre-commit hook on your source control server. This way you can enforce that no code makes it into the branch without conforming to code standards.

http://checkstyle.sourceforge.net/ 可以作为一个Ant任务或pre-commit钩子。所以,你可以在源代码控制服务器上,为每个开发者的Ant任务运行此。但是没有什么是忽略它停止你的开发者。

http://checkstyle.sourceforge.net/ can be used as an ANT task or pre-commit hook. So you can run this on the source control server or as an ANT task for each developer. However there's nothing to stop your developer from ignoring it.

您可以通过做让开发人员做他们的工作分支机构和使用一个集成分支这个后提交。您可以添加code样式检查像詹金斯 http://jenkins-ci.org/ <一个连续的集成服务器/ A>,并使用像 http://wiki.hudson-ci.org插件/显示/ HUDSON /声纳+插件报告如果最新提交到集成BRACH不辜负标准。一旦集成分支通过了所有的测试,你将它添加到你的主分支。

You can do this post-commit by having developers do all their work in branches and use an integration branch. You can add a code style checker to a continuos integration server like Jenkins http://jenkins-ci.org/ and use a plugin like http://wiki.hudson-ci.org/display/HUDSON/Sonar+plugin to report if the latest commit to the integration brach doesn't live up to standards. Once the integration branch passes all tests you add it to your main branch.

这篇关于如何强制code样式格式作为构建的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆