org.dbmaintain.maven.plugin
Class CreateScriptArchiveMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.dbmaintain.maven.plugin.BaseMojo
          extended by org.dbmaintain.maven.plugin.CreateScriptArchiveMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public class CreateScriptArchiveMojo
extends BaseMojo

Task that enables creating a jar file that packages all database update scripts. This jar can then be used as input for the updateDatabase task to apply changes on a target database. This way, database updates can be distributed as a deliverable, just like a war or ear file.
The created jar file will contain all configuration concerning the scripts in the META-INF folder.

This operation will hook into the package stage and will attach the generated archive to the build (so that it is installed in the local repository). The archive will have the same artifact id and group id as configured in the pom. An optional classifier can be configured also. A typical usage would be to create a pom of packaging type pom and then add this pom to your scripts folder.


 <project>
   <groupId>mygroup</groupId>
   <artifactId>myScripts</artifactId>
   <version>version</version>
   <packaging>pom</packaging>

   <build>
       <plugins>
           <plugin>
               <groupId>org.dbmaintain</groupId>
               <artifactId>dbmaintain-maven-plugin</artifactId>
               <version>-current dbmaintain version-</version>
               <configuration>
                   <databases>
                       <database>
                           <dialect>oracle</dialect>
                           <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
                           <userName>user</userName>
                           <password>pass</password>
                           <url>jdbc:oracle:thin:@//localhost:1521/XE</url>
                           <schemaNames>TEST</schemaNames>
                       </database>
                   </databases>
               </configuration>
               <executions>
                  <execution>
                      <goals>
                          <goal>createScriptArchive</goal>
                      </goals>
                  </execution>
               </executions>
          </plugins>
       </plugin>
   </build>
 </project>
 
The installed artifact can then later be used as a scriptArchiveDependency in for example the updateDatabase task.

You can also specify an explicit archive name. In that case, the archive will just be generated and not attached to the build.

Author:
Tim Ducheyne, tiwe

Field Summary
protected  String archiveFileName
          Explicitly defines the target name for the generated script archive.
protected  String patchQualifiers
          The qualifier to use to determine whether a script is a patch script.
protected  String postProcessingScriptDirectoryName
          Comma separated list of directories and files in which the post processing database scripts are located.
protected  String qualifier
          An optional qualifier for the artifact.
protected  String qualifiers
          Optional comma-separated list of script qualifiers.
protected  String scriptEncoding
          Encoding to use when reading the script files.
protected  String scriptFileExtensions
          Sets the scriptFileExtensions property, that defines the extensions of the files that are regarded to be database scripts.
protected  String scriptLocations
          Defines where the scripts can be found that must be added to the jar file.
 
Fields inherited from class org.dbmaintain.maven.plugin.BaseMojo
artifactFactory, configFile, localRepository, mavenProjectHelper, project, remoteRepositories, resolver
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
CreateScriptArchiveMojo()
           
 
Method Summary
protected  DbMaintainTask createDbMaintainTask()
           
protected  void performAfterTaskActions()
          Hook method to perform some operations (such as attaching an artifact) when the task has completed successfully.
 
Methods inherited from class org.dbmaintain.maven.plugin.BaseMojo
execute, getMavenProperties
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scriptLocations

protected String scriptLocations
Defines where the scripts can be found that must be added to the jar file. Multiple locations may be configured, separated by comma's. Only folder names can be provided. Defaults to the current folder.


archiveFileName

protected String archiveFileName
Explicitly defines the target name for the generated script archive. By default, the current artifact id will be taken (optionally appended with a classifier). If you explicitly set an archive file name, the artifact will no longer be attached to the build (so not installed in the local repository).


qualifier

protected String qualifier
An optional qualifier for the artifact. This can be used if the archive is not the main artifact of the pom.


scriptEncoding

protected String scriptEncoding
Encoding to use when reading the script files. Defaults to ISO-8859-1


postProcessingScriptDirectoryName

protected String postProcessingScriptDirectoryName
Comma separated list of directories and files in which the post processing database scripts are located. Directories in this list are recursively search for files. Defaults to postprocessing


qualifiers

protected String qualifiers
Optional comma-separated list of script qualifiers. All custom qualifiers that are used in script file names must be declared.


patchQualifiers

protected String patchQualifiers
The qualifier to use to determine whether a script is a patch script. Defaults to patch. E.g. 01_#patch_myscript.sql


scriptFileExtensions

protected String scriptFileExtensions
Sets the scriptFileExtensions property, that defines the extensions of the files that are regarded to be database scripts. The extensions should not start with a dot. The default is 'sql,ddl'.

Constructor Detail

CreateScriptArchiveMojo

public CreateScriptArchiveMojo()
Method Detail

createDbMaintainTask

protected DbMaintainTask createDbMaintainTask()
Specified by:
createDbMaintainTask in class BaseMojo

performAfterTaskActions

protected void performAfterTaskActions()
Description copied from class: BaseMojo
Hook method to perform some operations (such as attaching an artifact) when the task has completed successfully.

Overrides:
performAfterTaskActions in class BaseMojo


Copyright © 2011. All Rights Reserved.