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