Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*-
* ========================LICENSE_START=================================
* flyway-gradle-plugin
* ========================================================================
* Copyright (C) 2010 - 2024 Red Gate Software Ltd
* ========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =========================LICENSE_END==================================
*/
package org.flywaydb.gradle.task;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.api.Location;
import org.flywaydb.core.internal.configuration.ConfigUtils;
import org.flywaydb.core.internal.jdbc.DriverDataSource;
import org.flywaydb.core.internal.util.StringUtils;
import org.flywaydb.gradle.FlywayExtension;
import org.gradle.api.DefaultTask;
import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.artifacts.ResolvedConfiguration;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.api.tasks.TaskAction;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.*;
import static org.flywaydb.core.internal.configuration.ConfigUtils.FLYWAY_PLUGINS_PREFIX;
import static org.flywaydb.core.internal.configuration.ConfigUtils.makeRelativeLocationsBasedOnWorkingDirectory;
import static org.flywaydb.core.internal.configuration.ConfigUtils.putIfSet;
/**
* A base class for all Flyway tasks.
*/
public abstract class AbstractFlywayTask extends DefaultTask {
/**
* The default Gradle configurations to use.
*/
// #2272: Gradle 4.x introduced additional configuration names and Gradle 5.0 deprecated some old ones.
// -> Rely on historic ones for Gradle 3.x
private static final String[] DEFAULT_CONFIGURATIONS_GRADLE3 = {"compileClasspath", "runtime", "testCompileClasspath", "testRuntime"};
// -> And use new ones with Gradle 4.x and newer
private static final String[] DEFAULT_CONFIGURATIONS_GRADLE45 = {"compileClasspath", "runtimeClasspath", "testCompileClasspath", "testRuntimeClasspath"};
/**
* The flyway {} block in the build script.
*/
protected FlywayExtension extension;
/**
* The fully qualified classname of the JDBC driver to use to connect to the database.
*/
public String driver;
/**
* The JDBC url to use to connect to the database.
*/
public String url;
/**
* The user to use to connect to the database.
*/
public String user;
/**
* The password to use to connect to the database.
*/
public String password;
/**
* The maximum number of retries when attempting to connect to the database. After each failed attempt, Flyway will
* wait 1 second before attempting to connect again, up to the maximum number of times specified by connectRetries.
* The interval between retries doubles with each subsequent attempt.
* (default: 0)
*
Also configurable with Gradle or System Property: ${flyway.connectRetries}
*/
public int connectRetries;
/**
* The maximum time between retries when attempting to connect to the database in seconds. This will cap the interval
* between connect retry to the value provided.
* (default: 120)
*
Also configurable with Gradle or System Property: ${flyway.connectRetriesInterval}
*/
public int connectRetriesInterval;
/**
* The SQL statements to run to initialize a new database connection immediately after opening it.
* (default: {@code null})
*
Also configurable with Gradle or System Property: ${flyway.initSql}
*/
public String initSql;
/**
* The name of the schema history table that will be used by Flyway. (default: flyway_schema_history)
* By default, (single-schema mode) the schema history table is placed in the default schema for the connection provided by the datasource.
* When the {@code flyway.schemas} property is set (multi-schema mode), the schema history table is placed in the first schema of the list,
* or in the schema specified to {@code flyway.defaultSchema}.
*
Also configurable with Gradle or System Property: ${flyway.table}
*/
public String table;
/**
* The tablespace where to create the schema history table that will be used by Flyway.
* If not specified, Flyway uses the default tablespace for the database connection.
* This setting is only relevant for databases that do support the notion of tablespaces. Its value is simply
* ignored for all others.
*
Also configurable with Gradle or System Property: ${flyway.tablespace}
*/
public String tablespace;
/**
* The default schema managed by Flyway. This schema name is case-sensitive. If not specified, but schemas
* is, Flyway uses the first schema in that list. If that is also not specified, Flyway uses the default schema for the
* database connection.
*
Consequences:
*
*
This schema will be the one containing the schema history table.
*
This schema will be the default for the database connection (provided the database supports this concept).
*
*
Also configurable with Gradle or System Property: ${flyway.defaultSchema}
*/
public String defaultSchema;
/**
* Whether Flyway should attempt to create the schemas specified in the schemas property.
*/
public Boolean createSchemas;
/**
* The schemas managed by Flyway. These schema names are case-sensitive. If not specified, Flyway uses
* the default schema for the database connection. If defaultSchema is not specified, then the first of
* this list also acts as default schema.
*
Consequences:
*
*
Flyway will automatically attempt to create all these schemas, unless they already exist.
*
The schemas will be cleaned in the order of this list.
*
If Flyway created them, the schemas themselves will be dropped when cleaning.
*
*
Also configurable with Gradle or System Property: ${flyway.schemas} (comma-separated list)
*/
public String[] schemas;
/**
* The version to tag an existing schema with when executing baseline. (default: 1)
*/
public String baselineVersion;
/**
* The description to tag an existing schema with when executing baseline. (default: << Flyway Baseline >>)
*/
public String baselineDescription;
/**
* Locations to scan recursively for migrations.
* The location type is determined by its prefix.
* Unprefixed locations or locations starting with {@code classpath:} point to a package on the classpath and may
* contain both SQL and Java-based migrations.
* Locations starting with {@code filesystem:} point to a directory on the filesystem, may only
* contain SQL migrations and are only scanned recursively down non-hidden directories.
* (default: filesystem:src/main/resources/db/migration)
*/
public String[] locations;
/**
* The fully qualified class names of the custom MigrationResolvers to be used in addition (default)
* or as a replacement (using skipDefaultResolvers) to the built-in ones for resolving Migrations to
* apply. (default: none)
*/
public String[] resolvers;
/**
* If set to true, default built-in resolvers will be skipped, only custom migration resolvers will be used.
* (default: false)
*/
public Boolean skipDefaultResolvers;
/**
* The file name prefix for versioned SQL migrations. (default: V)
* Versioned SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix,
* which using the defaults translates to V1_1__My_description.sql
*
Also configurable with Gradle or System Property: ${flyway.sqlMigrationPrefix}
*/
public String sqlMigrationPrefix;
/**
* The file name prefix for undo SQL migrations. (default: U)
* Undo SQL migrations are responsible for undoing the effects of the versioned migration with the same version.
* They have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix,
* which using the defaults translates to U1.1__My_description.sql
* Flyway Teams only
*
Also configurable with Gradle or System Property: ${flyway.undoSqlMigrationPrefix}
*/
public String undoSqlMigrationPrefix;
/**
* The file name prefix for repeatable SQL migrations (default: R).
* Repeatable SQL migrations have the following file name structure: prefixSeparatorDESCRIPTIONsuffix,
* which using the defaults translates to R__My_description.sql
*
Also configurable with Gradle or System Property: ${flyway.repeatableSqlMigrationPrefix}
*/
public String repeatableSqlMigrationPrefix;
/**
* The file name prefix for SQL migrations
* SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix,
* which using the defaults translates to V1_1__My_description.sql
*/
public String sqlMigrationSeparator;
/**
* The file name suffixes for SQL migrations. (default: .sql)
* SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix,
* which using the defaults translates to V1_1__My_description.sql
* Multiple suffixes (like .sql,.pkg,.pkb) can be specified for easier compatibility with other tools such as
* editors with specific file associations.
*
Also configurable with Gradle or System Property: ${flyway.sqlMigrationSuffixes}
*/
public String[] sqlMigrationSuffixes;
/**
* The encoding of SQL migrations.
*/
public String encoding;
/**
* Whether Flyway should try to automatically detect SQL migration file encoding
* Flyway Teams only
*
Also configurable with Gradle or System Property: ${flyway.detectEncoding}
*/
public Boolean detectEncoding;
/**
* Placeholders to replace in SQL migrations.
*/
public Map