View Javadoc

1   /**
2    * Copyright 2004-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.torque.mojo;
17  
18  import java.io.File;
19  
20  import org.apache.maven.plugin.MojoExecutionException;
21  import org.apache.torque.mojo.morph.MorphRequest;
22  import org.apache.torque.mojo.morph.Morpher;
23  import org.apache.torque.mojo.morph.SchemaMorpher;
24  
25  /**
26   * Convert an Ant impex schema XML file into a maven-impex-plugin schema XML file
27   *
28   * @goal morphschema
29   * @phase generate-sources
30   */
31  public class MorphSchemaMojo extends AbstractMorphSingleMojo {
32  
33      /**
34       * The XML file describing the database schema (Maven style)
35       *
36       * @parameter expression="${newSchemaXMLFile}" default-value=
37       *            "${project.build.directory}/generated-impex/${project.artifactId}.xml"
38       * @required
39       */
40      private File newSchemaXMLFile;
41  
42      /**
43       * The XML file describing the database schema (Ant style)
44       *
45       * @parameter expression="${oldSchemaXMLFile}" default-value="${basedir}/src/main/impex/schema.xml"
46       * @required
47       */
48      private File oldSchemaXMLFile;
49  
50      @Override
51      protected void beforeExecution() {
52          setNewFile(newSchemaXMLFile);
53          setOldFile(oldSchemaXMLFile);
54      }
55  
56      @Override
57      protected void executeMojo() throws MojoExecutionException {
58          getLog().info("------------------------------------------------------------------------");
59          getLog().info("Converting schema XML file");
60          getLog().info("------------------------------------------------------------------------");
61          super.executeMojo();
62      }
63  
64      @Override
65      protected Morpher getMorpher(final MorphRequest request, final String artifactId) {
66          return new SchemaMorpher(request, artifactId);
67      }
68  
69      public File getNewSchemaXMLFile() {
70          return newSchemaXMLFile;
71      }
72  
73      public void setNewSchemaXMLFile(final File newSchemaXMLFile) {
74          this.newSchemaXMLFile = newSchemaXMLFile;
75      }
76  
77      public File getOldSchemaXMLFile() {
78          return oldSchemaXMLFile;
79      }
80  
81      public void setOldSchemaXMLFile(final File oldSchemaXMLFile) {
82          this.oldSchemaXMLFile = oldSchemaXMLFile;
83      }
84  }