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 FilebaseDirectoryBase directory in which to operate.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).
-
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 voidloadMigrations()Scans the classpath for any migrations.json files and loads all definedMigrationTargetconfigurations.protected Map<String,MigrationTarget>loadMigrationsJson(File migrationsFile, Map<String,MigrationTarget> migrationTargets)Loads allMigrationTargets contained within the givenInputStream, which is expected to reference the desired migrations.json file to load.
-
-
-
Field Detail
-
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).
-
-
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
-
loadMigrations
protected void loadMigrations()
Scans the classpath for any migrations.json files and loads all definedMigrationTargetconfigurations.
-
loadMigrationsJson
protected Map<String,MigrationTarget> loadMigrationsJson(File migrationsFile, Map<String,MigrationTarget> migrationTargets)
Loads allMigrationTargets contained within the givenInputStream, which is expected to reference the desired migrations.json file to load.- Parameters:
migrationsFile-Filereferencing migrations.json file desired to load.migrationTargets- the migration targets already loaded to this point- Returns:
Mapcontaining all loadedMigrationTargets with their corresponding name as the map key.
-
getFileSetsForTarget
protected org.apache.maven.shared.model.fileset.FileSet[] getFileSetsForTarget(MigrationTarget target)
-
-