Some plugins already do this for you, but in cases where they don’t, I would normally just add a line in the main build.gradle
after plugins { }
or apply plugin
that saves the task type as an extra project property.
ext.FlywayMigrateTask = org.flywaydb.gradle.task.FlywayMigrateTask
This reduces the task declaration to just the property name (conveniently set the same the task type), and usually avoids classpath issues between scripts. You should be able to use this in a separate file used in your project with plugins { }
or any subproject of it.
task migrateDb(type: FlywayMigrateTask) {