001 package org.apache.torque.mojo; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import java.io.File; 023 024 import org.apache.commons.configuration.PropertiesConfiguration; 025 import org.apache.maven.plugin.MojoExecutionException; 026 import org.apache.tools.ant.types.FileSet; 027 import org.kuali.core.db.torque.KualiTorqueSQLTask; 028 029 /** 030 * Generates SQL from schema.xml files 031 */ 032 public abstract class SqlMojoBase extends DataModelTaskMojo { 033 034 /** 035 * Creates a new SQLMojo object. 036 */ 037 public SqlMojoBase() { 038 setAntTask(new KualiTorqueSQLTask()); 039 } 040 041 /** 042 * Returns the context properties for the Texen task. 043 * 044 * @return The PropertiesConfiguration containing all context properties, not null. 045 */ 046 protected PropertiesConfiguration getMojoContextProperties() { 047 PropertiesConfiguration configuration = new PropertiesConfiguration(); 048 configuration.addProperty(TARGET_DATABASE_CONTEXT_PROPERTY, super.getTargetDatabase()); 049 return configuration; 050 } 051 052 /** 053 * Returns the path to the control template. 054 * 055 * @return "sql/base/Control.vm" 056 */ 057 protected String getControlTemplate() { 058 return "sql/base/Control.vm"; 059 } 060 061 /** 062 * Configures the Texen task wrapped by this mojo 063 */ 064 protected void configureTask() throws MojoExecutionException { 065 super.configureTask(); 066 067 KualiTorqueSQLTask task = (KualiTorqueSQLTask) super.getGeneratorTask(); 068 069 if (getSuffix() != null) { 070 getLog().debug("Adding suffix: " + getSuffix()); 071 task.setSuffix(getSuffix()); 072 } 073 FileSet fileSet = getAntFileSet(new File(getSchemaDir()), getSchemaIncludes(), getSchemaExcludes()); 074 task.addFileset(fileSet); 075 } 076 077 }