Package org.technologybrewery.baton
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 Summary
FieldsModifier and TypeFieldDescriptionprotected StringCustomizes the location where backup of original files prior to migration is performed.protected booleanAllows backup of original files prior to migration to be turned off.protected FileBase directory in which to operate.Allows a list of migration names that should be deactivated.protected org.apache.maven.shared.model.fileset.FileSet[]A list of fileSet rules to select files and directories.protected StringThe configurations file name to look for in the classpath (all matches will be used).protected StringUsed to filter out migrations that are less than the valueprotected intAllows the number of backups for original files prior to migration to be customized.protected static final Stringprotected org.apache.maven.project.MavenProjectEnables access to the runtime properties associated with the project's POM configuration against which Baton is being executed.protected FileFolder in which source files are located.protected FileFolder in which test files are located, if not already covered by sourceDirectory (e.g., with typical python project standards).protected static final StringFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidexecute()protected org.apache.maven.shared.model.fileset.FileSet[]getFileSetsForTarget(MigrationTarget target) protected com.fasterxml.jackson.databind.ObjectMapperprotected booleanisActive(MigrationTarget migrationTarget) protected booleanisMinimumVersion(MigrationTarget migrationTarget, String groupType) protected voidScans the classpath for any migrations.json files and loads all definedMigrationTargetconfigurations.protected voidsortMigrationsInGroups(List<GroupTarget> groupTargets) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject projectEnables 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 baseDirectoryBase directory in which to operate. -
sourceDirectory
@Parameter(property="baton.sourceDirectory", required=true, defaultValue="${project.basedir}/src") protected File sourceDirectoryFolder in which source files are located. -
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 minimumVersionUsed to filter out migrations that are less than the value -
fileSets
@Parameter protected org.apache.maven.shared.model.fileset.FileSet[] fileSetsA 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 migrationsFileNameThe 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> deactivateMigrationsAllows 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 backupOriginalMigratedFilesAllows backup of original files prior to migration to be turned off. -
backupCustomLocation
@Parameter(property="baton.backupCustomLocation", required=false) protected String backupCustomLocationCustomizes 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 numberOfBackupsToKeepAllows 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
- See Also:
-
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.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
sortMigrationsInGroups
-
isActive
-
isMinimumVersion
-
loadMigrations
protected void loadMigrations()Scans the classpath for any migrations.json files and loads all definedMigrationTargetconfigurations. -
getFileSetsForTarget
protected org.apache.maven.shared.model.fileset.FileSet[] getFileSetsForTarget(MigrationTarget target)
-