ai.digital.integration.server.common.tasks.database.PrepareDatabaseTask.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integration-server-gradle-plugin Show documentation
Show all versions of integration-server-gradle-plugin Show documentation
The easy way to get custom setup for Deploy up and running
package ai.digital.integration.server.common.tasks.database
import ai.digital.integration.server.common.constant.PluginConstant.PLUGIN_GROUP
import ai.digital.integration.server.common.util.DbUtil
import org.gradle.api.DefaultTask
import org.gradle.api.Project
open class PrepareDatabaseTask : DefaultTask() {
companion object {
const val NAME = "prepareDatabase"
}
init {
this.group = PLUGIN_GROUP
val dbName = DbUtil.databaseName(project)
project.afterEvaluate {
injectDbDependency(project, dbName)
}
}
private fun injectDbDependency(project: Project, dbName: String) {
val testCompile = project.configurations.findByName("testCompile")
testCompile?.let { it ->
val dbDependency = DbUtil.detectDbDependencies(dbName).driverDependency
project.logger.debug("Test compile configuration has been found. Injecting database dependency '$dbDependency' for db: '$dbName'")
project.dependencies.add(it.name, dbDependency)
}
}
}