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 |
|
---|
19 | import java.io.File;
|
---|
20 | import org.apache.tools.ant.BuildException;
|
---|
21 | import org.apache.tools.ant.taskdefs.Java;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Executes the Apache Stylebook documentation generator.
|
---|
25 | * Unlike the commandline version of this tool, all three arguments
|
---|
26 | * are required to run stylebook.
|
---|
27 | * <p>
|
---|
28 | * Being extended from <Java>, all the parent's attributes
|
---|
29 | * and options are available. Do not set any apart from the <tt>classpath</tt>
|
---|
30 | * as they are not guaranteed to be there in future.
|
---|
31 | * @todo stop extending from Java.
|
---|
32 | */
|
---|
33 | public class StyleBook extends Java {
|
---|
34 | protected File m_targetDirectory;
|
---|
35 | protected File m_skinDirectory;
|
---|
36 | protected String m_loaderConfig;
|
---|
37 | protected File m_book;
|
---|
38 |
|
---|
39 |
|
---|
40 | public StyleBook() {
|
---|
41 | setClassname("org.apache.stylebook.StyleBook");
|
---|
42 | setFork(true);
|
---|
43 | setFailonerror(true);
|
---|
44 | }
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * The book xml file that the documentation generation starts from;
|
---|
48 | * required.
|
---|
49 | */
|
---|
50 |
|
---|
51 | public void setBook(final File book) {
|
---|
52 | m_book = book;
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * the directory that contains the stylebook skin;
|
---|
58 | * required.
|
---|
59 | */
|
---|
60 | public void setSkinDirectory(final File skinDirectory) {
|
---|
61 | m_skinDirectory = skinDirectory;
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * the destination directory where the documentation is generated;
|
---|
67 | * required.
|
---|
68 | */
|
---|
69 | public void setTargetDirectory(final File targetDirectory) {
|
---|
70 | m_targetDirectory = targetDirectory;
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * A loader configuration to send to stylebook; optional.
|
---|
75 | */
|
---|
76 | public void setLoaderConfig(final String loaderConfig) {
|
---|
77 | m_loaderConfig = loaderConfig;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * call the program
|
---|
83 | */
|
---|
84 | public void execute()
|
---|
85 | throws BuildException {
|
---|
86 |
|
---|
87 | if (null == m_targetDirectory) {
|
---|
88 | throw new BuildException("TargetDirectory attribute not set.");
|
---|
89 | }
|
---|
90 |
|
---|
91 | if (null == m_skinDirectory) {
|
---|
92 | throw new BuildException("SkinDirectory attribute not set.");
|
---|
93 | }
|
---|
94 |
|
---|
95 | if (null == m_book) {
|
---|
96 | throw new BuildException("book attribute not set.");
|
---|
97 | }
|
---|
98 |
|
---|
99 | createArg().setValue("targetDirectory=" + m_targetDirectory);
|
---|
100 | createArg().setValue(m_book.toString());
|
---|
101 | createArg().setValue(m_skinDirectory.toString());
|
---|
102 | if (null != m_loaderConfig) {
|
---|
103 | createArg().setValue("loaderConfig=" + m_loaderConfig);
|
---|
104 | }
|
---|
105 |
|
---|
106 | super.execute();
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|