Class MigrateMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="migrate",
          requiresDependencyResolution=TEST,
          defaultPhase=PRE_INTEGRATION_TEST,
          threadSafe=true)
    public class MigrateMojo
    extends org.apache.maven.plugin.AbstractMojo
    Maven goal that triggers the migration of the configured database to the latest version.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected DaprConfiguration daprConfiguration
      The configuration for DAPR Secrets Store.
      protected java.lang.String driver
      The fully qualified classname of the JDBC driver to use to connect to the database.
      java.lang.Boolean failOnMissingLocations
      Whether to fail if a location specified in the flyway.locations option doesn't exist
      protected GcsmConfiguration gcsmConfiguration
      The configuration for Google Cloud Secret Manager.
      protected org.apache.maven.project.MavenProject mavenProject
      Reference to the current project that includes the Flyway Maven plugin.
      protected org.apache.maven.settings.Settings settings
      The link to the settings.xml
      protected boolean skip
      Whether to skip the execution of the Maven Plugin for this module.
      protected java.lang.String url
      The JDBC url to use to connect to the database.
      protected java.lang.String user
      The user to use to connect to the database.
      protected VaultConfiguration vaultConfiguration
      The configuration for Vault secrets manager.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      MigrateMojo()  
    • Method Summary

      Modifier and Type Method Description
      protected void doExecute​(org.flywaydb.core.Flyway flyway)
      Executes this mojo.
      void execute()  
      protected boolean getBooleanProperty​(java.lang.String systemPropertyName, boolean mavenPropertyValue)
      Retrieves the value of this boolean property, based on the matching System property on the Maven property.
      protected java.lang.String getProperty​(java.lang.String name)
      Retrieves this property from either the system or the maven properties.
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • skip

        @Parameter(property="flyway.skip")
        protected boolean skip
        Whether to skip the execution of the Maven Plugin for this module.

        Also configurable with Maven or System Property: ${flyway.skip}

      • driver

        @Parameter(property="flyway.driver")
        protected java.lang.String driver
        The fully qualified classname of the JDBC driver to use to connect to the database. By default, the driver is autodetected based on the url.

        Also configurable with Maven or System Property: ${flyway.driver}

      • url

        @Parameter(property="flyway.url")
        protected java.lang.String url
        The JDBC url to use to connect to the database.

        Also configurable with Maven or System Property: ${flyway.url}

      • user

        @Parameter(property="flyway.user")
        protected java.lang.String user
        The user to use to connect to the database. (default: blank) The credentials can be specified by user/password or serverId from settings.xml

        Also configurable with Maven or System Property: ${flyway.user}

      • failOnMissingLocations

        @Parameter(property="flyway.failOnMissingLocations")
        public java.lang.Boolean failOnMissingLocations
        Whether to fail if a location specified in the flyway.locations option doesn't exist
      • settings

        @Parameter(defaultValue="${settings}",
                   readonly=true)
        protected org.apache.maven.settings.Settings settings
        The link to the settings.xml
      • vaultConfiguration

        @Parameter
        protected VaultConfiguration vaultConfiguration
        The configuration for Vault secrets manager. You will need to configure the following fields:
        • vaultUrl: The REST API URL of your Vault server - https://flywaydb.org/documentation/configuration/parameters/vaultUrl
        • vaultToken: The Vault token required to access your secrets - https://flywaydb.org/documentation/configuration/parameters/vaultToken
        • vaultSecrets: A list of paths to secrets in Vault that contain Flyway configurations - https://flywaydb.org/documentation/configuration/parameters/vaultSecrets
        Flyway Teams only
      • daprConfiguration

        @Parameter
        protected DaprConfiguration daprConfiguration
        The configuration for DAPR Secrets Store. You will need to configure the following fields:
        • daprUrl: The REST API URL of your Dapr application sidecar - https://flywaydb.org/documentation/configuration/parameters/daprUrl
        • daprSecrets: A list of paths to secrets in Dapr that contain Flyway configurations - https://flywaydb.org/documentation/configuration/parameters/daprSecrets
        Flyway Teams only
      • gcsmConfiguration

        @Parameter
        protected GcsmConfiguration gcsmConfiguration
        The configuration for Google Cloud Secret Manager. You will need to configure the following fields:
        • gcsmProject: The Project which contains your secrets - https://flywaydb.org/documentation/configuration/parameters/gcsmProject
        • gcsmSecrets: A list of secrets in GCSM that contain Flyway configurations - https://flywaydb.org/documentation/configuration/parameters/gcsmSecrets
        Flyway Teams only
      • mavenProject

        @Parameter(defaultValue="${project}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.project.MavenProject mavenProject
        Reference to the current project that includes the Flyway Maven plugin.
    • Constructor Detail

      • MigrateMojo

        public MigrateMojo()
    • Method Detail

      • doExecute

        protected void doExecute​(org.flywaydb.core.Flyway flyway)
                          throws java.lang.Exception
        Executes this mojo.
        Parameters:
        flyway - The flyway instance to operate on.
        Throws:
        java.lang.Exception - Any exception.
      • getBooleanProperty

        protected boolean getBooleanProperty​(java.lang.String systemPropertyName,
                                             boolean mavenPropertyValue)
        Retrieves the value of this boolean property, based on the matching System property on the Maven property.
        Parameters:
        systemPropertyName - The name of the System property.
        mavenPropertyValue - The value of the Maven property.
      • execute

        public final void execute()
                           throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getProperty

        protected java.lang.String getProperty​(java.lang.String name)
        Retrieves this property from either the system or the maven properties.
        Parameters:
        name - The name of the property to retrieve.
        Returns:
        The property value. null if not found.