1. /*
  2. * Copyright 2000-2002,2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional;
  18. import java.io.File;
  19. import org.apache.tools.ant.BuildException;
  20. import org.apache.tools.ant.taskdefs.Java;
  21. /**
  22. * Executes the Apache Stylebook documentation generator.
  23. * Unlike the commandline version of this tool, all three arguments
  24. * are required to run stylebook.
  25. * <p>
  26. * Being extended from <Java>, all the parent's attributes
  27. * and options are available. Do not set any apart from the <tt>classpath</tt>
  28. * as they are not guaranteed to be there in future.
  29. * @todo stop extending from Java.
  30. */
  31. public class StyleBook extends Java {
  32. protected File m_targetDirectory;
  33. protected File m_skinDirectory;
  34. protected String m_loaderConfig;
  35. protected File m_book;
  36. public StyleBook() {
  37. setClassname("org.apache.stylebook.StyleBook");
  38. setFork(true);
  39. setFailonerror(true);
  40. }
  41. /**
  42. * The book xml file that the documentation generation starts from;
  43. * required.
  44. */
  45. public void setBook(final File book) {
  46. m_book = book;
  47. }
  48. /**
  49. * the directory that contains the stylebook skin;
  50. * required.
  51. */
  52. public void setSkinDirectory(final File skinDirectory) {
  53. m_skinDirectory = skinDirectory;
  54. }
  55. /**
  56. * the destination directory where the documentation is generated;
  57. * required.
  58. */
  59. public void setTargetDirectory(final File targetDirectory) {
  60. m_targetDirectory = targetDirectory;
  61. }
  62. /**
  63. * A loader configuration to send to stylebook; optional.
  64. */
  65. public void setLoaderConfig(final String loaderConfig) {
  66. m_loaderConfig = loaderConfig;
  67. }
  68. /**
  69. * call the program
  70. */
  71. public void execute()
  72. throws BuildException {
  73. if (null == m_targetDirectory) {
  74. throw new BuildException("TargetDirectory attribute not set.");
  75. }
  76. if (null == m_skinDirectory) {
  77. throw new BuildException("SkinDirectory attribute not set.");
  78. }
  79. if (null == m_book) {
  80. throw new BuildException("book attribute not set.");
  81. }
  82. createArg().setValue("targetDirectory=" + m_targetDirectory);
  83. createArg().setValue(m_book.toString());
  84. createArg().setValue(m_skinDirectory.toString());
  85. if (null != m_loaderConfig) {
  86. createArg().setValue("loaderConfig=" + m_loaderConfig);
  87. }
  88. super.execute();
  89. }
  90. }