构建蚂蚁(Java)项目的ZC构建方案
collective.recipe.ant的Python项目详细描述
What is collective.recipe.ant ?
collective.recipie.ant执行蚂蚁构建。它假设java和ant 安装在系统上。
支持的选项:
- 蚂蚁
- 指定ant应用程序的位置。此选项是可选的。 如果未使用,则在默认路径中查找应用程序。
- 蚂蚁回家
- 如果ant不在默认的PATH-环境变量中 您可以在此处指定位置。
- 蚂蚁选项
- 指定应使用的选项ant。你可以改变 例如,使用-buildfile选项生成文件。
- 类路径
- 为包含java库提供一些额外的位置。 即junit,…
可以通过增加buildout的详细程度来调试ant输出。
Simple example
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = javaproject ... ... [javaproject] ... recipe = collective.recipe.ant ... """)
好,让我们运行构建:
>>> print system(buildout) Installing javaproject. Build failed While: Installing javaproject. Error: System error: Buildfile: build.xml does not exist! <BLANKLINE> <BLANKLINE>
这次失败了。我们没有指定任何选项。让我们这样做吧。
>>> from os.path import join, dirname >>> buildfile = join(dirname(__file__), 'testdata', 'echo.xml') >>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = javaproject ... ... [javaproject] ... recipe = collective.recipe.ant ... ant-options = ... echo ... -buildfile %s ... ... """ % buildfile)
获取Ant进程的输出,当它非常详细时
>>> print system(buildout + ' -v') Installing ... <BLANKLINE> echo: [echo] Foo Bar <BLANKLINE> BUILD SUCCESSFUL Total time: 0 seconds <BLANKLINE> javaproject: Build successful <BLANKLINE>
让我们看看类路径验证是否有效
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = javaproject ... ... [javaproject] ... recipe = collective.recipe.ant ... classpath = %s %s ... ant-options = ... echo ... -buildfile %s ... ... """ % (join(dirname(__file__), 'testdata'), ... tmpdir('foo'), ... buildfile))>>> print system(buildout) Uninstalling javaproject. Installing javaproject. javaproject: Build successful <BLANKLINE>
现在我们尝试引用一个(希望)不存在的目录
>>> write(sample_buildout, 'buildout.cfg', ... """ ... [buildout] ... parts = javaproject ... ... [javaproject] ... recipe = collective.recipe.ant ... classpath = %s ... ant-options = ... echo ... -buildfile %s ... ... """ % (join(dirname(__file__), '__bogus__dir__'), ... buildfile))>>> print system(buildout) Uninstalling javaproject. Installing javaproject. While: Installing javaproject. Error: Classpath .../__bogus__dir__ does not exist. <BLANKLINE>
1.0 (2010-01-05)
- Initial Release [tom_gross]
- Removed path checks from __init__() since the required paths may not be available at that time. [dokai]