I took a look at the flyway gradle plugin code (https://github.com/flyway/flyway/tree/master/flyway-gradle-plugin) and my guess is that the flyway tasks depend on the compile tasks in order to support migrations written using the flyway Java api.
The flyway plugin seems to assume that that if the project is a java project then you are using the Java api.
Reading between the lines, it seems that flyway expects you to have a separate gradle sub-project for your migrations.
So, move your migrations to a sub-project called, say, 'migrations'. Then you can do
myBatisGenerator.dependsOn(':migrations:flywayMigrate')
and ':migrations:flywayMigrate' will only depend on ':migrations:compileTestJava' rather than your main ':compileTestJava' (and even then only if 'migrations' is a java project)