KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > StyleBook


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  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.taskdefs.optional;
19
20 import java.io.File JavaDoc;
21 import org.apache.tools.ant.BuildException;
22 import org.apache.tools.ant.taskdefs.Java;
23
24 /**
25  * Executes the Apache Stylebook documentation generator.
26  * Unlike the commandline version of this tool, all three arguments
27  * are required to run stylebook.
28  * <p>
29  * Being extended from &lt;Java&gt;, all the parent's attributes
30  * and options are available. Do not set any apart from the <tt>classpath</tt>
31  * as they are not guaranteed to be there in future.
32  * @todo stop extending from Java.
33  * @deprecated since 1.7.
34  * This task is considered unsupported by the Ant developers
35  */

36 public class StyleBook extends Java {
37     // CheckStyle:VisibilityModifier OFF - bc
38
// CheckStyle:MemberNameCheck OFF - bc
39
protected File JavaDoc m_targetDirectory;
40     protected File JavaDoc m_skinDirectory;
41     protected String JavaDoc m_loaderConfig;
42     protected File JavaDoc m_book;
43     // CheckStyle:MemberNameCheck ON
44
// CheckStyle:VisibilityModifier ON
45

46
47     /**
48      * Constructor
49      */

50     public StyleBook() {
51         setClassname("org.apache.stylebook.StyleBook");
52         setFork(true);
53         setFailonerror(true);
54     }
55
56     /**
57      * Set the book xml file that the documentation generation starts from;
58      * required.
59      * @param book the source file
60      */

61
62     public void setBook(final File JavaDoc book) {
63         m_book = book;
64     }
65
66
67     /**
68      * Set the directory that contains the stylebook skin;
69      * required.
70      * @param skinDirectory the location of the stylebook skin
71      */

72     public void setSkinDirectory(final File JavaDoc skinDirectory) {
73         m_skinDirectory = skinDirectory;
74     }
75
76
77     /**
78      * Set the destination directory where the documentation is generated;
79      * required.
80      * @param targetDirectory the document output directory
81      */

82     public void setTargetDirectory(final File JavaDoc targetDirectory) {
83         m_targetDirectory = targetDirectory;
84     }
85
86     /**
87      * A loader configuration to send to stylebook; optional.
88      * @param loaderConfig the configuration to use.
89      */

90     public void setLoaderConfig(final String JavaDoc loaderConfig) {
91         m_loaderConfig = loaderConfig;
92     }
93
94
95     /**
96      * call the program
97      * @throws BuildException if there is a problem.
98      */

99     public void execute()
100          throws BuildException {
101
102         if (null == m_targetDirectory) {
103             throw new BuildException("TargetDirectory attribute not set.");
104         }
105
106         if (null == m_skinDirectory) {
107             throw new BuildException("SkinDirectory attribute not set.");
108         }
109
110         if (null == m_book) {
111             throw new BuildException("book attribute not set.");
112         }
113
114         createArg().setValue("targetDirectory=" + m_targetDirectory);
115         createArg().setValue(m_book.toString());
116         createArg().setValue(m_skinDirectory.toString());
117         if (null != m_loaderConfig) {
118             createArg().setValue("loaderConfig=" + m_loaderConfig);
119         }
120
121         super.execute();
122     }
123 }
124
Popular Tags