是否有任何好的教程整合咕噜与蚂蚁?我们目前的版本使用ant,因为我们是一家Java商店。然而,前端开始成为头等公民,我们正在研究使用node和grunt来进行前端构建。我需要将前端构建与ant构建集成。我需要知道如何规范所有我的自定义任务的退出代码以及内置的grunt任务,并在咕噜任务被ant调用时将控制台输出限制为这些预定义的代码。任何帮助将不胜感激。整合咕噜与蚂蚁
整合咕噜与蚂蚁
回答
Grunt可以调用命令行,因此您可以轻松地在grunt中创建几个任务,除了通过shell执行一个ant任务外什么也不做。
的grunt-shell
库使它特别容易从繁重的任务,执行外部命令:https://github.com/sindresorhus/grunt-shell
既然你在谈论的自定义退出代码,不过,你很有可能要结束了写自己的自定义咕噜任务执行shell命令,然后查看响应代码(可能使用grunt.helpers.spawn
帮助程序):https://github.com/gruntjs/grunt/blob/master/docs/api_utils.md#gruntutilsspawn
我的建议是?我的organization recently went through the same thing,如果可能的话,最好尽量彻底摆脱蚂蚁,彻底摆脱与JavaScript相关的项目。
Grunt有这样一个越来越有用的插件库,如果你不能复制你的ant构建文件并创建一个100%javascript解决方案,我会感到惊讶。
您可以使用http://abc.tools.qafoo.com/其中包括NPM模块* 1)
,那么你唯一需要的是一个自定义的目标,如:
…
<target
name="-mm:compile:main~hooked"
extensionOf="-compile:main~hook"
depends="
-my-compile-npm-hook
"
>
<target
name="-my-compile-npm-hook"
>
<echo>install local grunt-cli</echo>
<antcall target="npm:install">
<param name="in.npm.package.name" value="grunt-cli" />
</antcall>
</target>
…
之后,你可能会遇到在.npm/node_modules/.bin/
目录别名咕噜${npm.local.modulesdir}/.bin/
^^不会错过包括或src/main/resources/extensions/npm/npm.properties
* 1)定义属性:unfortunatly buggy与当前的node.js版本
您可以使用此宏:
<macrodef name="exec-node">
<attribute name="module" description="The name of the NodeJS module to execute"/>
<attribute name="failonerror" default="true" description="Fail if the exit code is not 0"/>
<element name="args" implicit="yes" description="Argument to pass to the exec task"/>
<sequential>
<exec executable="cmd.exe" failonerror="@{failonerror}" osfamily="winnt">
<arg line="/c @{module}" />
<args/>
<!-- Windows cmd output workaround: http://stackoverflow.com/a/10359327/227349 -->
<!-- Forces node's stderror and stdout to a temporary file -->
<arg line=" > _tempfile.out 2<&1"/>
<!-- If command exits with an error, then output the temporary file -->
<!-- to stdout delete the temporary file and finally exit with error level 1 -->
<!-- so that the apply task can catch the error if @failonerror="true" -->
<arg line=" || (type _tempfile.out & del _tempfile.out & exit /b 1)"/>
<!-- Otherwise, just type the temporary file and delete it-->
<arg line=" & type _tempfile.out & del _tempfile.out &"/>
</exec>
<exec executable="@{module}" failonerror="@{failonerror}" osfamily="unix">
<args/>
</exec>
</sequential>
</macrodef>
而且你可以调用任何命令:例如:
<target name="jshint">
<exec-node module="grunt">
<arg value="jshint" />
</exec-node>
</target>
的作品就像一个魅力:也保证了标准错误还印,这是一种常见调用grunt时出现问题。
- 1. 整合svnant与蚂蚁1.6和svnclient1.7
- 2. 与咕噜
- 3. 咕噜:咕噜毂不看
- 4. 与咕噜 - 萨斯
- 5. 咕噜livereload与WordPress
- 6. 与蚂蚁JARring
- 7. 如何整合蚂蚁设计和arangodb?
- 8. 咕噜:运行咕噜-GH-页
- 9. 如何使用SVG与咕噜咕噜和玉
- 10. 热运行咕噜服务与咕噜-永远
- 11. 设置与蚂蚁
- 12. 建筑与蚂蚁
- 13. 未能与蚂蚁
- 14. 与咕噜量角器
- 15. 版本控制与咕噜
- 16. 咕噜配置与参数
- 17. 蚂蚁合并结构
- 18. 如何咕噜
- 19. Debowerify不咕噜
- 20. 咕噜力看?
- 21. 在咕噜
- 22. 的咕噜
- 23. 蚂蚁
- 24. 蚂蚁
- 25. 构建步骤:“调用蚂蚁”与“从shell运行蚂蚁”
- 26. 使用xjc与蚂蚁
- 27. NoClassDefFoundError的运行与蚂蚁
- 28. 迭代通过与蚂蚁
- 29. ftp任务与蚂蚁
- 30. 与蚂蚁的Flex SDK
我也在Java商店,这是一个很难卖。虽然前端对我们而言也越来越重要,但我们不太可能将JS用作服务器端代码的构建语言。更现实的方法似乎是通过自定义的ant任务调用grunt。另一方面,我没有看到有人这样做,所以... – carbontax