{"_id":"ant","_rev":"13-07f129d22212fd309c02888c0ece38e3","name":"ant","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.0":{"name":"ant","main":"package.json","version":"0.0.0","_npmJsonOpts":{"file":"/home/nickolay/.npm/ant/0.0.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"ant@0.0.0","dependencies":{},"devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.5.1","_defaultsLoaded":true,"dist":{"shasum":"f07cc335a0bce58c508163bcb046a033cf16760e","tarball":"https://registry.npmjs.org/ant/-/ant-0.0.0.tgz","integrity":"sha512-W/Y1YCn4iQhxqFiWn+17q/ZzmVRhPosFGcZV16dgOEite3FL2MMocnd200JCJJi9VPa26of5FG3wIQmzV8wHfQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDdRZqJHCyDCTI7cWsFJpxlqw7SaiQwsjpr+nVhgttiPQIhAM8fA90BDbu/5PGZTHjT103rTijAEBGyuePEOJ4gW404"}]},"scripts":{},"maintainers":[{"name":"samuraijack","email":"nickolay8@gmail.com"}],"directories":{}},"0.2.0":{"name":"ant","description":"Apache Ant Adapter, execute Ant tasks from node","keywords":["ant","build","java"],"homepage":"http://github.com/millermedeiros/node-ant/","version":"0.2.0","author":{"name":"Miller Medeiros","url":"http://blog.millermedeiros.com/"},"repository":{"type":"git","url":"https://github.com/millermedeiros/node-ant.git"},"main":"index.js","bugs":{"url":"https://github.com/millermedeiros/node-ant/issues"},"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.php"}],"engines":{"node":"~0.8.0"},"readme":"# node-ant\n\nExperimental [Apache Ant](http://ant.apache.org/) adapter for\n[node.js](http://nodejs.org).\n\nThis is a proof-of-concept more than anything else. Still unsure if it will\nactually work on multiple environments and if it is really a good idea.\n\n\n\n## Why?\n\nMany people been using [node.js to run build\nscripts](http://blog.millermedeiros.com/node-js-as-a-build-script/) and\neveryone is writting the same tasks for the most basic stuff like\ncopying/concateneting/deleting/ziping files and it will take a long time before\n*someone* implements [all the tasks present on\nAnt](http://ant.apache.org/manual/tasksoverview.html).\n\nProjects like [grunt](https://github.com/cowboy/grunt),\n[gear](https://github.com/yahoo/gear), [jake](https://github.com/mde/jake),\n[rivet](https://github.com/jaredhanson/rivet),\n[roto](https://github.com/diy/roto) and many others are all writting their own\ntasks to do the same things. TBH I think a better approach would be to create\nseparate libs that could do each task (or a group of tasks) and that wasn't\ntied to a specific build tool, and create tools that abused this (no need to\nconvert 3rd party lib into a plugin or author a new module just to use the\nmethods inside your build files).\n\nAnt contains [many advanced tasks](http://ant.apache.org/manual/tasksoverview.html)\nand is *battle tested* so it makes sense to reuse them instead of reinventing\nthe wheel.\n\nAnt is also not that easy to install on Windows since you need to configure the\n`ANT_HOME`, `CLASSPATH` and `JAVA_HOME` paths. So it's easier to use\na standalone version of Ant that is distributed together with the\n[npm](http://npmjs.org) package. The Java Runtime is avaialble on most\ncomputers so calling the ant executable should work out of the box on most\ncases.\n\nThe idea is not to write multiple ant `<target>`s, but to treat Ant as\na standalone lib that can be called from a node.js script. Performance isn't\nthat great (since JVM isn't as fast as node) but it is still better than\nwritting error-prone tasks that gets half of the job done.\n\nBuild tools based solely on configuration are doomed to \"fail\" the same way as\nAnt did \"failed\". You can't express all edge-cases with configuration without\ncreating an overly complex system. Some things that could be easily done with\na `for` loop and a few `if/else` are a huge PITA with a descriptive syntax\n(XML/JSON). The main reason why I moved my build scripts to node.js is to the\nget freedom to write new tasks by myself without major pains, locking down your\nbuild to a system that can only be extended by writting plugins that accepts\na simple config object won't scale up. Let's use Ant for what it is good for\n(broad amount of battle tested tasks with flexible config options) and use\nplain JavaScript for those tasks that aren't covered by Ant.\n\nMaybe this project will motivate someone to port the most important Ant tasks\nto plain JavaScript. I still haven't found a single node task that is as\ncomplete the ones provided by Ant, see for instance all the options available\non the [copy task](http://ant.apache.org/manual/Tasks/copy.html) (multiple\n`include`/`exclude`, `filter`, `globmapper`, download internet files,\n`flatten`, etc...).\n\n\n\n## How?\n\nThe idea is to use the Ant as if it was a standalone library that can be called\nfrom node.js, that way you can reuse them in your custom node.js build files\nwhen necessary.\n\nIt will simply convert JSON-like objects into a temporary XML file and execute\nthe standalone version of Ant passing the custom arguments. This tool is just\na \"bridge\" between Node.js and the Ant JAR file.\n\n\n\n## Example\n\nExecute the test file to see a very basic example:\n\n    node test\n\nYou can run it from another node.js program:\n\n```js\nvar ant = require('ant');\n\nant.exec({\n    // concat task (http://ant.apache.org/manual/Tasks/concat.html)\n    concat : {\n        fileset : {\n            '@dir' : '.',\n            include : {\n                '@name' : '*.js'\n            }\n        }\n    }\n}, function(err, stdout, stderror){\n    // it doesn't throw any errors and also doesn't log the stdout by\n    // default that way you can control what you want to do.\n    if (stdout) console.log(stdout);\n    if (stderror) console.log(stderror);\n    if (err) throw err;\n});\n```\n\n\n\n## Documentation\n\nRight now it contains a single method `exec()` that accepts an object with each\ntask and a callback. The tasks are just JSON-like representation of the XML\nmarkup needed to execute each task, `node-ant` will convert it back to XML\nduring the `exec`.\n\n\n### `ant.exec(tasks, [args], callback)`\n\n - **tasks**:\n   - JSON-like object containing Ant tasks to be executed.\n - **[args]**:\n   - Command line arguments passed to the ant executable.\n - **callback**\n   - Function executed after `exec` finishes. Will receive the following\n     arguments: (err, stdout, stderr).\n\n\n### JXON syntax\n\nAttributes starts with `@`.\n\n    > { foo : { '@bar' : 123 }}\n    <foo bar=\"123\" />\n\nThe XML node text value is stored as the actual key value if node doesn't\ncontain attributes and/or child nodes or on a special property `keyValue`.\n\n    > {\n        foo : 'Lorem Ipsum'\n    }\n    <foo>Lorem Ipsum</foo>\n\n    > {\n        foo : {\n            '@bar' : 123,\n            keyValue : 'Lorem Ipsum'\n        }\n    }\n    <foo bar=\"123\">Lorem Ipsum</foo>\n\n    > {\n        concat : {\n            fileset : {\n                '@dir' : '.',\n                include : {\n                    '@name' : '*.js'\n                }\n            }\n        }\n    }\n    <concat><fileset dir=\".\"><include name=\"*.js\" /></fileset></concat>\n\nUse the [Ant tasks\ndocumentation](http://ant.apache.org/manual/tasksoverview.html) as reference.\n\n\n\n## Important\n\nThis project is on early experimental phase. The way that `ant.exec` is called\nmight change in the future, specially since the\n[JXON](https://developer.mozilla.org/en/JXON) format currently used doesn't\nallow XML nodes with same name that aren't adjacent to each other (object can't\nhave multiple properties with the same key). So I might end up changing the\nformat to something closer to [JSONML](http://www.jsonml.org/) or use some sort\nof special token to differentiate duplicates (eg. `echo#1`, `echo#2`).\n\n\n\n## TODO\n\n - Test on a computer that doesn't have JDK installed.\n - Check if it is possible to ship with a standalone version of JDK for the\n   advanced tasks.\n - Make it possible to log to console without waiting the whole task to finish.\n\n\n\n## Requirements\n\n - node.js 0.8.0+\n - Java\n - JDK 1.4+ (depending on which task you use)\n\n\n\n## Changelog\n\n### v0.2.0 (2012/08/03)\n\n - add support to functions on tasks (for [script](http://ant.apache.org/manual/Tasks/script.html) task). [Thanks to @Diullei](https://gist.github.com/3245017)\n - small refactor to jxon to improve readability and autoclose empty tags.\n\n\n### v0.1.0 (2012/08/02)\n\n - initial release.\n\n\n\n## License\n\nnode-ant is distributed under the MIT license.\n\nApache Ant is distributed under the Apache License.\n","_id":"ant@0.2.0","dist":{"shasum":"f4abbe0d6f9cc4f63db5d3a557450288a0f0a394","tarball":"https://registry.npmjs.org/ant/-/ant-0.2.0.tgz","integrity":"sha512-DWibFtH1S2f3ueMjO9EWy+jdFtcYR2byZIV62w5eBcWZVL3xeGyyN9t3kqv/kRsU8LMPD78XIQB8arywB8oRIA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoduozBcVgEsXqXs+LTNCmQRaHIKuVCTIJGTKJKxxNBAIgJgi1EbdRrlgqhHAKOPpHTY6qzuFZ0mCpnNZo2Q0fRp4="}]},"maintainers":[{"name":"millermedeiros","email":"miller@millermedeiros.com"}]}},"maintainers":[{"name":"millermedeiros","email":"miller@millermedeiros.com"}],"time":{"modified":"2022-06-13T03:05:44.118Z","created":"2011-09-05T06:40:07.619Z","0.0.0":"2011-09-05T06:40:08.462Z","0.2.0":"2012-08-03T17:18:55.090Z"},"description":"Apache Ant Adapter, execute Ant tasks from node","author":{"name":"Miller Medeiros","url":"http://blog.millermedeiros.com/"},"repository":{"type":"git","url":"https://github.com/millermedeiros/node-ant.git"}}