Class BatonMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.technologybrewery.baton.BatonMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="baton-migrate", defaultPhase=VALIDATE, requiresDependencyResolution=COMPILE, threadSafe=true) public class BatonMojo extends org.apache.maven.plugin.AbstractMojo
A Maven plugin that allows migration logic to be executed against a Maven module based on a classpath-provided migrations. These are intended to run every time the build runs such that they perform a migration or no-op appropriately.
  • Field Details

    • project

      @Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject project
      Enables access to the runtime properties associated with the project's POM configuration against which Baton is being executed.
    • baseDirectory

      @Parameter(property="baton.baseDirectory", required=true, defaultValue="${project.basedir}") protected File baseDirectory
      Base directory in which to operate.
    • sourceDirectory

      @Parameter(property="baton.sourceDirectory", required=true, defaultValue="${project.basedir}/src") protected File sourceDirectory
      Folder in which source files are located.
    • testDirectory

      @Parameter(property="baton.testDirectory", required=false) protected File testDirectory
      Folder in which test files are located, if not already covered by sourceDirectory (e.g., with typical python project standards).
    • minimumVersion

      @Parameter(property="baton.minimumVersion", required=false, defaultValue="0.0.0") protected String minimumVersion
      Used to filter out migrations that are less than the value
    • fileSets

      @Parameter protected org.apache.maven.shared.model.fileset.FileSet[] fileSets
      A list of fileSet rules to select files and directories. Will be defaulted based on project information if not specified.
    • migrationsFileName

      @Parameter(property="baton.migrationsConfigurationFile", required=false, defaultValue="migrations.json") protected String migrationsFileName
      The configurations file name to look for in the classpath (all matches will be used). Defaults to migrations.json.
    • deactivateMigrations

      @Parameter(property="baton.deactivateMigrations", required=false) protected Set<String> deactivateMigrations
      Allows a list of migration names that should be deactivated. This provides an opportunity to turn off specific migrations that don't work as desired or a project just doesn't want in a "last mile" fashion.
    • backupOriginalMigratedFiles

      @Parameter(property="baton.backupOriginalMigratedFiles", required=false, defaultValue="true") protected boolean backupOriginalMigratedFiles
      Allows backup of original files prior to migration to be turned off.
    • backupCustomLocation

      @Parameter(property="baton.backupCustomLocation", required=false) protected String backupCustomLocation
      Customizes the location where backup of original files prior to migration is performed. By default, the system temp directory is used.
    • numberOfBackupsToKeep

      @Parameter(property="baton.numberOfBackupsToKeep", required=true, defaultValue="10") protected int numberOfBackupsToKeep
      Allows the number of backups for original files prior to migration to be customized. This will impact the number of backups, not the total number. So if set to 5, you will have 5 *prior* backup files as well as one active backup. This is based on the file rotation library works.
    • VERSIONED

      protected static final String VERSIONED
      See Also:
    • ORDERED

      protected static final String ORDERED
      See Also:
  • Constructor Details

    • BatonMojo

      public BatonMojo()
  • Method Details

    • initializeObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper initializeObjectMapper()
    • defaultFileSets

      protected void defaultFileSets()
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • sortMigrationsInGroups

      protected void sortMigrationsInGroups(List<GroupTarget> groupTargets)
    • isActive

      protected boolean isActive(MigrationTarget migrationTarget)
    • isMinimumVersion

      protected boolean isMinimumVersion(MigrationTarget migrationTarget, String groupType)
    • loadMigrations

      protected void loadMigrations()
      Scans the classpath for any migrations.json files and loads all defined MigrationTarget configurations.
    • getFileSetsForTarget

      protected org.apache.maven.shared.model.fileset.FileSet[] getFileSetsForTarget(MigrationTarget target)