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 3.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 id="definition">What is an ArgumentProcessor?</h2>
  24. <p>
  25. An <code class="code">ArgumentProcessor</code> is a parser of command line argument which is then
  26. call before and after the build file is being parsed. Third party libraries may then be able to have
  27. custom argument line argument which modify Ant behaviour.
  28. </p>
  29. <p>
  30. An <code class="code">ArgumentProcessor</code> is called each time Ant parse an unknown argument,
  31. an <code class="code">ArgumentProcessor</code> doesn't take precedence over Ant to parse already
  32. supported options. It is then recommended to third party <code class="code">ArgumentProcessor</code>
  33. implementation to chose specific 'enough' argument name, avoiding for instance one letter arguments.
  34. </p>
  35. <p>
  36. It is also called at the different phases so different behaviour can be implemented. It is called
  37. just after every arguments are parsed, just before the project is being configured (the build file
  38. being parsed), and just after. Some of the methods to be implemented return a boolean:
  39. if <q>true</q> is returned, Ant will terminate immediately, without error.
  40. </p>
  41. <p>
  42. Being called during all these phases, an <code class="code">ArgumentProcessor</code> can just print
  43. some specific system properties and quit (like <kbd>-diagnose</kbd>), or print some specific
  44. properties of a project after being parsed and quit (like <kbd>-projectHelp</kbd>), or just set some
  45. custom properties on the project and let it run.
  46. </p>
  47. <h2 id="repository">How to register it's own ArgumentProcessor</h2>
  48. <p>First, the <code class="code">ArgumentProcessor</code> must be an implementation
  49. of <code class="code">org.apache.tools.ant.ArgumentProcessor</code>.
  50. </p>
  51. <p>Then to declare it: create a
  52. file <samp>META-INF/services/org.apache.tools.ant.ArgumentProcessor</samp> which contains only one
  53. line the fully qualified name of the class of the implementation. This file together with the
  54. implementation class need then to be found in Ant's classpath.
  55. </p>
  56. </body>
  57. </html>