001 package org.apache.torque.mojo; 002 003 import java.io.File; 004 005 import org.apache.maven.plugin.MojoExecutionException; 006 import org.apache.torque.mojo.morph.MorphRequest; 007 import org.apache.torque.mojo.morph.Morpher; 008 import org.apache.torque.mojo.morph.SchemaMorpher; 009 010 /** 011 * Convert an Ant impex schema XML file into a maven-impex-plugin schema XML file 012 * 013 * @goal morphschema 014 * @phase generate-sources 015 */ 016 public class MorphSchemaMojo extends AbstractMorphSingleMojo { 017 018 /** 019 * The XML file describing the database schema (Maven style) 020 * 021 * @parameter expression="${newSchemaXMLFile}" default-value= 022 * "${project.build.directory}/generated-impex/${project.artifactId}.xml" 023 * @required 024 */ 025 private File newSchemaXMLFile; 026 027 /** 028 * The XML file describing the database schema (Ant style) 029 * 030 * @parameter expression="${oldSchemaXMLFile}" default-value="${basedir}/src/main/impex/schema.xml" 031 * @required 032 */ 033 private File oldSchemaXMLFile; 034 035 @Override 036 protected void beforeExecution() { 037 setNewFile(newSchemaXMLFile); 038 setOldFile(oldSchemaXMLFile); 039 } 040 041 @Override 042 protected void executeMojo() throws MojoExecutionException { 043 getLog().info("------------------------------------------------------------------------"); 044 getLog().info("Converting schema XML file"); 045 getLog().info("------------------------------------------------------------------------"); 046 super.executeMojo(); 047 } 048 049 @Override 050 protected Morpher getMorpher(final MorphRequest request, final String artifactId) { 051 return new SchemaMorpher(request, artifactId); 052 } 053 054 public File getNewSchemaXMLFile() { 055 return newSchemaXMLFile; 056 } 057 058 public void setNewSchemaXMLFile(final File newSchemaXMLFile) { 059 this.newSchemaXMLFile = newSchemaXMLFile; 060 } 061 062 public File getOldSchemaXMLFile() { 063 return oldSchemaXMLFile; 064 } 065 066 public void setOldSchemaXMLFile(final File oldSchemaXMLFile) { 067 this.oldSchemaXMLFile = oldSchemaXMLFile; 068 } 069 }