001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.tools.ant.taskdefs.optional;
019:
020: import java.io.File;
021: import org.apache.tools.ant.BuildException;
022: import org.apache.tools.ant.taskdefs.Java;
023:
024: /**
025: * Executes the Apache Stylebook documentation generator.
026: * Unlike the commandline version of this tool, all three arguments
027: * are required to run stylebook.
028: * <p>
029: * Being extended from <Java>, all the parent's attributes
030: * and options are available. Do not set any apart from the <tt>classpath</tt>
031: * as they are not guaranteed to be there in future.
032: * @todo stop extending from Java.
033: * @deprecated since 1.7.
034: * This task is considered unsupported by the Ant developers
035: */
036: public class StyleBook extends Java {
037: // CheckStyle:VisibilityModifier OFF - bc
038: // CheckStyle:MemberNameCheck OFF - bc
039: protected File m_targetDirectory;
040: protected File m_skinDirectory;
041: protected String m_loaderConfig;
042: protected File m_book;
043:
044: // CheckStyle:MemberNameCheck ON
045: // CheckStyle:VisibilityModifier ON
046:
047: /**
048: * Constructor
049: */
050: public StyleBook() {
051: setClassname("org.apache.stylebook.StyleBook");
052: setFork(true);
053: setFailonerror(true);
054: }
055:
056: /**
057: * Set the book xml file that the documentation generation starts from;
058: * required.
059: * @param book the source file
060: */
061:
062: public void setBook(final File book) {
063: m_book = book;
064: }
065:
066: /**
067: * Set the directory that contains the stylebook skin;
068: * required.
069: * @param skinDirectory the location of the stylebook skin
070: */
071: public void setSkinDirectory(final File skinDirectory) {
072: m_skinDirectory = skinDirectory;
073: }
074:
075: /**
076: * Set the destination directory where the documentation is generated;
077: * required.
078: * @param targetDirectory the document output directory
079: */
080: public void setTargetDirectory(final File targetDirectory) {
081: m_targetDirectory = targetDirectory;
082: }
083:
084: /**
085: * A loader configuration to send to stylebook; optional.
086: * @param loaderConfig the configuration to use.
087: */
088: public void setLoaderConfig(final String loaderConfig) {
089: m_loaderConfig = loaderConfig;
090: }
091:
092: /**
093: * call the program
094: * @throws BuildException if there is a problem.
095: */
096: public void execute() throws BuildException {
097:
098: if (null == m_targetDirectory) {
099: throw new BuildException(
100: "TargetDirectory attribute not set.");
101: }
102:
103: if (null == m_skinDirectory) {
104: throw new BuildException("SkinDirectory attribute not set.");
105: }
106:
107: if (null == m_book) {
108: throw new BuildException("book attribute not set.");
109: }
110:
111: createArg().setValue("targetDirectory=" + m_targetDirectory);
112: createArg().setValue(m_book.toString());
113: createArg().setValue(m_skinDirectory.toString());
114: if (null != m_loaderConfig) {
115: createArg().setValue("loaderConfig=" + m_loaderConfig);
116: }
117:
118: super.execute();
119: }
120: }
|