View Javadoc

1   package org.apache.torque.mojo;
2   
3   import java.io.File;
4   
5   import org.apache.maven.plugin.MojoExecutionException;
6   import org.apache.torque.mojo.morph.MorphRequest;
7   import org.apache.torque.mojo.morph.Morpher;
8   import org.apache.torque.mojo.morph.SchemaMorpher;
9   
10  /**
11   * Convert an Ant impex schema XML file into a maven-impex-plugin schema XML file
12   *
13   * @goal morphschema
14   * @phase generate-sources
15   */
16  public class MorphSchemaMojo extends AbstractMorphSingleMojo {
17  
18      /**
19       * The XML file describing the database schema (Maven style)
20       *
21       * @parameter expression="${newSchemaXMLFile}" default-value=
22       * "${project.build.directory}/generated-impex/${project.artifactId}.xml"
23       * @required
24       */
25      private File newSchemaXMLFile;
26  
27      /**
28       * The XML file describing the database schema (Ant style)
29       *
30       * @parameter expression="${oldSchemaXMLFile}" default-value="${basedir}/src/main/impex/schema.xml"
31       * @required
32       */
33      private File oldSchemaXMLFile;
34  
35      @Override
36      protected void beforeExecution() {
37          setNewFile(newSchemaXMLFile);
38          setOldFile(oldSchemaXMLFile);
39      }
40  
41      @Override
42      protected void executeMojo() throws MojoExecutionException {
43          getLog().info("------------------------------------------------------------------------");
44          getLog().info("Converting schema XML file");
45          getLog().info("------------------------------------------------------------------------");
46          super.executeMojo();
47      }
48  
49      @Override
50      protected Morpher getMorpher(final MorphRequest request, final String artifactId) {
51          return new SchemaMorpher(request, artifactId);
52      }
53  
54      public File getNewSchemaXMLFile() {
55          return newSchemaXMLFile;
56      }
57  
58      public void setNewSchemaXMLFile(final File newSchemaXMLFile) {
59          this.newSchemaXMLFile = newSchemaXMLFile;
60      }
61  
62      public File getOldSchemaXMLFile() {
63          return oldSchemaXMLFile;
64      }
65  
66      public void setOldSchemaXMLFile(final File oldSchemaXMLFile) {
67          this.oldSchemaXMLFile = oldSchemaXMLFile;
68      }
69  }