1 package org.apache.torque.mojo; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.commons.configuration.PropertiesConfiguration; 23 import org.apache.torque.task.TorqueSQLTask; 24 25 /** 26 * Creates html or anakia documentation for the data model from the 27 * schema.xml files. 28 * 29 * @author Raphael Pieroni (rafale_at_codehaus.org) 30 * @author <a href="fischer@seitenbau.de">Thomas Fischer</a> 31 * 32 * @goal documentation 33 * @phase generate-sources 34 */ 35 public class DocumentationMojo extends DataModelTaskMojo 36 { 37 /** The context property for the output format. */ 38 public static final String OUTPUT_FORMAT_CONTEXT_PROPERTY 39 = "outputFormat"; 40 41 // The following dummies trick the Mojo Description Extractor 42 // into setting the correct default values for 43 // outputDir, reportFile, contextPropertiesPath, schemaExcludes 44 /** 45 * The directory in which the documentation will be generated 46 * 47 * @parameter property="outputDir" 48 * expression="${project.build.directory}/generated-docs/torque" 49 */ 50 private String dummy; 51 52 /** 53 * The location where the report file will be generated. 54 * 55 * @parameter property="reportFile" 56 * expression="../../torque/report.${project.artifact.artifactId}.doc.generation" 57 */ 58 private String dummy2; 59 60 /** 61 * The location where the context property file for velocity will be 62 * generated. 63 * 64 * @parameter property="contextPropertiesPath" 65 * expression="${project.build.directory}/torque/context.doc.properties" 66 */ 67 private String dummy3; 68 69 /** 70 * The schema files which should be excluded in generation 71 * (in ant-style notation). 72 * 73 * @parameter property="schemaExcludes" expression="id-table-schema.xml" 74 */ 75 private String dummy4; 76 77 /** 78 * The format of the generated documentation. Can be either html or anakia. 79 * 80 * @parameter expression="html" 81 */ 82 private String outputFormat; 83 84 /** 85 * Creates a new SQLMojo object. 86 */ 87 public DocumentationMojo() 88 { 89 super(new TorqueSQLTask()); 90 } 91 92 /** 93 * Sets the output format of the documentation (html or anakia) 94 * 95 * @param outputFormat the output format of the documentation. 96 */ 97 public void setOutputFormat(String outputFormat) 98 { 99 this.outputFormat = outputFormat; 100 } 101 102 /** 103 * Returns the output format of the documentation (html or anakia) 104 * 105 * @return the output format of the documentation. 106 */ 107 public String getOutputFormat() 108 { 109 return outputFormat; 110 } 111 112 /** 113 * Returns the context properties for the Texen task. 114 * 115 * @return The PropertiesConfiguration containing all context properties, 116 * not null. 117 */ 118 protected PropertiesConfiguration getMojoContextProperties() 119 { 120 PropertiesConfiguration configuration = new PropertiesConfiguration(); 121 configuration.addProperty( 122 OUTPUT_FORMAT_CONTEXT_PROPERTY, 123 getOutputFormat()); 124 return configuration; 125 } 126 127 /** 128 * Returns the path to the control template. 129 * 130 * @return "doc/Control.vm" 131 */ 132 protected String getControlTemplate() 133 { 134 return "doc/Control.vm"; 135 } 136 }