Class 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 Detail

      • 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).
    • Constructor Detail

      • BatonMojo

        public BatonMojo()
    • Method Detail

      • 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
      • loadMigrations

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

        protected Map<String,​MigrationTarget> loadMigrationsJson​(File migrationsFile,
                                                                       Map<String,​MigrationTarget> migrationTargets)
        Loads all MigrationTargets contained within the given InputStream, which is expected to reference the desired migrations.json file to load.
        Parameters:
        migrationsFile - File referencing migrations.json file desired to load.
        migrationTargets - the migration targets already loaded to this point
        Returns:
        Map containing all loaded MigrationTargets with their corresponding name as the map key.
      • getFileSetsForTarget

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