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.AbstractMojoA 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
Fields Modifier and Type Field Description protected StringbackupCustomLocationCustomizes the location where backup of original files prior to migration is performed.protected booleanbackupOriginalMigratedFilesAllows backup of original files prior to migration to be turned off.protected FilebaseDirectoryBase directory in which to operate.protected Set<String>deactivateMigrationsAllows a list of migration names that should be deactivated.protected org.apache.maven.shared.model.fileset.FileSet[]fileSetsA list of fileSet rules to select files and directories.protected StringmigrationsFileNameThe configurations file name to look for in the classpath (all matches will be used).protected StringminimumVersionUsed to filter out migrations that are less than the valueprotected intnumberOfBackupsToKeepAllows the number of backups for original files prior to migration to be customized.protected static StringORDEREDprotected org.apache.maven.project.MavenProjectprojectEnables access to the runtime properties associated with the project's POM configuration against which Baton is being executed.protected FilesourceDirectoryFolder in which source files are located.protected FiletestDirectoryFolder in which test files are located, if not already covered by sourceDirectory (e.g., with typical python project standards).protected static StringVERSIONED
-
Constructor Summary
Constructors Constructor Description BatonMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddefaultFileSets()voidexecute()protected org.apache.maven.shared.model.fileset.FileSet[]getFileSetsForTarget(MigrationTarget target)protected com.fasterxml.jackson.databind.ObjectMapperinitializeObjectMapper()protected booleanisActive(MigrationTarget migrationTarget)protected booleanisMinimumVersion(MigrationTarget migrationTarget, String groupType)protected voidloadMigrations()Scans the classpath for any migrations.json files and loads all definedMigrationTargetconfigurations.protected voidsortMigrationsInGroups(List<GroupTarget> groupTargets)
-
-
-
Field Detail
-
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
@Parameter(property="baton.testDirectory", required=false) protected File testDirectoryFolder 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[] 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 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
protected static final String VERSIONED
- See Also:
- Constant Field Values
-
ORDERED
protected static final String ORDERED
- See Also:
- Constant Field Values
-
-
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.MojoExecutionExceptionorg.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 definedMigrationTargetconfigurations.
-
getFileSetsForTarget
protected org.apache.maven.shared.model.fileset.FileSet[] getFileSetsForTarget(MigrationTarget target)
-
-