You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

argumentprocessor.html 2.9 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
  19. <title>The Command Line Processor Plugin: ArgumentProcessor</title>
  20. </head>
  21. <body>
  22. <h1>The Command Line Processor Plugin: ArgumentProcessor</h1>
  23. <h2><a name="definition">What is an ArgumentProcessor?</a></h2>
  24. <p>
  25. An <code>ArgumentProcessor</code> is a parser of command line argument which is
  26. then call before and after the build file is being parsed. Third party
  27. libraries may then be able to have custom argument line argument which modify
  28. Ant behaviour.
  29. </p>
  30. <p>
  31. An <code>ArgumentProcessor</code> is called each time Ant parse an unknown
  32. argument, an <code>ArgumentProcessor</code> doesn't take precedence over Ant to
  33. parse already suported options. It is then recommended to third party
  34. <code>ArgumentProcessor</code> implementation to chose specific 'enough'
  35. argument name, avoiding for instance one letter arguments.
  36. </p>
  37. <p>
  38. It is also called at the different phases so different behaviour can be
  39. implemented. It is called just after every arguments are parsed, just
  40. before the project is being configured (the build file being parsed),
  41. and just after. Some of the methods to be implemented return a boolean:
  42. if <code>true</code> is returned, Ant will terminate immediately, without
  43. error.
  44. </p>
  45. <p>
  46. Being called during all these phases, an <code>ArgumentProcessor</code>
  47. can just print some specific system properties and quit (like
  48. <code>-diagnose</code>), or print some specific properties of a project after
  49. being parsed and quit (like <code>-projectHelp</code>), or just set some
  50. custom properties on the project and let it run.
  51. </p>
  52. <h2><a name="repository">How to register it's own ArgumentProcessor</a></h2>
  53. <p>First, the <code>ArgumentProcessor</code> must be an implementation of
  54. <code>org.apache.tools.ant.ArgumentProcessor</code>.
  55. </p>
  56. <p>Then to decare it: create a file
  57. <code>META-INF/services/org.apache.tools.ant.ArgumentProcessor</code> which
  58. contains only one line the fully qualified name of the class of the
  59. implementation. This file together with the implementation class need then to
  60. be found in Ant's classpath.
  61. </p>
  62. </body>
  63. </html>